2 years of LoRa trough sensors on a dairy farm: what I stuffed up so you don't have to
Contents
Kia ora. Not a programmer, just a dairy farmer in the Waikato who got sick of driving round on the quad every morning checking troughs. 400 cows, 28 troughs, 3 tanks. That run took me about an hour and a half before milking, every day, rain or shine.
Two years ago I started teaching myself Arduino off YouTube. Now every trough and tank reports in over LoRaWAN and I get a ping on my phone if one is low. I've stuffed up most things at least once, so here's the list.
The setup
- A RAK LoRaWAN gateway on the cowshed roof, on The Things Network (the free community one)
- Heltec LoRa boards for the nodes, 3 lithium AAs each, in IP67 junction boxes from the electrical wholesaler
- Float switches in the troughs, JSN-SR04T waterproof ultrasonic sensors in the tanks
- Home Assistant on an old PC in the shed, pulling from TTN over MQTT
Stuff-up 1: ultrasonic in troughs
Started with the ultrasonic sensors in the troughs too. Condensation on the sensor face gave rubbish readings every frosty morning. Then the cows worked out the sensor was there and started licking it. One knocked the whole bracket into the water. Switched the troughs to plain float switches, just "ok" or "low". Cheap, cows can't hurt them, never wrong. The ultrasonics are only on the tanks now, with a little hood over them.
Stuff-up 2: spreading factor
To get range I had everything at SF12. Works over the hills, but at SF12 a tiny message takes over a second of airtime, and TTN's fair use is 30 seconds of uplink airtime per device per day. That's only about 20 messages a day. Fix was getting the gateway higher: up a 6 metre pole on the shed instead of on the roof. Now most nodes sit at SF9 or lower with ADR turned on, and they can report every 15 minutes no worries.
Stuff-up 3: water in the boxes
The first boxes filled with water through the cable gland. Wrong size gland for the cable, so it never sealed. Get glands that match your cable diameter, put a drip loop in the cable so water runs off before it reaches the box, and put a sachet of silica gel inside. The ones I built right have been bone dry for 18 months.
Stuff-up 4: lightning
Lost the gateway in a thunderstorm the first winter. Now there's a surge arrestor on the antenna feed and it's earthed properly to the shed earth. Sparky did that bit, not me.
Stuff-up 5: the alerts
At first only my phone got alerts. Then I was off the farm one day and a trough valve stuck. Now the missus gets them too, which means I get a phone call, which is honestly more reliable than any notification.
Was it worth it?
Yeah. I get that hour and a half back most mornings, I only drive to the troughs that need me. We caught a leaking trough valve in the first month that would've been pumping water into a paddock for weeks. Gateway was about NZ$400, each node about $45-60 all up. Paid for itself in diesel and time the first season.
The boxes are ugly, held together with cable ties and silicone, and I'm proud of every one of them. Happy to answer anything.
Get the best of #raspberry_pi_lab weekly
One email each Monday with the most useful posts. No spam; unsubscribe in one click.
Comments
Sign in to join the conversation.
Sign in to comment