Chat freely about anything...

User avatar
By Mikejstb
#15836 As part of my home health care project I need to keep track of when the patient (me) takes their meds.
So I built a little ESP-12/LiPo battery/charger device which uses a fairly sensitive vibration detector.
I believe the sensor is a little weighted spring in a tube with two contacts.
I set it up to connect gpio-13 to ground and set that up as an interrupt.
When triggered it beeps a little piezo buzzer for 250 ms - like a chirp sound, and publishes a mqtt message.

I tried 5 different vibration switches of varying sensitivity.

It all fits nicely into a little project box which I got from Electrodragon when I ordered a batch of their new ESP-12 breakout boards. They have a half dozen or so different boxes, I got a couple of each and the small one was just the right size.

Here's a picture of inside an out - with a -201 sized breakout board on top so you can see the scale.
My bad measurements size this box out at about 2.5" x 1.5" x .5"

IMG_2199.JPG


I got impatient and moved it before the hot-glue holding the lipo charger completely set.
IMG_2198.JPG


I wrote the code for this one in Lua since I prototyped it before the ESP-Arduino ide was released.
I struggled for several days trying to figure out how to use deep-sleep and have the sensor interrupt trigger a wake up and message but I never got that to work - so I included a batter charger instead. I may go back and try to make the ds-wake up code work.

The final application logs the mqtt message to a MySQL DB, and checks the time of day with the activations. If I miss a med at its proper time my wife and I get an email. Same thing if someone is in the meds when they aren't supposed to be.

It's working pretty well for me. Part of my damage is very bad memory problems, so I appreciate being reminded when it's a med time and I've missed it.
User avatar
By danbicks
#15847 Well Done fella.

Brilliant project I really like the idea. Like the SQL stuff, how are you storing MQTT data to SQL database?

I have started using Sming open framework. MQTT seems to work flawless and using Eclipse IDE is awesome.

Good luck

Dans
User avatar
By Mikejstb
#15854 Thanks.
I use Node Red running on a local Raspberry Pi 2.
To actually put things into the DB there's a MySQL node in node red, you have to format the MySQL string like this:
newMsg3.topic = "INSERT into patientData(movement, meds) VALUES ('Vib-" +words[2] +"'," +1 +");"
that appends the ESP chip ID number into the database entry so I know which sensor the entry came from. The MySQL table has a timestamp so I don't have to manually do that.

It took a while to figure the proper syntax out, but basically the MySQL node can insert or retrieve from the database pretty well.