I have read about people putting their ESPs into a deep power saving sleep which allows batteries to run for many months if not years which is exactly what I am looking for.
Since I am running NodeMCU firmware on my ESP you can initiate deep sleep by running the code
Not that it is microseconds and not milliseconds, so to make the chip sleep for 60 seconds you would have to enter the value 60 000 000. To someone like me who is used to think in timing events in milliseconds this is a rather important difference 🙂
Setting the timeout to 0 makes the chip sleep indefinitly until the chip is reset.
You can read more about it in the NodeMCU documentation at:
Deep sleep interrupt
So now you have your chip fast asleep. How do get that thing to wake up?
Well, there is the timeout alarmbell… BUT… in order to make that work we need to connect GPIO16 to the reset pin… Wait, what?!? GPIO16?
The ESP8266-01 have GPIO00 and GPIO02, but no GPIO16.
As I read up I actually managed to find a blog about someone that hacked the ESP-01 to allow deep sleep, but that involves some fairly funky soldering. The chip itself is not exactly on the larger side, and having to solder a wire from one of the miniscule pins of the main chip to the reset pin seems a bit… interresting…
You can read more about it here:
Another problem is the fact that apparently the GPIO16 is set to high, and when the timeout occurs it is temporarely set to low to reset the chip… the PIR sensor however is set to low unless it detects a movement where it goes high… which is the opposite.
A different way to power
In a thread, which I unfortunatly can not find the link to again I found someone saying that if you only have VCC connected but no CH_PD then the chip is essentially in power saving mode, with networking and everything else turned off… hmm, now this IS interresting.
I hooked the battery up to the ESP and to the PIR sensor… but instead of having the ESP chip connected to the VCC and CH_PD pins at the same time I simply connected the PIR output to the CH_PD pin directly.
I started doing some twisting and turning on the PIR potentiometers that adjust sensitivity and delay (as in how long the power should be on if a detection is noted)… lets just say that it was a royal pain in the ***. Turning the nob 1mm to far in either direction and the timing went haywire. I currently have it set up so that it sends power approximatly 20 seconds when it detects a movement. The chip takes about 4-6 seconds to wake up and connect to the WIFI network.
So far the sensitivity seem to be all over the place. Most of the time it detects movement within 3m, some times in low lighting conditions however it can detect a movement 9-10m away, but not consistently. I have not yet figured out the sensitivity setting.
What I did then was to open up a command console and start pinging the chip IP continuously with this command.
ping 192.168.0.XX /t
Initially all I got was timeouts, then I sent one of my lab rats (aka our oldest kid) down to walk into the room and presto! The pings hit their mark perfectly!
So far I have had this contraption running for a week and so far the batteries are still in the game.
What this opens up is the possiblity to allow the chip to send data to some remote site… OR it allows you to build a simple pinging solution that sends out pings to your ESPs and whenever that ping hits home you know you have a detection and then sends that data to the remote site.
I am currently not sure which of the two solutions to persue. The second solution seems a bit like crossing the stream to get some water… BUT it should be more battery saving than having the chip connect to an external site over the network.
Success, and yet not
So apparently my latest experiment was a success… if you have a room or place where you seldom go to. If it is a room that frequently have people in it, say your kitchen or living room however the PIR would trigger pretty much all the time running your batteries dry…
When I think about it then sure, during evening hours the batteries would be taxed pretty hard, but during night and during day hours when everyone is at work the chip should be in constant low power mode. So the 3-4 days of continuous WIFI connection should be able to be extended to at least a couple of weeks… not enough, but better.
I guess I still a fair amount of walking before I get to the close….