Project · · 9 min read

Going deep with LoRaWAN and power consumption

One LoRaWAN gateway or two to watch for leaks under a building? Three hours of crawling with Rob Howard, the script we used with no internet, and what a second gateway really costs against battery swaps.

Type
Hardware + software
Status
Done
Links
Download the script ↗
Simulator showing an invented crawl space floor plan with one gateway, sensors at SF7 near it and sensors with no link in the far rooms.

In a hurry? Go play with the simulator.

Normally I’m deploying LoRaWAN outdoors, but this time Rob Howard and I took “ground-level monitoring” a bit too literally, in a massive crawl space.

There are numerous pipes to monitor down there, and the floor is completely uneven: bare ground under a vapor barrier, with the occasional cement slab. One area can be completely flooded while the one next to it stays dry. So we’ll have a contact sensor and a rope sensor in every area, plus surface leak sensors under some identified pipes. That means many sensors, spread over the whole building, behind a lot of concrete block walls.

The question is how many gateways it takes, because both answers cost money:

  • Every gateway needs an Ethernet drop routed down there, at $1,000 to $2,000 each.
  • Every sensor too far from a gateway has to transmit slower and longer, which drains its battery, and a battery swap means somebody crawling to it.

So: one gateway or two?

Rob Howard was kindly narrating what is going on for you.

Three hours on all fours

There is zero internet in there, so no network server, no dashboard, nothing to tell us if a packet arrived. Instead, we ran an SSH script to read the gateway’s internal logs in real time (it’s below, help yourself).

Then we crawled and ran back and forth for three hours, trying different nodes and gateway placements, at different spreading factors and data rates. The goal wasn’t a perfect test scenario, but rather a coarse idea of the range to expect.

Gateway sitting on a portable power station, an antenna against the wall and a yellow walkie-talkie on my knee The test setup: gateway on a portable power station, antenna against the wall, and a walkie-talkie.

Pipes and ducts running between concrete block walls in the crawl space What the radio has to go through: block walls, pipes and ducts everywhere.

One thing we found out along the way: our LoRaWAN coverage (902–928 MHz) was very close to that of the GMRS walkie-talkies (462–467 MHz) we brought to talk to each other. Roughly, where the walkie-talkie stopped working, so did the sensors. A pair of walkie-talkies makes a decent first guess before bringing any gateway.

The script

The gateway is a Dragino DLOS8N. Its packet forwarder already logs every packet it hears, so the script only has to SSH in, follow that log, and turn it into a readable table on the laptop.

Terminal table listing uplinks with frequency, data rate, spreading factor, RSSI, SNR and a signal bar Join requests from the test nodes while we moved them around. RSSI goes from -30 dBm next to the gateway down to -116 dBm at the far end.

Notice the DevEUI listed at the end of each line: that’s how you check which device is talking.

  • monitor-lorawan.sh connects to the gateway and follows the forwarder log (Semtech UDP or Basic Station).
  • lora_viewer.py formats the log into the table and decodes the LoRaWAN headers.
  • udp_listener.py is plan B, a fake network server on UDP port 1700.

Or everything in one zip. Join the gateway’s own Wi-Fi access point, then:

./monitor-lorawan.sh              # live uplinks and downlinks
./monitor-lorawan.sh 192.168.1.50 # another gateway address
./monitor-lorawan.sh -a           # the whole forwarder log
./monitor-lorawan.sh -d           # diagnose: processes, config, radio

It needs ssh, nc and python3 on the laptop (written on macOS), and nothing installed on the gateway. The address and the root password in the script are Dragino’s factory defaults. Turn on LogRead > Record Log in the gateway’s web UI first, otherwise it only keeps the last few hundred log lines.

What distance does to the battery

A sensor far from the gateway can still get through by using a higher spreading factor, but airtime is what empties the battery. On the US band, the choice is between these two ends:

SF7 (DR3)SF10 (DR0)
What it isthe fastest data ratethe slowest one, and the most robust
Time on air, 10-byte uplink62 ms371 ms (6× longer)
Weakest signal it can decodeabout -7.5 dB SNRabout -15 dB SNR
When a sensor uses itgood signal, close to the gatewayweak signal, far away or behind walls

We selected Milesight’s leak sensors because they are compact, with no antenna sticking out, and the cells are easy to replace.

Their datasheet gives over 10 years at SF7 and around 4.1 years at SF10, on one 4,000 mAh cell. That sounds scary, but it is for a sensor that talks every 10 minutes and reports a leak every hour on top. A leak sensor doesn’t need to talk that much.

The battery consumption differs slightly from one model to the other, but overall, one “I’m alive” uplink per hour at SF7 means a 10-year battery, and about 8 years at SF10.

Batteries vs. a second gateway

A second gateway, an indoor Milesight UG65, is about $555, plus the Ethernet drop: $1,600 to $2,600 installed.

A battery swap depends on which cell you buy. Saft cells are about $15 to $20 a piece, while generic ER18505 Li-SOCl₂ cells go for $45 the pack of ten on Amazon. Changing the cell takes about 10 minutes per sensor, so a swap is $15 to $30. I count $20.

Extra battery cost of SF10, per sensor over 10 yearsSensors at SF10 needed to pay for the gateway
Milesight’s test: every 10 min + 24 triggers per day$2956 to 90
One “alive” uplink per hour$4387 to 630

Batteries alone will not pay for a second gateway.

What remains is reliability. A leak sensor says “I’m alive” for years and then has one message that really matters. At the far end of the crawl space we saw packets arrive at -116 dBm, and one with an SNR of -15.2 dB, right at the limit of what SF10 can decode. On the US band there is no slower data rate to fall back to. A sensor sitting there will lose packets, and the ways to compensate (confirmed uplinks, retransmissions, rejoins) are exactly what eats the battery.

Try it yourself

Here is a small simulator. The floor plan is invented: two entrances facing each other, eighteen rooms, a contact sensor and a rope sensor in every room, and a surface sensor under a few pipes. Each sensor picks the fastest data rate that still reaches a gateway. Switch to two gateways, drag them around, and watch the spreading factors drop.

It shows what we saw down there: with one gateway, the corners end up at SF10 or with no link at all. The second gateway saves very little on batteries. What it buys is the corners.

  • One central gateway. Nothing more to install. The sensors furthest away work at SF10, at the edge of the coverage, and some may not get through every time. They are also the ones closest to the entrances, so the easiest to reach for a battery swap.
  • Two gateways with overlapping coverage. It is $1,600 to $2,600 more, and the batteries will never pay that back. But the alarm has two chances to get through, and there’s a backup if one gateway goes down.

The only good reason to pay for the second gateway is not to miss a leak.

Either way: turn on ADR so the sensors with a good signal settle at SF7 by themselves, keep the reporting interval long, and take the dual-battery (8,000 mAh) version of the sensor for the spots that stay weak.

The math, for the curious

Skip this part unless you want to check the numbers or redo them with yours.

Spreading factors and data rates

Airtime of a 10-byte uplink at 125 kHz. The data rate numbers don’t mean the same thing on both sides of the Atlantic, and US uplinks stop at SF10.

Spreading factorUS915EU868Time on airvs SF7
SF7DR3DR562 ms1×
SF8DR2DR4113 ms1.8×
SF9DR1DR3206 ms3.3×
SF10DR0DR2371 ms6×
SF11n/aDR1823 ms13×
SF12n/aDR01,483 ms24×

What Milesight says

SensorTest conditionSF7SF10, US915SF10, EU868
EM300-SLD and ZLD (contact and rope)10 min interval + 24 triggers per dayover 10 yearsaround 4.1 yearsaround 5.6 years
EM300-MLD (membrane)one hour of leakage per day, 25°Caround 10 yearsaround 3.9 yearsaround 5.3 years

All on one 4,000 mAh ER18505 cell, tested in the lab. The US loses more at SF10 because the sensor transmits at 20 dBm there, instead of 16 dBm in Europe.

Milesight’s test is 168 uplinks per day (one every 10 minutes, plus 24 triggers), and I count “over 10 years” as 10.

  • One cell is 4,000 mAh × 3,600 = 14,400,000 mAs.
  • Daily use at SF7: 14,400,000 ÷ (10 × 365 days) = 3,945 mAs.
  • Daily use at SF10: 14,400,000 ÷ (4.1 × 365 days) = 9,622 mAs.
  • Extra per SF10 uplink: (9,622 − 3,945) ÷ 168 = 34 mAs.
  • At 24 uplinks per day: 3,945 + 24 × 34 = 4,756 mAs per day, so 14,400,000 ÷ 4,756 = 3,028 days, or 8.3 years.

Cost

Second gateway over 10 yearsLowHigh
UG65 gateway, without cellular (retail, Nov 2026)$555$555
Routing an Ethernet drop$1,000$2,000
Electricity (2.9 W × 10 years × $0.13/kWh)$33$33
Total$1,588$2,588
One battery swapGeneric cellSaft cellWhat I count
ER18505 cell$4.50$15 to $20$10
Labor: 10 min per sensor, at $60/h$10$10$10
Total$14.50$25 to $30$20

For a sensor at one uplink per hour:

  1. Cells used in 10 years. At SF7: 10 ÷ 10 = 1 cell. At SF10: 10 ÷ 8.3 = 1.21 cells.
  2. Extra swaps because of SF10. 1.21 − 1 = 0.21 swap per sensor.
  3. Extra cost per sensor. 0.21 × $20 = $4 over 10 years.
  4. Break-even. $1,588 ÷ $4.11 = 386.4 and $2,588 ÷ $4.11 = 629.7, so 387 to 630 sensors.
Uplinks per dayBattery at SF10Extra swaps per sensorExtra cost per sensorSensors to pay for the gateway
Milesight’s test1684.1 years1.44$2956 to 90
One uplink per hour248.3 years0.21$4387 to 630