Farm LoRa Project: laying the groundwork
· 3 min read · Updated
On this page
Farm LoRa Project: laying the groundwork#
the idea#
The farm's 32 acres and the WiFi dies the second you walk into the metal barn. Plan is a little LoRa network instead: one gateway at the house, and sensor nodes out at the brooder barn, the wells, and the gate. The radios are DX-LR32 modules (SX1262, 915 MHz). They're UART modules, so the ESP32 just sees a stream of bytes, no packets. I wrote a small packet format on top of that with a sync byte, a length, and a CRC so the receiver can tell where a packet starts and ends and whether it got mangled.
Tonight was just getting two radios to talk on the bench. That took a lot longer than it should have.
gpsd#
First upload failed. gpsd had grabbed /dev/ttyUSB0 again. Stopping it wasn't enough cause it starts itself back up when a USB serial device shows up, so it's masked now.
my power supply app ate the port#
I have a little app that controls my bench supply over USB. The supply uses a CP2102 USB serial chip. So does the ESP32. Both report the same serial number (0001), and the app just grabs "a CP2102", so it kept opening the ESP32 and eating its output. Pinned the app to the supply's physical USB port and that fixed it. It was a small thing but it was something nonetheless.
wrong pins. for like an hour#
Nothing answered on the radio pins. Turns out the wires were landing two pins off the whole time. The pinout image I was going off doesn't quite match this board. Ended up flashing a tiny sketch that drives each GPIO one at a time and reports which other pin follows it, and that found the jumper sitting on GPIO5 instead of 19.
the radio reset every time it transmitted#
Once the wiring was right the radio would talk, but every byte I sent made it print "Power on" again. It was rebooting on every transmit. Each transmit pulls around 190 mA, and through flimsy jumper wires the voltage sagged enough to reset it. Running power straight to the module helped. Long replies were still coming back as garbage halfway through though, until I redid power and ground in solid core wire and ran a ground from the radio straight to the ESP32. After that everything was clean.
+++ doesn't get you out#
You get into AT mode (the config mode) by sending +++. The manual says send +++ again to leave. My modules (firmware V1.2.4) just reply ERROR=104 to that. AT+RESET works instead, the module always boots back into normal mode. The test sketch does that now.
don't blast them at a foot#
These ship at 22 dBm, full power. At about a foot apart that's more than the receiver on the other one is rated for. First thing I did on each radio was drop it to 0 dBm, which is plenty on a bench. The range test sketch always boots at 0 and won't go to 22 while the radios are still close.
it works#
Two radios on one ESP32, 5 pings, 5 back. About 460 ms round trip at the long range setting, around -9 dBm at 5 inches.
Then one radio per ESP32. 58 packets, none lost, mostly -15 to -25 dBm in the same room with a few dips to -36. Each board has an RGB LED that goes green to yellow to red as the signal drops, and the base logs every packet with timestamps.
next#
Range test in daylight. Base stays at the house, I walk the other one out toward the barn (73 m) and the far well (413 m) and see where it drops. Also need to buy capacitors, I have zero and the radios would really like some. After that it's real node firmware, starting with a BME280 in the brooder barn.
I also need to add image support for this blog and better blog drafting. Sounds like a tomorrow me problem lol