DIY low power 433MHz TH sensor with 5 year battery life

Something a little different from the DIY ESP wifi sensors you’d usually find here :slight_smile:

So winter is coming and we needed an additional temperature and humidity sensor for a room we weren’t using before. I always liked the 433MHz sensors from Oregon Scientific, the THGN/THGR series. They’re small, inexpensive, have great range, a protocol that is supported by all major RF modules for HA (RFXCOM, RFLink, etc) and most important of all, their battery life is insane compared to today’s zigbee/zwave/whatever devices. I’ve a couple of sensors I haven’t changed the batteries for 4 years and they’re still up and running !

image

Sadly, they’re not manufactured anymore. So I decided to build a DIY clone which had to have the following properties:

  • Same protocol as my existing sensors, readable by my current RF module (an RFXCOM RfxTrx433).
  • Similar battery life (at least 3 years)
  • I only had an evening to do this, so it had to be quick and with components I had in my spare parts bin.

The spare parts

I wanted the sensor to be powered by two AA batteries, totalling 3V. So I decided to use an Arduino Pro Mini as the heart of the sensor, running an ATMega328p MCU clocked at 8MHz. The 328p can actually run down to 1.8V, but doing this would require clocking it at a very low frequency, below 2MHz. At this frequency, it becomes complicated to keep the timing of the RF protocol, so I opted for an 8MHz clock at 3V. This also reduced power consumption. I also disabled the power LED by physically removing it, as it was pulling a lot of current.

The temperature and humidity sensor I used is a standard BME280 connected over the I2C bus. It has a pretty good power saving sleep mode integrated, using only a few µA and is rated from 1.7V to 3.6V. So that was a perfect match. And finally, I used a standard cheapo 433MHz transmitter module for the OOK modulated transmission. The nice thing about this module is that it doesn’t consume any power when no data is sent to it.

image

Low power design

If I wanted the batteries to last for years, I had to really cut down on power use. That meant aggressive use of sleep modes for everything, from the MCU, peripherals and the BME module. The sensor will transmit its data every 5 minutes and spend the rest of the time sleeping. The 328p has a mode where all clock oscillators are stopped, the main processor is put into deep sleep and then awaits an interrupt to wake up and resume execution where it left off. This interrupt can come from an external clock, but that would have meant more components and higher power use.

So I opted for the internal watchdog timer. This is a timer integrated into the MCU that fires after a predetermined period of time and wakes up the processor. Enabling and configuring it the way I wanted to involved a little low level bit manipulation in the processor control registers, but it’s all well documented in the datasheet. I also disabled BOD (brown out detection), which will stop the MCU if the voltage gets too low, reducing power use further.

void sleep(void)
{
    // Turn off ADC during sleep
    ADCSRA &= ~(1 << ADEN);

    // Enable the Watchdog interrupt before going to sleep (no WDE)
    WDTCSR |= _BV(WDIE);

    // Use power down sleep mode, the lowest power one
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);

    // Get ready to disable all clock oscillators and brown out detection
    cli();
    sleep_enable();
    sleep_bod_disable();
    sei();

    // Sleep the CPU
    sleep_cpu();

    // Continue execution here after the WDT fired, wake up the CPU now
    sleep_disable();

    // Enable interrupts
    sei();

    // Re-enable the peripherals
    power_all_enable();

    // Reenable ADC
    ADCSRA |= (1 << ADEN);
}

So doing all this gave me an average power consumption of 620µA. That’s far too much. Batteries would not have lasted more than half a year with that. Not good. So I had to get it further down. So whats next ?

The BME280 needs to sleep too ! According to the BME280 datasheet, the sensor has a built-in sleep mode where it only consumes 0.1µA. Nice ! Of course I would have to add the consumption of the level shifters and other components on the breakout board I was using, but it sounded promising. In order to use this sleep, you have to operate the BME in forced mode. Waking up the BME, waiting for it to stabilize, taking one sample and going back to sleep. Thankfully the Adafruit BME library I was using had some functions available to easily perform these operations.

// Set BME to forced mode (take one sample and go to sleep)
bme.setSampling(Adafruit_BME280::MODE_FORCED);

// Read BME data, BME goes back to sleep after that
bme.takeForcedMeasurement();
float t = bme.readTemperature();
float h = bme.readHumidity();

I ended up with an average power consumption of 55µA. Using typical alkaline AA batteries with a capacity of 2500mAh, this gives a theoretical runtime of over 5 years on a single set of batteries. That’s probably longer than their own self discharge rate.

Putting it all together

I didn’t want to put in the time designing and ordering a PCB for this, so I just quickly soldered the modules together:

image

The code and the schematics are on my github. For the RF protocol, I used the library WlessOregonV2 by Olivier Lebrun and Dominique Pierre, who had already reverse engineered the Oregon Scientific transmission format. Without that I wouldn’t have been able to do this in one evening :slight_smile:

I love seeing people post things like this - helps me learn! Thanks for sharing.

is there a reason you prefer to use alkaline over a single rechargeable 18650 ?

Yes. Self discharge rate and shelf life, which is an order of magnitude worse on rechargeable Li-ion batteries.

Li-ion’s have clear advantages over older alkaline cells for larger discharge currents. But for very low power devices, they’re not a good choice. At around the same capacity per battery (2500-3000mAh), Alkalines lose around 2-3% of their charge per year. Li-ions lose 1-2% per month (12-24% per year). So the runtime of the device would be a lot shorter on Li-ions.

Now, non-rechargeable lithium batteries are different (they use a different chemistry than rechargeable Li-ion’s). They would be a great choice for a low power device like this. But I didn’t have any unused around.

Very cool. I’d like something similar for my mailbox, but what battery chemistry can work well in the elements? What can be used for a hub? The RFXCOM hub is no longer in production.

RFLink and rtl_433 both support this protocol. Maybe the Sonoff RFBridge with alternative firmware, but not sure about that.

For outdoor use, non-rechargeable lithium batteries would be best.

Hey Alex
Sorry for bringing an old post to life, but this is exactly the solution I am after for a very low power longe range temp device.

I need at least 50m coverage through my garden and through a brick wall. Would that be doable with this setup, and what 433 mhz module would you recommend as the transmitter and for the receiving device connected to HA, respectively? (I have no 433 mhz receiver stick, so I would beed to build one also).

Also would it be possible to run the node on a ls26500 3,6v li-socl2 battery? Or would that require some voltage regulation?

If you were to do it again, would you still use an arduino nano, or would you go with for example an esp-01 (that can also be used for a lot of other applications because of its built in wifi, althoug as a mains powered device)?

Any ideas how to bring down the cost if making multiple devices?

How is your setup running some time after this post?

The OP hasnt posted in 2 years so he may not answer. If i was to do what your looking for again as cheap as possible then I would by a generic 433mhz weather sensor. They cost about 5bucks on aliexpress. The receiver I would go with is an rtl-sdr for about 20 bucks. I do have 2 such devices outside so i modified them with a small solar panel with tp4056 and a lithium cell from a discarded vape with Low dropout linear regulator. Some 433mhz devices tolerate 4.2v but possibly at reduced life expectancy.

Spiro, thanks a lot for answering this.
What sensor do you have in mind?
And what about the range, would they fulfill my needs as described?

Will it work for you is a very difficult to answer exactly. 50m is not too far. Even a brick wall is possible. There are many factors that could affect it. like your receivers height above the ground where the sensor is, What your wall is made of, metal objects anywhere near, plants in the garden, other 433mhz transmitters in your area, the antenna on the SDR-RTL.
I’ve used BALDR Wireless Weather Station Outdoor Remote Sensor and similar digoo ones. RF is part magic not science and your milage may vary. Not everyone finds it easy even to setup the 433-rtl app on HA.

wanted to post for some time now … sorry for half baked post
I have got 5 of these working just fine for quite some time and am quite happy with the setup. @12422 pro mini has a voltage regulator on board - that i removed to reduce energy consumption even more but did not measure the result. At least in my situation with 2-3 walls any generic 433Mhz sender module will do the job.
Using an antenna similar to this: 433 MHz Coil Loaded Antenna - Instructables

I altered the software to emulate BTHR918N instead of THGR122N to have access to the pressure measurements of BME280 and to send a bit indicating battery voltage threshold.