“After around 18 months of using my previous mail notifier the mobile network provider that I was using, ASDA, decided to move from EE’s network to Vodafone’s network. Unfortunately, the A9G GPRS module doesn’t like the Vodafone network very much and I was unable to find another pay-as-you-go provider using EE’s network that didn’t have silly terms like requiring a £10 top-up every few months to keep the SIM active, even if it still has plenty of credit.
Luckily, I had moved into a new apartment where the letter box is on the front door rather than in a lobby area. That means it’s now in range of my WiFi network! This mail notifier has a much simpler design than the previous notifier; it does away with the ATtiny402, battery charging and GPS stuff and replaces the A9G module with an ESP-M2 WiFi module housing an ESP8285, similar to the ESP8266 but with embedded flash. It still uses the same lithium battery and reed switch though.
The ESPs only job is to send a HTTP web request whenever mail arrives, so to maximize battery life the ESP is only powered on when the reed switch is triggered and then powered off once the web request has completed, which usually takes 4 - 10 seconds in total without any speed-up tricks. The switch input (JP2) is connected to U4, a 74LVC1G98 logic gate configured as a NAND gate with an inverted input. The switch input is normally pulled HIGH through R1, producing a LOW level at the gate output to disable the 3.3V regulator.
When the switch is triggered the capacitor, C3, is discharged and the gate input becomes LOW, which then drives the output HIGH and turns on the regulator for the ESP. The ESP must then boot up and drive the second input of the logic gate HIGH from IO15 before C3 charges back up through R1. This then keeps the gate output HIGH until the web request has completed, at which point the ESP can drive IO15 LOW, turning off the regulator and itself until the next switch trigger.
C3 ensures than the ESP has time to boot and drive the second input of the gate HIGH from IO15, which takes around 500ms, before the letter box flap closes and causes the reed switch to open again.
The logic gate also serves as a way of turning on and off the voltage divider R8 and R9 for measuring the battery voltage, otherwise the divider would be wasting power when the ESP is off resulting in a much shorter battery life.”