Fitness trackers became very popular over the last few years. These brilliant tools help us to achieve our goals in sports and even exceed our expectations.
The more sensor these devices have, the more we can do. Here's the time to examine how barometers can be used in sports and how they can help us in other parts of our life.
Before you read any further I recommend you to download and install my application. You might need to manually give SMS sending permission if you want to use fall detection. Here's the true story of how this project was born:
A customer from far awayA couple of weeks ago, a guy called Darth Vader and his strange pals asked my help. They acquired a device of unknown origin from some kind of 'Rebels'. I don't know who those guys are but whatever. These are definitely some strange folks. He also said that I can call him Lord Vader. He must be English.
Lord Vader told me that he has some serious health problems and would like to use this device to improve his quality of life. He was unsure how to do that and asked me to come up with ways to use the unknown device, the so called Sensor Hub Nano.
Getting know the Sensor Hub NanoAfter some researching I realized that this device contains a microcontroller, a bluetooth module and a barometer sensor called DPS310, produced by Infineon. They are making some great stuff and I saw great potential here, so I started working.
A barometer is used to measure air pressure and in our case it is great to detect vertical movement. After some experimenting I realized that it can detect even just a couple of centimeters of movement with quite high accuracy and it also has a built-in temperature sensor to further improve the measurements.
After that I talked with the customer and asked him to tell me about his health conditions. Finding the problem is the first step of finding the solution.
Up-Down movement countingLord Vader then told me that lots of years ago, during a business trip to a place called Mustafar he got some serious injuries. Nasty story. I'll never go to spend my holidays there. After this event, his doctor suggested him that he should do daily fitness training to keep his health from declining.
I created an app with a counter function to help him following his development. However constant thresholds might work, but if the air pressure changes during the workout, it might cause problems. I used a fix sized and moving window to detect this up-down movement.
Let's take and example: squat.
- Connecting to a paired BT device is always possible, but if it is not supported, you'll get a Toast error message. Even then the app won't force you back to the paired devices screen, so you can browse the UI.
- Going down - altitude decreases
- Reaching the bottom of the window. Registering this event.
- Further movement down, the window is following the movement,
- Reaching the bottom
- Going up
- Reaching the top of the window, Registering this event and increasing the counter
- Further movement up, the window is following the movement.
- Reaching the top.
This is the process and it worked perfectly in every examined case. Push ups, sit ups or jumping? It can be used in all kinds of sports. A goal can also be added, so you don't even have to watch your phone during the workout. You'll hear a beep when you reach you goal.
I showed it to Lord Vader and he loved it.
Good to know:
- Use magnets to connect the Sensor Hub Nano to your body. I recommend connecting it to somewhere around your shoulder or wrists. It depends on the exercise you'd like to do.
- Counting starts with 0 and you can reset it at any time. The counter will be incremented once you reach the upper threshold of the window.
- You can set an optional goal, too. Once you reach the goal, it will notify you with a sound and the counter text will turn to green.
- Due to the moving window, it will automatically adapt to any altitude. It can continuously work even if you are moving between floors, but it might cause a false positive event when you move up and down.
- Navigating to a different function will stop the original function's operation
He said that he loves throwing things and people (Ok, I guess?). It helps him to handle his problems. His pals seemed to worry about this topic. I smell a good story here. I created a little game to chill his nerves. He can also play it with his friends. All he has to do is start the game and try to throw the Sensor Hub Nano as high as the given target is and then catch it. The person with the closest throwing to the target is the winner.
The working principals are very simple:
- The system generates a target high
- You throw it up and it measures the maximum altitude of the DPS310's path
- If the difference between the target and your current maximum is smaller than the current record then this is the new record
- You catch it and try again
This is a great skill game and you can play it anywhere. They liked this game very much. Maybe too much. He started playing with his friends and I couldn't get the Sensor Hub Nano back from him. Luckily someone came and told him something about those 'Rebels' and he left without the Sensor Hub Nano.
Good to know:
- The range of the generated target varies between 0.5 - 2 m from the starting height
- A valid throw must end under the 0 m relative height
- Heating up the DPS310 can affect the values. Try to minimize it.
Later on this day he sent me an e-mail regarding another one of his wishes. He hates standing. Whenever he can he sits down. This is comfortable, but his therapist told him that he should stand up in every 30 minutes and walk a little. As a good patient he'd like to listen, but he always forgets about this issue. I can help with that, too. I integrated this new function into the app.
Here's how it works:
- You have to set how much minutes you'd like to sit before your hear the alarm. Let's say 30 minutes
- Sit down
- Click Start
- Sit comfortably
- When this 30 minutes passes, you'll hear an alarm
- If you stand up it will reset the countdown.
- If you don't stand up, the alarm will start again in 5 minutes
A not too aggressive way, but it does the job. It will definitely solve his problem.
Good to know:
- This function uses a fix threshold, updated on start
- It is recommended to click on start while standing and then sit down.
- If you reach the "sitting for minutes" time, then you'll hear an alarm. It won't force you to stand up, but a new countdown, from 5 minutes will be started until you stand up, or click on the stop button.
- If you stand up and then sit down, it will start counting down from the given time, not from 5 minutes.
- Standing for only a moment is enough to reset the timer. It doesn't force you to walk for minutes, however that would be desired and healthy.
Darth Vader came back half-heartedly:
- It is boring, the Rebels are weak. I can easily beat them. Fighting was better in the old days... - he said.
I guess he is talking about some kind of game, so I suggested him that he should do challenges. He liked this idea and we came up with a fun challenge. Beat the Rebels while Lord Vader locks himself in an altitude window. It means that he can't go higher or lower than what the preset range let's him. Otherwise he'll hear the alarm to warn him.
Good to know:
- Altitude lock works very similar like the previous function (sitting timer), but you can set the ranges manually and it works both up and down.
- Fall detection and Altitude lock can work in parallel at the same time or you can enable only one of them.
- A tipical use case for Altitude lock is to prevent old people or children from leaving a specific altitude range. Stairs can be dangerous and old people with not mental issues might forget about it. This function can notify them to don't do this and ask for help. It can also be a way of parental control for smaller children, preventing them to climb too high or too deep.
He was thrilled and was running around to tell everybody about this new challenge when an accident happened. He stumbled on an RC car like robot. He fell hard and was unconscious for 10 minutes. Even after he woke up, he couldn't just stand up, he needed help. He told that he is old and sometimes things like this happens. He is lucky that he wasn't alone during the accident.
After that I came up with the idea of fall detection. Falling is a very serious problem, especially among older people. If help doesn't come by itself and you can't call for help then it might lead to the death of the injured person.
My solution works like this:
- You set the emergency message and the phone number of your emergency contact
- Click start
- If you fall it will cause a fast decrease in you altitude. The system will register this event and will start counting down
- If you don't stand up then the app will send the emergency message to your contact
The system monitors the altitude change speed and not fixed altitude thresholds. Sitting down, or taking a walk in the cellar won't be recognized as fall. Only if this altitude change happens too fast. This function can mean the difference between life or death for lot's of people.
Lord Vader immediately enabled this function. He used the phone number of some Palpatine guy as emergency contact. After that he told me that he is very grateful and the Force is strong with me. I'm not sure what did he mean by that but I guess it is something good. Strong is always good.
Another satisfied customer and I made the world a little bit better place, again. This is a great end for this week.
Good to know:
- This function based on the differential of the raw signal so altitude change itself won't trigger fall event, unless the change is too fast. If you jump into the bed too fast it might be recognized as falling.
- Falling can be very dangerous, especially for old people, but anyone can be in a fall related life or death situation, hikers, pedestrians, cyclists, etc. This function can make a huge difference in these cases.
- To use emergency sms function. you have to give permission for the app to send SMS, otherwise it won't work.
- Fall detection and Altitude lock will make the same alarm sound when triggered
- If you fall, the app will immediateliy start the alarm sound and it will continue until you stand up. After 15 seconds it will send the emergency SMS to the given phone number. Sending the SMS won't stop the alarm sound. You'll be notified about the SMS using with a Toast message.
The app itself is in perfectly working condition. However, in the future I plan to improve the UI and optimize the usage of the DPS310. The Sensor Hub Nano is powered be a small battery and BT can suck it dry quite fast. In some cases less reading per minute wouldn't affect much.
On the UI side I will create a loading screen when connecting to the Sensor Hub Nano. I'll also create an indicator to show the user when it is disconnected from the phone. A way to reconnect with just one click will also be in the next version.
The logic of the code is great, however the sensibility of the falling detection might require some fine tuning (if you sit down to the floor very fast it will recognize it as falling). The code for the sitting part will be changed to something similar to the counter's code. It is just proved to be more accurate than the current code for sitting.
ConclusionAccidents can happen to anybody and sports are needed to keep you fit. There's no exception to that. Not even if you are Darth Vader.
Barometers are a must have sensor for the new generation fitness trackers. They can create a whole range of new applications, and this 5 function is just the top of the iceberg. We can make apps with them, apps that matters and can hugely affect the life of people in a positive way.
These are real life ways of using this great piece of hardware, called Infineon DPS310.
This funny style is experimental, so please give me some feedback whether you liked it or not. I hope you liked my project, the funny tone and I hope it gave you some motivation to use your imagination and create something new, something that will move the world forward!
Thank you for reading and have a nice day!
Comments