Remote Battery Monitor 12V LORA

Hi Everyone,
I have asked a few different questions in multiple threads while developing this project and I’d just like to say thanks to everyone who commented. Many people wanted to know how the project came out in the end. I’m glad to say, I finally got it finished and I’m happy with the result.
For those who may want to create something like this themselves I’m no expert and there are probably much better / simpler ways of doing this but I had a lot of fun and learnt heaps!

Let me know what you think and definitely Comment here if you try and make one of these yourself. Maybe I’ll make a YouTube video of the installation once that’s done.

Contents

  • Requirements
  • Goal
  • Hardware
  • Problems Encountered
  • Build
  • Software

Requirements
A local Lions Club member asked me if there was a way he could remotely monitor the igniter battery on a gas BBQ in a public park that the club maintains. The problem he is trying to monitor is people get impatient when lighting the BBQ and jam the start button in and it just clicks away until the 12V battery is flat.

The 12v battery can last for months or it can get jammed the day after the battery has been charged. As it’s a bit of a walk from the carpark and the battery is locked away in a steel cupboard, it’s not that convenient to check every day or so. It’s also a free BBQ for anyone to use which I think is pretty cool and it is checked and maintained by volunteers.

The existing 12v battery is around 10Ah and there is no other power available and no way to connect up a solar panel as the BBQ is an island surrounded by concrete with a free standing roof. So I need to power the device from the same 12V battery and make the device use as little power as possible so it doesn’t add to the problem and flatten the battery even quicker.

Goal
Measure the battery voltage remotely, say from the Pub ~300m away :slight_smile:

NOTE:
This project uses two LoRa client devices to communicate peer to peer. There is no LoRa router device and there is no Internet connection required. The devices can communicate over a very long distance, reportedly 10+ km with line of sight. With obstacles like brick walls, hills and trees this distance is greatly reduced.

Hardware

BBQ Device
Custom Circuit Board (See below for how I created this PCB)
This board is not required but it’s way neater and more robust.

Raspberry Pi Pico (non WIFI)
I used a non WIFI board as it requires less power.

Lora Wan Pico Module
Comes with a Battery and Antenna. The battery is not used on the BBQ Device.

Nano Power Timer Hat
I have the DIP switches set to power off the device for 20 Minutes. This unit powers up the pico after the specified time, check the clock and either waits for a request or goes back to sleep.

Real Time Clock
The Pico’s internal clock is set from this device every time it starts up.
To set initially set the RTC clock from the Pico clock or after replacing the battery, connect to the device with Thonny via USB. The default is behaviour for Thonny to set the Pico clock from your PC’s clock.
Then to set the RTC clock from the Pico Clock, run the following command located in ds321.py.
setDS3231Time()

Power Supply 12V → 3.3V
This needs to be set to output the correct voltage using a multi metre before use.

Relay Module
(Reliably actuated by 3V)
Here is something I found on eBay.
“10A 30V DC SRD-03VDC-SL-C”

Assorted other Stuff
3x 3.3 K ohm Resistor
1x 22 K ohm Resistor
1x Screw Block Connector
4x 20 pin male - female connectors
4x 1 pin male - male connectors (power supply)
Standoffs and miscellaneous stuff

The Pico modules are mounted onto the 20 pin sockets to allow for easy installation.
All Pico modules are stacked except for the RTC module due to pin conflicts.

Mobile Device

Pico Omni Bus Circuit Board
GPIO pins 10 and 11 are removed from the Omni Bus board on Deck 2 under the 4 Digit LED display. The Male end of Male-Female Jumper wires are inserted into the Digital display where to two pins are removed from the Omni Bus. The Female end of these jumpers is connected GPIO 6 and 7 on the Lora Module (for convenience). See circuit diagram and Mobile Device picture below.

Lora Wan Pico Module
Same as above

Raspberry Pi Pico
Same as above. I used the WIFI version but it doesn’t need it.

4 digit decimal display

Other Stuff
1 Momentary push button switch
Jumper wires etc.

Problems Encountered
On the Mobile Device the 4 digit LED display has pin conflicts with the Lora Wan module so I had to jump those pins to different pins on the Pico and adjust the program accordingly.
The following photos show where I have removed two pins on the Omni Bus board and then connected them with jumper wires. The circuit diagram shows the ditails.


On the BBQ Device, the Real Time Clock and the Lora Module have conflicting pins. Taking the RTC out of the Pico stack and mapping the pins on the PCB to different pins on the Pico worked around this problem. All the other required connections are also made on the PCB, however not all 40 pins are connected, only the required ones.
The circuit diagrams show the details.

Minimising the power usage was difficult. In the end I came up with a compromise.
The device is programmatically powered up from 8:00am to 8:00pm from 10 minutes before the hour to 10 minutes after the hour. The achieve this at the end of each cycle the Nano Power Hat is used to power down the device for 20 minutes. When it powers the device up the again the current time is assessed to decide if it should simply turn off again or continue execution. While running and waiting for something to happen, the device is put into light sleep mode and it wakes up from this mode when an incoming message is received on the Lora Module.
One possible problem is, depending on where the device is located it might get woken up a lot during this 20 minute window by other Lora traffic from unrelated devices on the same frequency. Probably not going to be a big deal where this is going but you never know.

I noticed there would also be a continuous trickle of power used by the voltage divider circuit. The relay disconnects the voltage divider circuit when no readings are being taken. (I know this was over kill)

Build

BBQ Device
While I was programming and prototyping the circuit for the BBQ device, I had the components on a PiicoDev LiPo Expansion Board and additional stuff soldered on a proto typing board.

Next, I wanted to come up with an easy to read circuit diagram so others could understand how it works. I came across an application called EasyEDA (not sponsored). They have a free online version of this software at EasyEda.com. It took a bit of getting used to but the results were great.

BBQ-CircuitDiagram.pdf (117.0 KB)
Mobile-CircuitDiagram.pdf (73.8 KB)

By luck more than good management the tool I chose to create the circuit diagram also allows you to fairly easily convert the diagram directly into a PCB. Of course you need to specify all the dimensions but it can automatically hook up all the traces and will let you know if you miss any connections.

If you wish to create your own circuit board, I believe all you need is this Gerber format file which I exported from my EasyEDA project. I believe this is a widely used format for circuit board design.

Gerber_PCB1_2024-11-08.zip (27.7 KB)

If someone really wants it, I’ll figure out how to export the entire project in EasyEDA.

They have some introductory offers which makes producing boards at least initially, really cheap. Five boards delivered from China is less that what we’d pay for a cardboard box at the post office here in AU. It looks a whole lot neater and is more physically robust once everything is mounted on the PCB.

The 3D view of the board before it’s created is also pretty cool. You can spin it around looking for potential problems with the design.

It took me three goes to the the PCB design correct. First go I had some incorrect hole spacing and the parts wouldn’t fit on the board so I couldn’t test anything. Second go I discovered I had connected a trace to the wrong pin by mixing up the physical pin number with the GPIO pin number. Third go was a charm :slight_smile:

The only problem when using the budget postage option is delivery takes about 10 working days so mistakes can draw out the process. The estimated delivery time was actually fairly accurate each time.

Mobile Device

This device runs off the tiny battery that comes with the Lora module. The battery is hidden in the gap between the Omni Bus Board and the Lora Module. The device is programmed to put itself to sleep after displaying a reading if it has nothing else to do. The device is woken up by pressing the button and and after a few seconds the LED on the Pico flashes when it has finished waking up. Once awake the LED will continue to flash for 10 seconds to indicate it’s ready to send the request. Pressing the button again, will send the request to the BBQ Device for a reading to be carried out and returned. The Lora programming is fairly simple and the library does all the hard work.

When the button is pressed while the LED is flashing it broadcasts the word “Volts” across the selected frequency. The Remote BBQ device hears this signal, closes the relay to connect the voltage dividing resistors and gets a voltage reading from the battery. This reading is then transmitted back to the mobile hand held device for display. The mobile device displays this value for a few seconds then goes back to sleep after some more LED flashing in case you want to get a second opinion. :slight_smile:

The Software
I was able to find reasonable examples for programming each module so I simply used the example as a base and went from there. Here is a quick description of each of the files contained in the zip archive. I try to program using modular code so I can simply include the generic .py files in other projects with minimal reworking.

The files go in the root folder of each pico.
The files are the same on each device except for main.py
Main-Mobile-Ping is on the hand held device and renamed to main.py
Main-BBQ-Pong is on the remote BBQ device and is renamed to main.py

At the time of testing I was using…
MicroPython v1.23.0 on 2024-06-02; Raspberry Pi Pico with RP2040

NOTE:
To avoid loosing your connection to Thonny set LOWPOWERMODE to False until testing is complete and you get everything working. Then test Low Power Mode after that. If you forget to do this power off the device and power it back on again and click the Thonny stop button the first second or two after connecting the power. This seem to be to with the way lightsleep works as it interrupts the usb connection.

Main-BBQ-Pong.py (main.py)
Only required on the BBQ Device
This is the main program that launches when the BBQ device is powered on. It is launched again every time the Nano Power Hat restarts the device. I have tried to comment the code so that others can understand whats going on. The comments are normally aimed at me as other people usually don’t read my code :slight_smile:

Main-Mobile-Ping.ph (main.py)
Only required on the Mobile Device
This is the main program that launches when the mobile hand held device is powered on.
It runs continuously and uses very little power when the device is asleep. If using the battery that comes with the Lora module you can expect several days of continuous options. The Lora module does have an on off switch so it should run for months between recharges.

NOTE:
The remainder of the files are identical on both devices.

constants.py
Most of the user modifiable variables are stored in this file

battery.py
Function to return the battery in volts or as a percentage.

dateTime.py
Lots of date and time related functions.

debug.py
My standard debugging routine. A debug level is set in constants.py from 0 to 3 where 0 is off and 3 is annoying. Rather than simply inserting print statements in my code I instead include calls to my debug routine that can optionally print to the console, to a file on the device or both. Once the code is working correctly the debug level can be disabled by setting the level to 0 and all the debug output code is skipped but it’s still there if something unexpected happens down the track. I think level 0 still prints failure exceptions and if you really want to disable those as well set debug level to -1. The default output file name is debugLog.csv.

ds3231.py
Real Time Clock Library

Lora Module Libraries
_sx126x.py
sx126x.py
sx1262.py

diskFree.py
Returns the amount of free space in the Pico filesystem.

lowpower.py
Used to wake up the mobile device from light sleep when a button is pressed.
It’s not used by the bbq device but it won’t hurt if its on there.

Auto Created Files
These files are created by the system if they don’t already exists.

debuglog.csv
Default output file for the debug log
Watch out it doesn’t get to big and fill the little file system. Disable debugging when not in use.
You can also set debugging to start a new file each time the system starts.

debugCounter.txt
Counter for sequential number shown in the debug log.
This allows the numbers to be continuous after a reboot of the system which is fairly often.

Here is the zip file
Release Version 1.7.zip (29.2 KB)

3 Likes

Hi David.
Congratulations. You have put a lot of work into this over the last months. Looks like a good result.
And yes. A custom PC board does tidy things up somewhat and you have got quite a professional look to this.
Cheers and well done Bob

1 Like

Hi Bob,
Thanks for the nice reply.
You were also right about only super humans can get a PCB 100% correct the first go.
I gave it a really good shot though :slight_smile:
I got it in three.
David

Thanks. How long did it take to finish this project?

1 Like

Hi Lia,
Well that’s difficult to say. If you are asking how long from start to finish it probably took about six months. But I didn’t work on it all the time. Things like waiting for the custom PCB to arrive certainly tested my patience. As mentioned above each revision of the board added another 2 weeks to the project and I needed three iterations.
The programming and testing also took a while but I did a lot of this on my laptop while I ignored crap on the TV :cowboy_hat_face:.
Apart from the Lions Club guy looking forward to getting this device the elapsed time doesn’t really matter as like so many things in life it’s a journey not a destination. I know more now than I did when I started.
The good part is others can take now take my work and use it as is or build on it.
David

Hi David

Doctor David. Congratulations.
“Patience” is what you probably typed. Probably an unnoticed result of the cursed auto complete system here. Can be a damn nuisance at times and if not corrected can often change the whole meaning of a sentence. Microsoft were pretty good at it but they used to (don’t know about now as it is years since I used MS Office) give the user the option to disable it.
Cheers Bob

1 Like

Hi Bob, I fixed that one Thanks.
I read and reread my initial message but I’m sure there is mistakes all over it. I figure it’s better to get it out there rather than worry to much about grammatical detail :cowboy_hat_face:
David

1 Like

Hi David
For interest I just tried your sentence “certainly tested my” and when I got to “patie” it completed the word to “patients” as I thought it must have as historically you don’t make too many (any???) errors of this kind. I find you have to read a post a couple of times then edit the auto complete errors.

A favourite one years ago was to add the extra “o” to the word “to”. Stands out like a neon light and mostly looks ridiculous until edited.
Cheers and we won’t worry too much about it. Bob

1 Like

Hey @David191372,

Looking very clean and professional!!!

Very keen to see the video you share of this project once its done :slight_smile:

1 Like