Smart Gas Meter - Battery Powered - DeepSleep

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
wiredcharlie
Normal user
Posts: 9
Joined: 28 Sep 2020, 13:58

Smart Gas Meter - Battery Powered - DeepSleep

#1 Post by wiredcharlie » 18 Oct 2020, 13:03

In this project I used a Hall Effect sensor to detect the rotation of a magnet on my gas meter.

Screen Shot 2020-10-18 at 11.35.41.png
Screen Shot 2020-10-18 at 11.35.41.png (68.17 KiB) Viewed 161 times
By using DeepSleep and connecting the Hall Effect Sensor to the Reset pin I was able to wake the ESP at each pulse.

Code: Select all

on System#Wake do
  If [Variable#DSAllowed]=0
    TimerSet,1,30
    GPIO,2,0
  else
    TaskValueSet,1,2,1
  endif
  
 TaskValueSet,1,1,[Variable#Total]+1
endon

on Rules#Timer=1 do
 GPIO,2,1
 TaskValueSet,1,2,1
endon

On WiFi#Connected do
    SendToHTTP,xxxxxxx.co.uk,80,/gas/xxxxx.asp?[Variable#Total]
      if [Variable#DSAllowed]>0 AND [Variable#ManDSBlock]=0
         Pulse,2,0,10
         DeepSleep,0
      endif
endon
On initial power up there is 30s before DeepSleep - you can access the web interface. Obviously this is messed up if the hall sensor is triggered and the ESP is reset. ManDSBlock can also block DeepSleep for access to the web interface - http://192.168.1.62/control?cmd=taskvalueset,1,3,1

In order to catch the device when it is momentarily awake:

Code: Select all

#!/bin/bash
c=0
while [ $c -ne 1 ]; do
        ping -c 1 -i 0.1 -W 0.1 192.168.1.62
        if [ $? -eq  0 ]; then
                open http://192.168.1.62/control?cmd=taskvalueset,1,3,1
              
                c=1;
        fi
done
Allow DeepSleep again - http://192.168.1.62/control?cmd=taskvalueset,1,3,0

3144 Hall sensor is connected to 3.3v / Reset /GND and uses 2ma continuously. Power supply is 3 x Alkaline D cells.
Attachments
Screen Shot 2020-10-18 at 11.45.02.png
Screen Shot 2020-10-18 at 11.45.02.png (56.93 KiB) Viewed 161 times

TD-er
Core team member
Posts: 3390
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Smart Gas Meter - Battery Powered - DeepSleep

#2 Post by TD-er » 18 Oct 2020, 20:56

You can also use the internal pull-up resistors of the GPIO pins and set them from the pin bootstates tab as that's being loaded even before the ESP enters the loop.
So then the pin to block the reset (using a logic port I assume?) can be set high.
N.B. not all pins are usable for this, as some may toggle at boot.

Or do you use something outside the ESP to prevent the RST pin to be triggered and only by setting a pin high or low to allow a reset again?

wiredcharlie
Normal user
Posts: 9
Joined: 28 Sep 2020, 13:58

Re: Smart Gas Meter - Battery Powered - DeepSleep

#3 Post by wiredcharlie » 19 Oct 2020, 12:51

You can also use the internal pull-up resistors of the GPIO pins and set them from the pin bootstates tab as that's being loaded even before the ESP enters the loop.
So then the pin to block the reset (using a logic port I assume?) can be set high.
N.B. not all pins are usable for this, as some may toggle at boot.
I hadn't thought of that!
Or do you use something outside the ESP to prevent the RST pin to be triggered and only by setting a pin high or low to allow a reset again?
No. I just turn the central heating off!

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests