There are numerous well-known accidents when a child climbs on a chair, rock or window and falls down which in some cases can lead to tragic consequences. As a parent I realize that it is impossible to track each step of your little baby (especially when you need to take care of more than one kid at the same time). We need to be careful and look after children if they play safely. In my opinion DPS130 sensor with its tremendous accuracy enables us to create a great and helpful application in mentioned domain. The idea is as follows:
How does it work?My solution is based on the Sensor Hub Nano (EVAL SHNBV01) module from Infineon. This board could be easily attached to a diaper for instance. Once we establish BLE connection between module and our smartphone with Android system, we can enable this device. Application on the smartphone is responsible for communicating with the module, and setup all necessary details as desired. Since the altitude measurements are based on the pressure sensors so the first values which we are going to obtain are relative to the sea level. Because of that we have to run the calibration by pressing the "Set Reference level" button. It allows us to adjust the readings to our external conditions. Then we need to trigger main workflow of the application (tracking the altitude) by pressing "Start Watching" button. If child climbs above some safe threshold (i.e. 40cm or 15.7”) above level "0" (reference level set before) the audio notification will be fired up on our smartphone. Alarm will occur as long as we do not hit the "Stop Watching" button.
HardwareFor this project I have used the Sensor Hub Nano ( EVAL SHNBV01) see below.
Sensor Hub Nano contains everything from the hardware stand point which I need to realize LeapKid concept.
The solution is build on top of the Pressure Sensor DPS310, BLE Module, Battery, and MCU which takes care to read the data from the sensor and push them via BLE to the smartphone.
The accuracy of the DPS310 is outstanding and allows to create an application which was never considered before.
Worth to mention is that the pressure sensor has a great advantage over the accelerometers in this kind of application because:
- Level reading are independent from position how it is assembled on the object which we want to monitor
- Accelometers measure the change in the movement so the are always relative. Pressure sensor can give you a chance to use the absolute values which are perfect this this application.
Also very interesting material why DPS310 pressure is different compare to other sensors from other vendors and what makes them so accurate. See link below:
Because of this accuracy, the many new technical solution can be done. One of them is LeapKid.
SoftwareFor this project I have used Android Studio (first time in my life) and Android libraries for this Sensor Hub which are available thanks to the Infineon team. Based on this information I was able to create my first Android application which I would like to describe in details below:
Application shows the Device number and after pressing the "Connect" button allows to start collecting the information from the Sensor Hub module.
On Fig3. you can find that the values being obtained for altitude are relative to the sea level. In order to correct them we mount the module on the level we want to treat as a "ground floor". By pressing the "Set Reference Level" button the offset is being set. After that operation we get the following screen:
On Fig4/5 we can see that the system is ready and operate properly.
Rest of the logic behind it is simple since the operator (parent) cannot spend too much time on calibrating the device.
When you press the "Start Watching" button the system tracks if the altitude is not higher than 0.4m [15.7”]. If it is, then it turns on the audio alarm on our smartphone. Thanks to that it lets us know the child reached the safe threshold. Alarm will work as long as we do not deactivate it by pressing the "STOP Watching" button.
Core functionality
public void onSensorDataReceived(SensorHub sensorHub, final SensorEvent sensorEvent) {
// measure altitude
if (sensorEvent.getDataId().equals("a")) {
Alt = sensorEvent.getSensorValue();
Alt_adjust = (Alt - Alt_offset); // Setup the altitude level with correct offset
if (Alt_adjust < 0.15) Alt_adjust = 0; // Ignore changes of the altitude below 15cm
if(Active) { // here we activate an alarm if requested conditions happen
if (Alt_adjust >= 0.4) alarm_on(); // we will engage the sound alarm if the altitude will reach 40cm or more.
}
Altitude.setText(Alt_adjust + "m");
}
}
});
sensorHub.connect();
btnSet.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) { // Activate watching
Active = true;
}
});
btnReset.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) { // Deactivate alarms
Active = false;
alarm_off();
}
});
btnOffset.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) { // setup the offset for altitude measurements
Alt_offset = Alt;
}
});
}
private void alarm_on() {
AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
float actualVolume = (float) audioManager
.getStreamVolume(AudioManager.STREAM_MUSIC);
float maxVolume = (float) audioManager
.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
float volume = actualVolume / maxVolume;
// Is the sound loaded already?
if (mLoaded) {
mSoundStreamId = mSoundPool.play(mSoundID, volume, volume, 1, -1, 1f);
}
Active = false;
} // function responsible for sound alarm activation
private void alarm_off() {
mSoundPool.stop(mSoundStreamId);
Active = false;
} // function responsible for deactivate the sound alarm
}
Note: The libraries provided by Infineon allow to set the precision for your application. In my case do to the fact that I am looking on high accuracy I setup sensor in the following way:
public void onConnected(SensorHub sensorHub) {
sensorHub.setMode("mode", "bg");
sensorHub.setMode("prs_mr", "128");
sensorHub.setMode("prs_osr", "128");
sensorHub.start();
}
VideoSummaryIt was a great experience to evaluate the DPS310 sensor and it capability. I see great potential to use this sensor in applications where we never before consider a pressure sensor due to low accuracy. Now with this sensor we can create the solution like i.e
- Respiratory analyses
- More precise weather forecast
- Flying objects precise height measurements
- Allow to check if the working area is hermetic ( i.e in bio-hazard materials )
- etc...
Note: BLE and single board solution drastically improve life of battery making a solution reliable for entire needed time.
Potential improvements / next steps ...- The system could be equipped with the Temp/Humidity sensor which could give us additional information if there is a need to change the diaper.
- BLE connection between application and module works in the background.
- Audio notification if the link between phone and module was dropped for some reason.
- Deactivate alarms if the jumps in altitude happen especially from bottom to top (i.e when parent lift the child from the "zero" level).
- Add option to change the safe threshold.
- Make it immune to occasional changes (i.e. child is jumping).
- Add additional accelometer which can detect the fall ( could be used for elder people )
Comments