Mail Notifier - WiFi Edition

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.

General Operation

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.

Truth table and system state:

IN 1 (Switch) IN 2 (ESP) OUT (Regulator) State
HIGH LOW LOW Mail flap closed, ESP is off, idle
LOW LOW HIGH Mail flap opened, ESP is booting up
LOW HIGH HIGH Mail flap opened, ESP is running and has set IO15 HIGH to keep regulator enabled
HIGH HIGH HIGH Mail flap closed, ESP is still running and has set IO15 HIGH to keep regulator enabled

Internet of Things

The notifier makes a web request similar to the previous A9G version. The POST request contains some JSON data, which is processed by a PHP script which then formats and sends a message to a Telegram group chat.

And of course, there is a SHT31-DIS temperature and humidity sensor, this time placed in a much better area.


{
	"key": "aabbccddeeff11223344556677889900abcdef12",
	"millis": 7220,
	"notify": "mail",
	"battery": 3915,
	"lastfail": 0,
	"fw": {
		"version": "1.0.0 211109",
		"build": "Nov 24 2021 23:19:24"
	},
	"counts": {
		"success": 109,
		"wififail": 1,
		"netfail": 0
	},
	"net": {
		"ip": "10.0.0.98",
		"subnet": "255.255.255.0",
		"gateway": "10.0.0.1",
		"dns1": "10.0.0.1",
		"dns2": "(IP unset)",
		"hostname": "ESP-AABB55"
	},
	"wifi": {
		"ssid": "MyWiFi123",
		"bssid": "01:23:45:67:89:AB",
		"channel": 3,
		"mac": "AA:BB:CC:DD:EE:FF",
		"rssi": -69
	},
	"env": {
		"t": 19.06119,
		"h": 62.00809
	}
}

Telegram message

Other Things

The ESP can be placed into a firmware upload mode by connecting RX to ground and then triggering the reed switch. In this mode the ESP will stay powered on while running a webserver where new firmware can be uploaded to.

So far after 7 months and 110 mail notifications the battery voltage has only dropped from 4.2V down to 3.9V, indicating that the device should last for at least another year or two and a further 200 notifications before needing to be recharged.

You can find all of the designs, firmware and things on my GitHub


Loading comments...
  1. « Prev
  2. Next »

Leave a Reply

Sorry, new comments have been disabled since I rarely have time to moderate and reply these days :(