GranCare: Pocket Size Health Monitor!
by Russel999 in Circuits > Arduino
2844 Views, 36 Favorites, 0 Comments
GranCare: Pocket Size Health Monitor!
So let me start, I have a grandma. She is a bit old but super fit and healthy. Well recently we had been to the doctor for her monthly checkup and the doctor advised her to walk every day for at least half an hour to keep her joints healthy. We needed a way to see how much she has walked. A smartwatch would have helped but its not something we could afford. Not just steps, grandma wanted to have like a small health kit so she could keep a check on herself.
So this is the reason why I thought of doing this project.
Also, falling is one of the most common and dangerous events, and last time my grandma fell we were late in knowing and it's something I could detect sooner so I decided to add a fall sensor too.
And to see if my grandma catches cold or fever, early-onset, I added a temperature sensor to measure body temperature.
I am concentrating on these things in this project. You can always add more sensors to make it more effective for your personal use.
Things Needed
Connecting Everything Together
Above is the schematic diagram for connection. It's pretty straight forward. For soldering, I stripped ribbon cable into individual wires as these wires are very thin (28 AWG). If you don’t have ribbon cable lying around you can use any wire that you wish.
I have added the pic with all connections done. You can zoom in the picture and follow the connections too. Don't mind the soldering it's not very good, new to it.
For the temperature sensor, you need to add a pull-up resistor between the positive and signal lines to make the sensor work correctly. Also, solder male jumper cables to the ends so that you can connect it to female header pins from the outside.
I have made an enclosure for all the components since I have a 3d printer at home. You don't have to do it. Rather you can make yourself a cardboard box or use a small container to place all the electronics. Make sure the accelerometer is stuck to the body of the case if you plan on making your own case.
Printing enclosure. [Optional]
There are two 3 files. Top and bottom case and switch. Attaching the switch is easy. I have added images above, you can follow it. I printed my files at 50% infill, 0.2mm height. You can get the original step files here if you want to change the design of the case.
After everything is assembled place the SD card inside the module and then close the device and using two 2mm screws on either side. I salvaged this screw from my sg90 servo motor set.
Make sure all the wires are properly soldered using multimeter by checking connectivity.
Make sure all the devices are getting proper voltage.
Note on powering the device.
For powering the device I have used 3.7v battery and it's good enough as all the sensor and wemos microcontroller can work at 3v. So if you plan to use more external sensors make sure they work at 3v. Also when the battery is about to die the SD card stops working this is because the voltage is not sufficient for the SD card module. So charging the battery solves the problem. The only drawback is you won't be able to use the complete potential of the battery. One way you can solve this is by using this charging module. This module steps up the voltage to 5v this way you won't have any problems running all the sensors.
Understanding Code
As I said in the beginning we will be tracking 3 things: FALL, STEPS, and TEMPERATURE.
This is not constrained, you can add any other sensor like heartbeat, oximeter, etc and get more health data. For now, I will be using 2 sensors that are accelerometer and temperature.
Finding the temperature is straight forward. After the sensor is connected we use the library DALLAS TEMPERATURE to find the degree Celcius.
To find steps and fall we will be using the accelerometer. The code starts with finding the acceleration value of 3 axis X, Y, and Z. and then determining the resultant acceleration.
Now there are two predefined thresh holds that are for step and fall. So whenever the resultant acceleration crosses this threshold, step or fall is detected.
Now since fall value is more important to be correct I have added a fall validation function where if a fall is detected then it also checks if the orientation has changed and if the person is idle. IF these two rules are true then the fall is confirmed and the message is sent to the database.
Along with this the device records all the data and writes it to sd card and every 30mins (can be changed) the values are sent to google firebase where it is stored in the realtime database.
To determine the values of the threshold I strapped the device on my waist and started doing different actions while the code was writing the acceleration value onto the SD card. Then later I imported the value into excel and plotted a line graph to analyze all the value. I have added some of the graphs above. You can see how different actions show different accelerometer values.
Setting Up WIFI and Google Database
With all the data that’s available, we need to find a way to store it so that we can use it to make a health profile and keep a track of your grandparent's health.
So to store the data and use it in realtime we are using Google Firebase and to achieves this we will be using the Esp8266Firebase library.
To set up the firebase you can follow this process. After this, you should have a secret key and host link. Just add these two in the code shown below along with your wifi name and password:
#define FIREBASE_HOST "YOUR_FIREBASE_PROJECT.firebaseio.com” #define FIREBASE_AUTH "YOUR_FIREBASE_DATABASE_SECRET" #define WIFI_SSID "YOUR_WIFI_AP" #define WIFI_PASSWORD "YOUR_WIFI_PASSWORD"
That’s It. That was easy. Our device has now connected to the online database where all the health data is stored. Now we can use this data to make a chart in excel or make a simple website to see the data visually or even connect it to an app.
Note:
To check if you have successfully added the library and if it works with your device try uploading example sketches provided in the library. You can try the one named beginner_start_here.
Programming WEMOS D1
Before we upload the code we need to install a few things.
Board:
- First, open up Arduino ide and go to Tools --> Board --> Boards manager and then search for esp8266 by ESP8266 community. Click install and wait for it to install.
- We have now added the board, to select it to go to Tools --> Board --> Wemos D1 R1
Libraries
- We need to install two libraries Firebase ESP8266 client by Mobizt and One wire by Jim Studt.
- To do this go to Sketch --> Include library --> Manage libraries. Search for the above two libraries and install them.
We have now installed everything necessary to run the code. Upload the below code and you are done!
Downloads
Connect Your Android App [Optional]
I used the MIT app inventor, which is a free drag and drop app maker. It's very easy to make an app this way. All the app does it checks the values in the database and displays them. Here is the project file for the app inventor. Just add your AUTH KEYS and HOSTNAME as shown above and that’s it.
Attach the Device to a Wearable
Now that everything is set up the only thing that's remaining is to attach it to a clothing piece like sweater. You can use any other clothing that your grandparents like too. For now, I have attached the device on the left side of the sweater along with a temperature sensor that runs below the armpit to measure the temperature. I have used masking tape to do it which is obviously not the best method. I am just using this for a few days for testing.
You can make a small pouch out of cloth and stitch it inside the sweater to keep the device and a sleeve to run the temperature sensor. Since I am not soo good at stitching things I haven't done this. But my mom is gonna fix that soon.
Doing More With GranCare.
Here I have used only two sensors but you can always add more. You can connect all the unused pins of WEMOS to the header pins and then externally connect more sensors to make the most of the sensor. You can add a heart sensor and then take your grandparent's heartbeat every hour and add it to the database or maybe add multiple temperature sensors. You can keep adding until WEMOS supports or the battery can handle it.
That’s about it. Take care of your grandparents, as they say, "A grandparents' love will never grow old."
UPDATE after use:
So I made my grandma use the device for a week. She did say the device does come in between sometimes but she is used to it now. So here's what I have learned from a week of using it.
- Fall detection works perfectly. I got alerts when she slipped two times in the last week. There are times when there is a false alarm, so maybe changing the threshold might help.
- Body temp data are perfect.
- Another problem is the battery runs out fast with my 300mAH battery!. Try using larger batteries to increase usage time but make sure the weight of the device doesn't change much.
Note:
This being my first instructable I am sure there are be mistakes that I have overlooked. Please do comment below if you find any and don't hesitate to ask any doubts. I'll try my best to reply at the earliest.