DIY Zigbee capacitive soil moisture sensor

Tags: #<Tag:0x00007fc4129dc4d8> #<Tag:0x00007fc4129dc410>

I want to measure the soil moisture with a capacitive (=non corrosive) sensor and transport the data via the CC2530 Zigbee module. This is how I did it.

Capacitive soil moisture sensor
This is readily available:

The device gives a DC signal of 0-3 V depending on the moisture content.
First challenge is to make it water tight so it can be used in moist soil :grinning:.
I followed this idea:



Please note:

  • that you can only use the CC2530 pins P00 … P07 for analog voltage reading,
  • a diode is needed to avoid “interference” from CC2530.

Flashing CC2530 with PTVO
The CC2530 module is flashed with the great PTVO configurable firmware ( Flashing is done with the CC debugger and the free software from TI ( ) not V2. You only need to define one pin:


Convert voltage to moisture
Connect the moisture sensor/diode/CC2530 and turn on the power. Make sure HA allows new devices to join. Use the MQTT explorer ( ) and connect to HA and look for the newly added device. You should see something like:



Calibration is needed. Note the voltage when the sensor is dry (in my case Vdry = 2.463 V), now put the sensor in glas of water and read the voltage again (in my case Vwet= 1.386 V).

Create moisture MQTT sensor in HA

The formula is: ( (Vdry - voltage_l1) / (Vdry-Vwet) ) * 100

In my case: (2.463 - voltage_l1) / 1.077 * 100

- platform: mqtt
    name: "Moisture"
    state_topic: "zigbee2mqtt/0x00124b0009e004d5"
    unit_of_measurement: "%"
    value_template: "{{ (((2.463 - (value_json.voltage_l1|float)) / 1.077) * 100 ) | round(0) }}"
    availability_topic: "zigbee2mqtt/bridge/state"
    payload_available: "online"
    payload_not_available: "offline"
    json_attributes_topic: "zigbee2mqtt/0x00124b0009e004d5/attributes" 
    icon: mdi:leaf           


Screen Shot 2020-12-01 at 21.34.02

Now you have endless possibilities to use the moisture value to start pumps, set alarms etc.etc.


Do your run this with a battery or is it driven by a external power source?

I am using an external power supply. PTVO is working on a battery operated firmware.

1 Like

That’s really cool. I didn’t realize there was a configurable firmware available for the cc2530. I’ve been wanting a zigbee alternative to esphome and this looks really promising!

yeah indeed, Zigbee is more reliable than wifi. I also have shared on this forum my other Zigbee-PTVO builds ( DS18B20 temperature sensors and roller blinds)


So if i understand you correctly, for now the only option is to power the cc2530 Zigbee module directly from an outlet with a power adaptor ?

That is correct

OK, so i will need to have my flower pot not too far from an outlet then :wink:

1 Like


I built the sensor following your first post but i’m facing an issue :
moisture sensor is always reporting the same value even with the sensor into water.

INFO: MQTT publish: topic 'zigbee2mqtt/0x00124b00070dd928', payload '{"l1":3.203,"linkquality":92,"state_l1":"OFF","voltage_l1":3.2}
  • I did flashed the CC2530 with the firmware as below
  • I put a diode between the sensor and CC2530.

I’m wondering if the diode i’m using is correct (i have no notion in electrionics).
Diode spec : 1N5819 40V 1A Schottky rectifier diode

Hi @MomoB, if you have a simple multimeter, you can first measure the voltage from Capacitive Moisture Sensor before and after the diode to see real voltage.

Thanks. I dont have a multimeter but I put the diode in the wrong direction and the output was 0.4V instead of the usual 3.2V. So the diode seems to be OK.
Also, with the cable disconnected from the pin P06, the output is 0.2V.

It’s looked like the Moisture Sensor is faulty ? The 2 i have ordered do have the same behavior.

Fixed : Both sensors i received have a faulty PCB which seems to be a common occurence.
It is caused by the 1 Mega-Ohm resistor in R4 not being connected to GRD.

After some soldering, the sensor is correctly reporting 2.4V dry and 0.9V wet.

Glad to hear that the sensor is now working for you as well!

Thanks for this tutorial. I flashed the firmware on my CC2530 + CC2591. Now trying without a diode, but I measure already 3,3V on P06, is this correct? Is the diode only for better reading or absolutely necessary?

The diode is an absolute necessity, you can try for yourself :wink:

It looks like a new custom firmware has been released for the CC2530 with a Low Power consumption mode.

How can this feature be used for this sensor to allow usage of a battery ?

I have measured the current used by the capacitive soil moisture device: 5 mA This is excluding the CC2530 device: :cry:
A bit too much for a battery operated device.

1 Like

I dont know how far the firmware can be configured but it seems that sleep mode can be enabled which can provide up to 20mA to sensor when needed.

Hello ! please tell me which diode are you using?

I have used IN5401 Rectifier Diode This is of course ridiculous heavy for this application but I had a few spare ones lying around :crazy_face: