Mobile Walking app for health monitoring PART 2
The first app
wasn’t comfortable to use. While walking your mind wanders off and it is difficult to remember to
press the lap button each time. So I had to find a different solution. I wanted to have something
that would automatically add a lap when you passed a certain point.
For this I used a microcontroller unit, a very small computer specialized in handling input and output
sensors. The board I used is a
D1 mini
with an ESP8266 chip that has WiFi and Bluetooth. I combined the D1 with an infrared motion
detector (PIR) and a small beeper. The whole setup cost less than $5.
This works wonderfully well. The first time I pass the motion sensor it will start
the timer and every next pass it will add a lap time and send that to the node js app. I can
start and stop with the web app on my phone.
I wrote a small program in C that would measure the time between the detected motions and send
it to a node js app running on my PC using websockets. The node js app on my PC also acts as a
web server and is serving a single page optimized for mobile devices. The web page on the mobile
device can signal the node js app to start and stop and receives the lap times and calculated
averages in different formats.
The web page is written using pure javascript, no frameworks or libraries are used except for a websockets
package. The node js app sits between the microcontroller unit and the mobile device. It receives
lap times and calculates averages and different display formats and sends it to the mobile device
also using websockets. At the start it requests the best average time via a
AWS Lambda
and a
Dynamodb
database. It sends the best average to the phone web app for display. When a stop signal is
received it checks if the best average has improved. If so it will send it to Dynamodb. It will
also send the laps to Dynamodb.
In a later project I will create another web app that will show the results of my daily walks in
a nice dashboard like style. Maybe using
Grafana for this. Lastly I will move everything from the node js app to the microcontroller, eliminating
the need for the node js app in the middle. The ESP8266 can definitely do this. The reason why I
didn’t do this from the start is that I wanted a fast result and I’m not so fast with C or with Micro
Python.
Typescript, Javascript, Websockets, ESP8266, C++, AWS CDK, DynamoDB, Lambda, Serverless