Remote Battery-Powered Sensor


Like every man and this dog, I’m going to build a battery powered IoT module. Ideally it will

  • Run for >1 year on battery (solar is an option, but an extra complication)
  • Use WiFi or LoRa or radio to wirelessly transmit. At least 20m, least ideally 100m
  • Be cheap (<$30 in parts)
  • Be reliable

Wireless Transmission

Lots of comparisons. My summary is:

  • WiFi 2.5Ghz: great and easy and cheap, but high-power demand, good range (150m)
  • Bluetooth Low Energy: medium throughput (1.0Mb/s), medium range (100m), low power (10mW)
  • ZigBee: lower throughout (0.2Mb/s), medium distance (100m), mesh, medium power (100mW)
  • LoRa: low power, (?mW), medium distance (100m), low throughput

WiFi is best if you can power it via solar or mains, as you can directly connect to the internet to upload data.

LoRa is best for battery devices.

Which SoC?

I’m selecting the ESP32, the successor to ESP8266. This is way over powered and more expensive than other chip, but has:

  • Good support
  • Enough memory
  • Ultra low sleep mode
  • Built-in WiFi and BLE

There is a good comparision of ESP32 boards.

Turns out only the FireBeetle ESP32 (from DFRobot) has good deep-sleep performance (I tested it at 10uA). I’m using that. Another option is a ‘bare’ ESP32 chip, which I haven’t tried.

SoC with LoRa

In Australia, use 915MHz for Lora.

You can get a separate module (RFM95), but easier to get an integrated board. There are LoRa only boards:

However, there are now integrated BLE, WiFi, LoRa, ESPP32 with a tiny OLED screen. These can operate as a gateway (Lora<->WiFi<->Internet) or a field sensor (battery powered, using just LoRa). They cost AU$25.

The Swiss Guy reviewed them and said they are ok. The TTGO V2.1 is available here.

However, TTGO has high sleep current, so I switched to the FireBeetle. Current trying to get Lora board’s sleep down too.

Temperature Sensor

The digital DS18B20 is waterproof and can have long leads. It can be attached to pipework too. I’ve used it before. Buy it cheaply for $5. It only does temperature.

Humidity and Air Quality Sensor

These are a bit harder. A review of them shows the DHT22 is unreliable, the BME280 is the best bet.

I’m trying the CJMCU-811 air quality sensor as a test.


The dev boards (e.g. FireBeetle) has a battery charger built in, so I chose a 3.7v lipo rechargeable battery. A low-voltage cutout, either on-board or separate is a necessity. A simple voltage divider (using high-resistance resisters like 1M ohm) can measure the battery voltage.


Initial Results (TTGO)

I got most aspects working, but then… checked the deep-sleep energy consumption. For both the Lora TTGO and even a plain WROOM-32, the deep-sleep current was 9mA. This is a no-go. Deep sleep needs to be around 50uA max to get one year’s usage (50uA sleep x 8860h + 150mA active x 10h =  2000 mAh).

Some options:

  • Use a bare ESP32 and WiFi. That should be able to sleep properly. My WRoom32-DevC board has the same consumption. The DFRobot FireBeetle sleeps properly.
  • Use a bare ESP32 and a RFM95-style module, which might be able to forcefully sleep.
  • Use a solar panel.

The FireBeetle 32 (currently out of stock) is selected as it has a LoRa sheild with low power, and documentation on adding a solar panel – let’s try that!

Second Shot Results (FireBeetle)

FireBeetle on WiFi looks good. I started with a 2800mAh 3.9v battery. The sketch deep sleeps (@10uA) for a minute then runs to get temperature/s and published via WiFi to Influx. This takes about 3s @ 50mA average.

Pasted 2
Battery Voltage and Runtime

We see the battery lasts about 5 days, below 3.6V it fails. It’s easy to calculate the remaining charge from the voltage – it’s linear. The runtime is generally 3s, with occasional spikes (WiFi not found?) – to improve.

I used Blobs v1.0 classes to write the sketch.

Third Shot Results

Improvement to make:

  • Minimise WiFi use – once an hour
  • Wake every ~10 minutes and read, then save temperature to SPIFFS or RTC memory.
  • Maybe use RTOS’s idle hook during reading

The results show we can run for about 3 months on a 2000mAh battery, reading at 10 minute intervals. So we can probably get a year’s operation with a 4000mAh battery and 20 minute intervals.

We also set the DS temperature senses are a bit flaky – not readable sometimes. Need to investigate this and check their operation when esp32 is sleeping: are they drawing current? Is 5v power better?

Leave a Reply

Your email address will not be published. Required fields are marked *