Accéder au contenu principal

Low cost, low power 6uA garden 433Mhz sensor with temperature, humidity ,hygrometer and voltage

I have built an external sensor so as to monitor temperature, air humidity, soil humidity of my garden and the battery voltage. The requirements was:
  • waterproof
  • long battery life, the atmega328p run at 8mhz with minimal components and functions
  • under 10€
  • wireless (433Mhz) with good range (2 walls to cross and 10 meters)
Here is the final view:

And some reports from OpenHab displaying the sensor data:

Air humidity

Soil humidity

Air temperature

We can of course imagine to use these values to control a water pump. Now let's see hpw to build this.

Bill of material

The sensors is based on atmega328p(3€), 
At total we are around 10€


Every hour the sensor send the data to a 433Mhz gateway so as to be stored in OpenHAB, the data sent are:
  • air temperature
  • air humidity
  • soild humidity
  • voltage of the power supply
The library used to send the data is RCSwitch.

The program to load to atmega328p on the sensor is here Low power sensor

The main principle of the architecture is to power ON the components on needs by using the digital pins of the ATmega328p as power supplies. The dht, the RF emitter and the moisture sensor are powered from pins directly. With this architecture they are consumming only when activated by the program and reducing by the way the power consumption of the whole system.

The current consumption of the system in sleep mode with 3 AA batteries giving 5V is around 6uA (yes 0,006mA), when retrieving and sending data we reach at maximum 20mA . If we consider that the system is going to wake up every hour 3 seconds so as to measure and send data. The theoretical life of this sensor with AA Alkaline battery (2000mAh) is around 10 years !! For this duration i'm not taking into account the discharge rate of this type of battery that can be significant compared to the consumption of the sensor. If we take into account the self discharge of typical alkaline battery (3% per year) the duration of our system go down to 7-8 years. Remaining quite interesting for my use.

After these theroretical things let's go to the practical side of this project.

Steps to follow

1) First we need to set the extended fuses of the ATMega 328p to disable brown out detection permanently and run at 8mhz, this will be done by a bootloader update

      newlFuse = 0xE2;  // internal 8 MHz oscillator

      newhFuse = 0xDA;  //  2048 byte bootloader, SPI enabled

      newextFuse = 0xFF; // disable Brown Out Detection to save power

So as to do that we will lean on the excellent tutorials of Nick Gammon:

  • Load this program on an arduino uno and wire it like that you can follow the chapter Alternate clock source to avoid the use of quartz on the breadboard. I forked the program of Nick Gammon and modified the valued of extended fuse so as to run disable BOD on the chip bootloader.
  • Once wired link your arduino uno to the pc, launch the arduino IDE and open the serial monitor at 115200 baud
  • If the ATMega328p is detected you will get the details of its current bootloader
Atmega chip programmer.
Written by Nick Gammon.
Version 1.36
Compiled on Jun 21 2016 at 21:40:08 with Arduino IDE 10605.
Attempting to enter ICSP programming mode ...
Entered programming mode OK.
Signature = 0x1E 0x95 0x0F
Processor = ATmega328P
Flash memory size = 32768 bytes.
LFuse = 0xE2
HFuse = 0xDA
EFuse = 0xFF
Lock byte = 0xEF
Clock calibration = 0x9B
Type 'L' to use Lilypad (8 MHz) loader, or 'U' for Uno (16 MHz) loader ...
  • Type L and enter
Using Lilypad 8 MHz loader.
Bootloader address = 0x7800
Bootloader length = 1932 bytes.
Type 'Q' to quit, 'V' to verify, or 'G' to program the chip with the bootloader ...
  • Type G and enter
Erasing chip ...
Writing bootloader ...
Committing page starting at 0x7800
Committing page starting at 0x7880
Committing page starting at 0x7900
Committing page starting at 0x7980
Committing page starting at 0x7A00
Committing page starting at 0x7A80
Committing page starting at 0x7B00
Committing page starting at 0x7B80
Committing page starting at 0x7C00
Committing page starting at 0x7C80
Committing page starting at 0x7D00
Committing page starting at 0x7D80
Committing page starting at 0x7E00
Committing page starting at 0x7E80
Committing page starting at 0x7F00
Committing page starting at 0x7F80
Verifying ...
No errors found.
Writing fuses ...
LFuse = 0xE2 
HFuse = 0xDA 
EFuse = 0xFF 
Lock byte = 0xEF 
Clock calibration = 0x9B 
Programming mode off.

Your atmega328p is now ready to welcome the sensor program!

2) Load the program

So as to load the program into the ATMega328p I use the following methods:
  • remove the Atmega328p chip of an arduino Uno
  • place your modified Atmega328p in the place of the stock one
  • on the arduino IDE select "Lilypad Arduino"
  • Connect the usb to the arduino Uno
  • Select the good port
  • Load this program:

3) Prototype the sensor

Now we need to do a little bit of hardware, here is the schematic:

and how it looks like on the breadboard:

And on a prototype PCB:

Once packaged in a standard electric box:

Once this is done you need to receive the data and store it to have some charts about your garden environment, so as to receive the data I use the 433Mhz MQTT Gateway sending the data to OpenHab.
Here is how it looks like on the webUI:

And the big question is ; how much does it last?
It is runningsince june 2016, now we need to wait so as to have more feedback in particular I will need to take into account other factor than the system itself like the influence of the temperature to the battery life.


  1. Hi

    Can you please tell me how to load the ino code to the atmega328P I already have the bootloader installed in it.

    I tried to follow the link you provided but couldn’t understand.


    1. Hello,

      If you have used the method above to load you bootloader you can keep your wiring like that.
      After load the program ArduinoISP into the Arduino Uno (change the target board to Arduino on IDE settings)
      Once the program has been loaded the arduino will act as the atmega328p programmer.
      To load the program into the Atmega328p choose the board Lilypad arduino" and "Arduino as ISP" for the programmer instead of AVR ISP.
      To upload the program don't choose upload but upload with a programmer

    2. Hi Flo

      Thanks for your response.

      I bought the atmega328P from ebay with the bootloader pre-installed and I am not sure as to how I have to program it.

      I have an arduino esp8266 as well which I thought I would require it to program the atmega328P but I am lost and dont know how to?

    3. Hello,

      I don't know how to change the bootloader of an atmega328p with an esp8266 but if you follow this tutorial you should be able to change the bootloader with an arduino uno. Once the bootloader is loaded you can go with the program upload

  2. Hi thanks for your reply.

    In my previous comment I meant, the atmega 328p that I have already contains the bootloader see here (
    I want to now upload the program but I want to know what components do I require to do this? and what is the wiring? I am new to this sorry.


    1. Hello,

      Yes but you have the standard bootloader which runs at 16mhz and without the low power parameters of the ones proposed on this tutorial.
      You can of course load the program but you will not reach low power consumption.

      The wiring to load is this one "Uploading Using an Arduino Board"

  3. Hi

    Is it possible to do the same project with a rf receiver instead of a rf transmitter.

    If yes the can you please help me with the code. I just need the rf transmitter and no temp and humidity sensors.


  4. I got the current in sleep mode to be 0.06 mA with 5V power supply and 0.04 mA with a 3.3V power supply. I think your 0.006 mA should be 0.06 mA.

    1. hmm, did you changed the bootloader?

    2. Yes, I did change the boot loader using your forked code above and the remaining files using Gammon's website. Also, I used Lilypad Arduino while burning the code.

  5. One thing I did notice: Gammon uses capacitors and you don't. Do these capacitors need to be removed?

    1. I'm not an electronics expert but following my experiences it works without.

  6. what kind of other components did you use?
    like the values of the three different resistors on the final result?

    1. for the dht it's a 10K
      for the led a 1.2K

      I don't think the one for the dht is compulsory


Enregistrer un commentaire

Posts les plus consultés de ce blog

433toMQTTto433 - Bidirectional ESP8266 NodeMCU gateway between RF 433Mhz signal and MQTT

The goal  is to act as a gateway between 433Mhz sensors and a MQTT broker or between the MQTT broker and 433Mhz actuators, It enables to:
receive MQTT data from a topic and send RF 433Mhz signal corresponding to the received MQTT data publish MQTT data to a different topic related to received 433Mhz signal 
It can be an interesting part in an home automation system so as to interface sensors and actuators (wall sockets) with software like openhab.

List of compatible sensors here

The interest of putting this gateway to an ESP8266 and not on a raspberry pi is to be able to manage security actions at gateway level (power on a siren, cut power to certain devices) following RF data received by sensors without being dependent to the PI for security related actions.

[EDIT] all infos are now centralized into the github repository take a look at it you will find up to date info about OpenMQTTGateway

You need:


MosquittoArduino IDE latest version (tested ok with 1.6.10)esp8266 board added to t…

Infrared IR, 433mhz and MQTT on ESP8266 bidirectional gateway OpenMQTTGateway

Following discussions on the home assistant forum people gave me the idea to add Infrared communication to the 433mhz gateway. 

The goal is to act as a gateway between 433Mhz sensors, infrared remote controls and a MQTT broker or between the MQTT broker and 433Mhz actuators, infrared devices, It enables to:
receive MQTT data from a topic and send RF 433Mhz signal corresponding to the received MQTT data publish MQTT data to a different topic related to received 433Mhz signal receive MQTT data from a topic and send infrared signal corresponding to the received MQTT data publish MQTT data to a different topic related to received infrared signal 
It can be an interesting part in an home automation system so as to interface sensors and actuators (wall sockets), your tv, home cinema, hifi ... with software like openhab or home assistant.

List of compatible RF sensors here

[EDIT] all infos are now centralized into the github repository take a look at it you will find up to date info about OpenMQT…

Adding infrared emitter to SONOFF RF BRIDGE

With the add of  SONOFF RF Bridge  to the OpenMQTTGateway compatibility list we were able to send and receive 433mhz by MQTT. 
The interesting thing with OpenMQTTGateway is the ability to have on one board several gateways (RF, IR, BLE and more to come ;-). 

The last versions of SONOFF RF BRIDGE as two IO free pins, why not using these pins to add a new gateway to this little cheap device and control more devices.

If we follow the interest of the different gateways you are more interested on RF and after comes IR infrared.

My choice came in this case to add an infrared emitter to the RF Bridge, with this gateway we are adding the capacity of controlling TV, DVD, hifi...

On the hardware side, I followed the same schematic for IR setup with ESP8266 with just a little add a protection resistor of 1K for the IR led.
The other resistor is connected between the transistor base and IO5 of the RF Bridge instead of D0.
The IR led is powered by the 3,3V of the Sonoff RF Bridge.

The schema:

Here is how i…