DIY Zigbee 4x DS18B20 temperature measurement

Tags: #<Tag:0x00007f7392f3d240> #<Tag:0x00007f7392f3d060>

I needed to read and record 4 temperature sensors on my central heating system and I wanted to use Zigbee as a reliable protocol. Here is how I did it, no rocket science but a lot of interesting details.

Hardware: DS18B20 sensors & CC2530 Zigbee module

Schematic:

Real life:

Software:
The CC2530 module is flashed with the great PTVO configurable firmware (https://ptvo.info/zigbee-switch-configurable-firmware-v2-210/). Flashing is done with the CC debugger and the free software from TI (https://www.ti.com/tool/FLASH-PROGRAMMER) not V2.

Obtain the DS18b20 device ID:
There are many ways, but I have chosen to do it with PTVO.
Flash the CC2530 with the following configuration (no Device ID):

Connect the CC2530 to the 4 sensors and power up. In HA switch on ‘allow devices to join’ for zigbee2mqtt.

The new device will appear in HA. Now install the MQTT explorer (http://mqtt-explorer.com/) and connect to HA and look for the newly added device.

In the History box of the device you will see that at the l1 position 4 different ID’s appear over time. Note them down.

Screen Shot 2020-11-15 at 11.25.02

Flash CC2530 again:
Now amend the PTVO configuration with the obtained Device ID’s:


and load the new firmware to the CC2530. You can check the configuration file, PTVO creates a HEX file and a text file (handy to correct typing and copy paste errors).

files

Power up the CC2530 with the 4 sensors and the unit will submit data to l1, l2, l3 and l4.

Get the temperature sensors in HA:
We are going to create 4 MQTT sensors:

#########################################################
#                                                       #
#           ZONNEBOILER TEMP PVTO                       #
#                                                       #
#########################################################    
  
  - platform: mqtt
    name: "T1"
    state_topic: "zigbee2mqtt/0x00124b000bc244a9"
    unit_of_measurement: "°C"
    value_template: "{{ value_json.l1 | round(1) }}"
    availability_topic: "zigbee2mqtt/bridge/state"
    payload_available: "online"
    payload_not_available: "offline"
    json_attributes_topic: "zigbee2mqtt/0x00124b000bc244a9/attributes" 
    icon: mdi:coolant-temperature
        
  - platform: mqtt
    name: "T2"
    state_topic: "zigbee2mqtt/0x00124b000bc244a9"
    unit_of_measurement: "°C"
    value_template: "{{ value_json.l2 | round(1) }}"
    availability_topic: "zigbee2mqtt/bridge/state"
    payload_available: "online"
    payload_not_available: "offline"
    json_attributes_topic: "zigbee2mqtt/0x00124b000bc244a9/attributes" 
    icon: mdi:coolant-temperature        
      
  - platform: mqtt
    name: "T3"
    state_topic: "zigbee2mqtt/0x00124b000bc244a9"
    unit_of_measurement: "°C"
    value_template: "{{ value_json.l3 | round(1) }}"
    availability_topic: "zigbee2mqtt/bridge/state"
    payload_available: "online"
    payload_not_available: "offline"
    json_attributes_topic: "zigbee2mqtt/0x00124b000bc244a9/attributes" 
    icon: mdi:coolant-temperature       

  - platform: mqtt
    name: "T4"
    state_topic: "zigbee2mqtt/0x00124b000bc244a9"
    unit_of_measurement: "°C"
    value_template: "{{ value_json.l4 | round(1) }}"
    availability_topic: "zigbee2mqtt/bridge/state"
    payload_available: "online"
    payload_not_available: "offline"
    json_attributes_topic: "zigbee2mqtt/0x00124b000bc244a9/attributes" 
    icon: mdi:coolant-temperature          
    
  
#########################################################
#                                                       #
#            END OF CONFIGURATION FILE                  #
#                                                       #
######################################################### 

Screen Shot 2020-11-18 at 20.56.17

Done

3 Likes

Wow this is very cool, I’ve always wondered if it was possible to connect sensors to a zigbee ic, like you can with esp8266 etc. I wonder if it draws a lot of power, and if I can make it battery powered…

And would this work with ZHA?

The PTVO configurable firmware does not (yet) support battery power. I am using the zigbee2mqtt integration.

I have had a little look at ptvo firmware before but never progressed or implemented it.

Now that I have a better zigbee co-ordinator I can use my cc2530 to have a ply. Thank you for the inspiration.

I have often wished that there was a zigbee version of the esp8266. This is (sort of) what is needed.

I say “sort of” because I think ptvo is not open source, and programming the cc2530 seems to be a dark art compared to an esp.

Cheers and thanks again.

1 Like