There are no weird, specialized components nor esoteric sleep mode tricks behind the long battery life of [Zak]’s WiFi mail slot watcher. Just some sensible design and clever focus on the device’s purpose: to send an HTTP request whenever it detects that the front door’s mail slot has been opened. The HTTP request is what kicks off useful notifications, but it’s the hardware design that’s really worth a peek.
The watcher’s main components are a ESP-M2 WiFi module, a reed switch, and a single lithium cell. Here’s how it works at a high level: when the mail slot is opened (detected by the reed switch), the ESP module is powered up just long enough to connect to the local WiFi network and send a single HTTP request, after which it shuts back down. The whole process takes between four and ten seconds.
As mentioned, the power control isn’t managed by any unusual components; it comes down to a NAND gate with a single inverted input, and a MIC5504 3.3 V regulator responsible for feeding the ESP board. The logic gate controls whether the voltage regulator is enabled or disabled, and therefore whether the microcontroller receives any power at all. Most of the time the regulator is disabled, but when the reed switch triggers, its input to the NAND gate is pulled low and the regulator is turned on, booting up the ESP board.
In order to stay on, the first thing the ESP board does is use a GPIO pin to drive the inverted input of the NAND gate high in order to keep the regulator enabled, and it has a window of about half a second to do this. Once the HTTP request is sent (and the battery voltage sensed), the ESP board pulls that pin low, disabling the regulator and turning itself off until the reed switch once again begins the process.
After seven months of use, the battery has dropped from 4.2 V to 3.9 V, so there’s plenty of life left. The project’s GitHub repository has the necessary code if you’d like to apply some of its ideas to your own projects. Alternately, you may wish to consider supercapacitors and solar in lieu of batteries. Even if ultra-level power savings isn’t your bag, when WiFi and networking is involved, there are software-level opportunities to be more efficient. Even a judicious 1 ms delay can save a surprising amount of power in the right circumstances.
Hmmm I created something similar using a Z-Wave magnetic open/close sensor tied into my HA system which told Alexa to announce “You’ve got mail”
When does it announce that? ’round here the mailman comes at all hours, in the middle of the night or early mornings, which would be a bit annoying.
Where do you live that the mailman is coming at night? That sounds terrible.
Morning paper won’t be morning paper if it’s delivered in the afternoon.
Here, they call that “production delay”
Always between 2:00 and 4:00 pm. But I could have easily added condition to delay or suspend announcement if I had weird mail service during sleep. But the USPS transitioned me to a centralized mail kiosk out of Z-Wave range. I now subscribe to the USPS service that sends you images of mail scheduled for delivery. I only pick up the mail if there’s something other than junk.
Surely rather than a http request, this should send a http POST?
a POST *request* is a HTTP request. You’re mixing up terminology
Does it matter if it is a POST or GET? How the other side handles the http request is important. Could be a http TUNNEL or a snmp PING as long as there is a notification on my smart(watch/phone) to go check the mailbox, the contact protocol is rather unimportant. Could be a smtp message :D
I hope your smartwatch send you a notification that the joke went over your head.
That is a HTTP request.
POST / postman, it’s a joke.
It does send a HTTP POST request. The previous guy just doesn’t know what a HTTP request is.
The Esp-M2 module uses an ESP8285 on-board. The Espressif ESP8285 is just like the ubiquitous ESP8266 but with 1 MB built-in Flash instead of (typically) 4 MB on the ESP8266.[1][2]
1. https://www.cnx-software.com/2016/06/22/espressif-esp8285-is-just-like-esp8266-but-with-1mb-built-in-flash-and-designed-for-wearables/
2. https://en.wikipedia.org/wiki/ESP8266
Needs a solar panel or a motor on the mail flap hinge to generate some juice and charge the battery.
I like the idea of getting juice out of the mail flap hinge movement.
not as smart as I expected. I thought it would use mechanical switch to keep power circuit open and when door is opened – feed just right amount of electricity to send the message. Given time needed to complete the request – charge some sort of capacitor?
On this kind of setup, the self discharge of the battery counts for more energy than the system itself.
Correct.
Fortunately LiIon batteries are extremely good at this and have nearly no self dicharge
I do sort of appreciate the simplicity of this design, but it is not optimized very much for low power. But compensating with a very big battery and charging it every one or two years seems acceptable.
The 74LVC1G98 has a maximum quiescent current of 4uA (0.1uA typ) and I’m a bit confused what that delta Icc “Additional supply current” with upto 500uA is ??? The MIC5501 is quite low power (50nA typ. 1uA max) but it’s still a second IC sucking current. (Or better sipping current). I’ve come to really appreciate the power down circuit of the ubiquitous “transistor tester”. In the off state the only current is leakage through a single PNP transistors (BJT’s generally have lower leakage then Fet’s) (Also note that leakage doubles about every ten degrees celcius.
And of course using WiFi and “low power” do not fit together very well. Needing 4 to 8 seconds just to start up the radio and send a message is atrocious, and WiFi sucks a lot of power in that time. There are plenty of other radio’s that can bring this back to 10ms or so, and use less power in that time too. So that is an improvement of over 2 orders of magnitude.
Also, when you get the energy needed for the radio down, you can further simplify the power circuit. A reed switch that charges a capacitor when closed could then store enough energy to send some message through.
This brings back some memories about Jeelabs / Jeenode. He blogged a lot about low power design and had sensor nodes with a radio that ran multiple years from a single coincll.
As an alternative, you can also use one of those energy harvesting light switches. A year ago BigClive tore one down, his video has the title: “Inside a kinetic self-powering remote switch”
I think it’s a stretch to say that WiFi and low power don’t fit together very well. I’ve had an ESP8266 sending one message a day and deep sleeping the rest of the time running for 1044 days off two AAs. No mechanical interlocks or other weirdness at all. Wakes up, takes a distance measurement with a TOF sensor, sends it to the cloud, goes to sleep, and repeats it all in a day. WiFi works great for my purposes.
This sounds useful – have you shared the project online?
I think it’s a bit of a stretch to say WiFi and low power do not fit together very well. I have an ESP8266 sensor that wakes once a day, takes a time of flight measurement, reports it to the cloud via WiFi and goes back into deep (software) sleep, and it’s been running 1044 days on the same 2 AA batteries. It looks like it will make at least 3 years at this rate. That’s about as good as I get on any AA-powered device.
What radios would you recommend looking into?
Been looking for days to find a good LDO with very low quiescent current and availability and finally found this article. A blessing for me, thanks alot!
The best LDO is no voltage regulator at all. Most 3V stuff can be directly powered by a Li primary cell or two alkaline cells.
Should use ESPNow instead of TCP and time up will be well under 100ms, you would just need a second device to act as the base/receiver.
You can save even more power by connecting to the router mac address and channel manually, drastically reducing the time the wifi is on. My estimates for an ESP8266 wifi switch being used once a day on 2 AA batteries is over five years. If you want low power ESP, you gotta have this.
This is the fifth page of his power savings posts:
https://www.bakke.online/index.php/2017/06/24/esp8266-wifi-power-reduction-avoiding-network-scan/
I like that this allows for the post inevitably leaving the flap open with letters/flats jammed halfway in the slot.
I did go a similar route, albeit not using a voltage regulator, for a mailbox sensor attached to home assistant.
https://www.espthings.io/index.php/2022/11/05/et-sw01-a-very-low-consumption-mailbox-switch/
We expect at least 2.5 years of running time out of a CR123a non rechargeable battery. And that is low power enough 🙂. Reason for not using a rechargeable cell is the need for a regulator and the relative high self discharge of rechargeable cells compared to primary, non-rechargeable, cells.
Hey everyone
I am currently thinking about building the wifi version of this and was wondering if someone has one of the circuit boards available or can tell me where I could buy the components and the board
I am currently thinking of building myself one of these modules and was wondering if someone has a supplier for the circuit boards or could tell me where to find something like that?