Wireless tank monitoring system using meshtatstic

Hi all,
This is my first real world project after watching the 4hr pico course and the meshtastic course, want to say how good those videos are and well presented!
I am looking for some human advice and guidance as I need some time away from chatGPT due to resorting to typing insults and profanities to a computer I started questioning my sanity! My sanity yes, that has been tested over the last little bit trying to get this project going…

To frame it all..

I live offgrid, and run a marketgarden on the property, I would like to start a local internet of things on the property and farm to help make my life easier and the farm more automated and profitable, and also learn electronics/coding along the way. I settled on the meshtastic format after watching the course as being able to ping from node to node is great to extend range. I will start basic and build on the system as i learn more and get better. The first project which I have started is a wireless tank monitering system.

The system-

3 nodes in total using 2x pico’s per node, 1 with SX1262 LoRa Node hat and the other for sensors etc.. Tank node sends battery voltage, and level of tank as a % to the OLED node to monitor and sound warnings and alerts and be the brains of the system until I build a more powerful interface with a raspberry pi and touchscreen. The 3rd node monitors and controls a solinoid valve on/off relative to the tanks state.

progress so far..

TANK NODE-
Is assembled on a breadboard with a voltage divider into adc26 for Node Battery sensing using 2x 10k resistors, a JSN-SRO4T ultrasonic sensor for water level sensing, meshtastic node hooked up via UART and both powered by a 1100mAH LiPo battery charged by a waveshare solar module D with solar panel.
I have it set up on a private meshtastic channel. I have sent data to the channel but its inconsistant and glitchy, the JSN-SRO4T especially, throwing full readings every 2nd or 3rd reading, pretty sure due to my code but I think its all wired right, it also has a small oled for debugging

=== UART SETUP ===

uart = UART(1, baudrate=115200, tx=Pin(8), rx=Pin(9)) # TX=GP8, RX=GP9

=== OLED SETUP ===

display = create_PiicoDev_SSD1306() # I2C0, SDA=GP4, SCL=GP5

=== JSN-SR04T Sensor Pins ===

trigger_pin = Pin(2, Pin.OUT)
echo_pin = Pin(3, Pin.IN)

=== Battery Voltage Setup ===

adc = ADC(26) # GP26 (ADC0)
VOLTAGE_DIVIDER_RATIO = 2

OLED NODE-
Is assembled on a breadboard with a voltage divider into adc26 for Node Battery sensing using 2x 10k resistors, a 2.42’’ Large SSD1309 OLED screen for monitoring 6 lines TANK%, VALVESTATE, TANKBAT, OLEDBAT, VALVEBAT, ALARMSTATES
it also has a DFrobot Digital Buzzer Module and a push button to silence alarms. it also uses the same Waveshare solar module D and 1100mMA battery for powering both picos. I have had it recieving data via the meshtastic network and the buzzer and button have worked. I just need a good code to put it alltogether which is beyond my current capacity and chatGPTs again I have stability and reliablity issues when i have had some of it working, no doubt through my code I am sure.

UART SET UP

uart = UART(1, baudrate=115200, tx=Pin(8), rx=Pin(9))

— Buzzer + Button Setup —

buzzer = Pin(15, Pin.OUT)
button = Pin(14, Pin.IN, Pin.PULL_UP)

— OLED Setup —

WIDTH = 128
HEIGHT = 64

I2C_SCL = 5 # GP5
I2C_SDA = 4 # GP4

i2c = SoftI2C(scl=Pin(I2C_SCL), sda=Pin(I2C_SDA))
oled = SSD1306_I2C(WIDTH, HEIGHT, i2c)

VALVE NODE-
This has not been assembled yet

Any help or advice is much appreciated, especially the coding side of things, im not too bad with circuits wiring etc.. but I am green as with coding, but am very motivated to learn as I have learnt that AI is just a tool (should just put a fullstop here!) not a prime mover of things.. cheers Nick..

Hi Nick,
I live in a similar situation to you in a remote area of eastern Victoria. One of my projects I intend to take on once I have learnt more micropython is water tank level monitoring for my main 100,000 litre storage tank which is about 1KM from my house. I pump from a collection tank at the house to the main storage tank which is at the highest point on my property. To check the main tank level I have to walk to the tank.
All I want to do is know the level in the main tank from my house so my requirements are simpler than yours. I had hoped to able to have just a Pico with LoraWan Meshtastic at each end but there is a powered spot about halfway where I can add a third setup if the distance is too great.
I have a similar level of experience to you so I will follow with interest and chip in if I can.
Ian

Hi Ian,
I think this type of network system has huge potential for farmers and landowners for simple but specific tasks that require custom applications. Im looking forward to becoming adept in this area! Hopefully we can share insight along the way!

Please just take this as a side comment. I am not saying any options or solutions are good or bad as each has their pros and cons.

I kinda view lora to have 3 modes (2 really).
The first is just point to point lora. (this will underpin meshtatstic) but you need to wrote your own code if need need repeaters etc, so more work, but the pro to using basic lora is that you can buy modules that can RX/TX a packet via a uart interface, so if all nodes can see the base stations and no repeaters needed, this can be a cleaner solution; i.e. less overhead of mestastic.

Meshtastic is good as all the hard work as been done so install and user, the down side will be that using someone else firmware means you need a 2nd controller to interface to your data collectors. But the really nice thing is it auto repeats so you dont need to think too much about it.

Then there is loraWAN
This is a node to Gateway comms (so repeating can be a bit more complex) but all the security is taken card of with loraWan modules. i.e. you setup the channels, keys and gateway, then have the gateway send to a server for processing. Main downside is it can get more complex and more costly.

Using a basic lora model (point to point) with line of site, i have personally tested to just under 4Km and I am sure with good line of site I could get longer.

One of the challenges I have been reading about with repeating is how how to manage it to ensure delivery, while at the some time not wasting too much air time. As more and more nodes are added (which may be out of your control) then by default all clients also repeat. so your nodes could become repeaters for the meshtatistic network, thus less time for your needs.

I spent most of my life in East Gippsland and over the years had lots of chats with friends on the land around tank levels and gate states etc. I did have a play with zigbee, but think lora is now a better choice.

So as a few people have commented a few times now… with any radio your best friend will be line of site. Testing in your exact positions can be very handy (I would call it a radio link site survey). e.g. If it works, but looks to be right on the limits, then you know you need to boost it somehow. on the other hand you may find you are well above the minimum signal level needed and are all good.

With these projects I see the radio comms and testing to be fairly straight forward (just need to learn the lingo and work out how to do things in your setup of choice). I see the harder bits is to supply power and look after the environmental.
with higher frequencies you get more loss per meter of cable, so keeping the radio module closer to the antenna is nice, but also need to workout if that means its going to get too hot on those hot summer days. If you have open vents to let the heat out, you are also allowing moist air to get in.

Thanks for your input Michael,
I really cant see there being an issue where I live of having the network crowded with the meshtastic setup but I am very open to whats going to be the best for my situation even if that means changing plans slightly. Line of sight with current and future endeavors shouldnt be a problem.
So are your saying doing away with meshtastic would be a simpler and more cost effective solution?

Need to do the numbers and see if its cheaper or not. If you need to write some code for a controller to talk to a 2nd controller, then you can write the code to talk directly to a cheap lora module. So in theory saving a controller and its power needs.

But it will come at the cost of your code to manage the way packets move. This is not overly hard, but does need some thought.

In class A lora the node must initiate coms to the "node* listening. So what can happen is your node can be always listening then have the central hub poll for status updates.

I am not saying you should out should not use meshtastic, my comment was there are different ways to use lora and some au be better suited.
E.g. if you select well support meshtastic node hardware then its very easy to get up and working, flash and run almost. But if you want to do more then a custom firmware might be the way to go, but now you need to work in their eco system, which could be the best option.

I have two different lora modules with uart interface and if you send a message via uart to the “network”/broadcast address then all nodes with the same id will hear it. If I set one of those as a repeater it can simple re transmit it.

Where I live, I have left a meshtastic node running for about 2 weeks. It has collect about 40 nodes some being 3 to 4 hops away up to about 80km via the relay. At the some time I have also seen some of my nodes just stop working until a reboot. And one of my older nodes drop off their officially supported nodes.

My key point here is more, if it works and meets your needs then all good. But if you need support you may find it becomes “fix it yourself” or buy a current supported module. None of this really matters at a hobby level, but will be important if you start installing for others.

Hope that makes sense.

Yea mate all makes sense cheers.. I do like having autonomy over things even to my own detriment! but I want to learn the in and outs of this stuff and prepared to put in a bit more effort to achieve things.
I found this https://core-electronics.com.au/projects/lora-p2p-wireless-gate-alarm/
which is using all the same hardware I allready have (sx1262, pico etc..) This may be a good starting base for me to use, I will have a look at it and evaluate.

Yeah give it a go, Im really about the learning to the extent that I end up writing my own drivers for things; but if you just want something to work, yeah its to low level.

For hardware most people (on the hobby side) tend to find something that works and stick with it. Im very old school so like to feel more in control. At the moment Im more into the ESP32 and C running RTOS, but that’s just me. Nothing wrong with other hardware and software if you can make it do what you need.

Sometimes I think we are a little spoilt today with all these ready to go dev boards and drivers; but If it brings more people into hardware and building things, then I think its a good thing.