No, Pete’s not regressing to a bygone age.I happen to have a bunch of LOLIN Mini D1 ESP8266 boards lying around, abandoned when I discovered the all-singing ESP32 – and I HATE to see waste – so I’ve had an idea forming for the LoRa Letterbox Alert for the last couple of days – please see part 1 before you continue – I had NO IDEA it would go this far….Firstly , after reducing the software-serial-driven comms for the Reyax LoRa radio unit from default 115k baud to a more sensible 9600 baud (I’m only sending simple text commands back and forth and only as I was being cautious with the software UART on the ESP8266) – see code below – and testing it to death, today I took my fully functioning but unfeasibly power hungry original NodeMCU ESP8266 + LoRa module (REMOTE END) apart and made a Lolin D1 Mini version instead.
Why this board? Well, one thing you’ll hear out there is “you need a board with no regulators as they take power regardless” – no such problems here when connecting to 3v3 and GND (NOT USB) once programmed up.Small, neat, cheap (AliExpress for example) – and remembering again that WiFi on the ESP8266 (remote unit only) is in this case is turned off, no problems with the 2 antenna being close together.The design requires a connection (micoswitch?) from GPIO16 to RST to wake the unit up from sleep.
That’s the hardware sorted – and bearing in mind that the ESP8266 can be put to sleep to save power – and with a test button in the base unit WebUI to tell the remote to sleep, the idea being that the instruction hits the remote ESP8266 which puts the LoRa module to sleep – then itself – and they all sleep happily ever after until someone opens the letter box flap.When that happens, the ESP8266 wakes up, sends an AT message to the LoRa module which auto-wakes it up – and off we go.That’s the idea, let’s see how that works in practice and whether the power-saving makes this incredibly cheap and simple idea work.
I’m not now using the Arduino IDE for development, the remote unit can be programmed in ESPHOME – albeit by serial as we’ve turned the WiFi OFF in the remote… But before I start – we have set the Lora unit to work at 9600 baud (non-volatile).This used a simple Arduino sketch ChatGPT made for me – there are other ways but this is what we used.Why a bunch of characters in the code below? Because the LoRa board is picky about exact CRLF.
#include <SoftwareSerial.h> SoftwareSerial loraSerial(D6, D7); // RX, TX void setup() { Serial.begin(115200); // RYLR998 is initially at 115200 loraSerial.begin(115200); delay(1000); // AT+IPR=9600\r\n const uint8_t command[] = { 0x41, 0x54, 0x2B, 0x49, 0x50, 0x52, 0x3D, 0x39, 0x36, 0x30, 0x30, 0x0D, 0x0A }; loraSerial.write(command, sizeof(command)); delay(1000); Serial.println("AT+IPR=9600 sent"); } void loop() { } So reading this on conjunction with part 1 for data pins..with my base unit set up with a WebUI for testing, I can turn the builtin LED on the D1 on and off remotely, see the status of D5 on the remote unit (my ultimate microswitch on the letterbox) and put the remote D1 and it’s LoRa board to sleep.Right now they wake up after 30 seconds but in the end they’ll only wake up when someone opens the letterbox.
I referred earlier to the obvious – the board combo as to sit OUTSIDE the letterbox as the latter is made of metal… so I was really looking for a setup with a small battery… and a plastic enclosure fastened to the side.Ok, down to business – as of part 1, this all fell apart (we’d not worked on sleep at that point) because combined ESP8266/Lora power was 32mA – WAY too high for a battery gadget that has to stay on constantly.That’s when I went off on a tangent to try the D1 Mini.
“Wisdom” has it that the ESP8266 isn’t that good at low power but what I discovererd was that the LoRa module was just as bad – 17mA each for a total of 34mA.Why the LOLIN D1 Mini? I just happen to have some and as it happens I could not have made a better choice.Total curent with both (remote) boards awake 34mA.
Totasl current with both boards asleep – a staggering 0.06mA.Now, I don’t really want 3v as my starting point as down to 2.8v could be troublesome..but a pair of non-rechargeable Lithium 1.5v batteries should start a lot neared to 3.3 or 3.4v and a CR2477 round Lithium battery will definitely start nearer 3.2v..
I have the base end on my messy desk talking to it’s ESPHOME WebUI over WiFi – and the remote board combo hanging off my (curently 3V) adjustable power supply – with an accurate 6-digit meter in-between the D1 (I’m using the D1 3v3 and gnd lines – not the USB) but bear in mind, first tests put the two units 160 BIG steps apart – all detailed in part 1.In essense – THIS IS GOING TO WORK – do the math – we could be looking at well over a year battery life- Wheee..
Read More