Share My Creation MQTT client on service working a few seconds by minute to preserve battery

at start i wanted to monitor 2 SOS buttons for seniors. My first idea was to use a rfbridge sonoff programmed with tasmota and a MQTT on mobile, but a MQTT client working full time in a mobile take more than 30% of battery : it is not usable.

second idea was to use a gateway between rfbridge and my mobile. in this case configuration is this one:

SOS_bridge-2.jpg


the gateway is a MQTT client on ESP8266 built with B4R and it is interface interrogated by this application. (code is in B4R side)
MQTT broker is cloudMQTT.com

on Android side, i built a MQTT client dedicted at SOS buttons monitoring
- MQTT client is a service running 15sec and sleeping 1mn (or more) => in this configuration it take less than 3% of battery
- we have a sound alarm 4sec each minute until alarm is removed
- we can choose one alarm between 8 available
- we have a permanent log with the 20 last alarm status
- we have an activity dedicated at configuration with a password before access
- we can make provisioning for MQTT, subscription, SOS keys and notification sound
- we have a big button moving to red when we have alarm
- we have a button to erase alarm
- we have a button to erase log file
- we have a notification without sound each time service is running
- we have a notification with sound each time we check alarms and if we have alarm (every minutes until reset of alarm)
- period of monitoring can be from 30sec to 5mn, with corresponding impact on battery
- max delay between a SOS button pressed and alarm on mobile is with basic period 1,15mn max

i hope this development done by a beginner on B4A can help others beginners.
 

Attachments

  • SOS Alert.zip
    150.9 KB · Views: 156

Sandman

Well-Known Member
Licensed User
Nice work.

I realize that it's a bad thing to have this running all the time (because of battery issues), but I'm curious: If you actually did have it running all the time, how much time would it typically take between a press on the SOS button and alarm on mobile?
 

candide

Active Member
Licensed User
from SOS button press, message in esp in real time
after, If basic period for request of alarm in application is 1mn, alarm is show in mobile less of 1mn after button press.. it can a few second later, but max it will be never more than 1mn)
and if mobile have no network during some times, alarm will be seen on mobile 1mn max after network back

in my case, 1mn of delay is not a problem
 
Top