DIY Zigbee 4x DS18B20 temperature measurement

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

18 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.

2 Likes

Recently i designed a board to simplify the development process of zigbee end devices. PTVO firmware is great and a user friendly hardware was needed… https://gio-dot.github.io/Z1-Mini/

2 Likes

Lovely, but tindie doesn’t seem to know about it https://www.tindie.com/search/?q=z1-mini

Oh no! We can’t find anything related to z1-mini .

Sorry… published just today.

That’s cool, :slight_smile:

Thanks, Great Job!
But due to I cant get success with my board, there are some questions:

  1. May I use any other port instead of P15 to connect ds18b20?
  2. I see newly added device in HA, but there is no such in MQTT explorer. So, I cant derive sensor ID as described in your article.
    Environment:
    HA is running on Docker, hw platform - beaglebone.
    I checked data transition at the sensor data pin with osciloscope - it iseems OK, at least init preable
  1. Port P15 is just a choice, not critical
  2. If the device is ‘visible’ in HA then it must also be visible in MQTT explorer.
    In MQTT explorer you see something like:Screen Shot 2021-07-04 at 17.44.41

each Zigbee device listed like 0x00124b0097331f3 , your CC2530 should be there somewhere, if not the device has not been paired yet (can take some minutes if you use simple/less powerfull coordinator)

PS: The device adres can be seen in the TI flashing program.

Thanks a lot for quick reply!
What I actually have in MQTT explorer is


device IEEE: 00:12:4b:00:1e:d1:6c:94 (as discovered by HA)

ah, I see your cc2530 is not paired/connected yet

1 Like

Isnt it strange that HA does show the device is paired already, but mqttexplorer doesnt?

indeed, can you please share your HA screen where the device is showing up?

1 Like

Checked it again. You`re right, something is wrong with the device connection, HA doesnt show it properly. Looking for solution. Thanks a lot!

Hi, is it possible that i send you a cc2530 board and 4 sensors to program for me?

Yes happy to do that, just send me a dm

Hi first of all where are you situated. We are in Friesland the Netherlands. It makers no sense to send the stuff by parcel post as it will become too expensive. Thanks

Hi, I’ve checked things again. I’m confused. My HA server works in docker (ip 172.17.0.1) on beaglebone based host (192.168.1.78). As you adviced above, I’ve got device connected, HA shows:

MQTT Explorer connected to docker shows:

MQTT Explorer connected to host:

So, it is far from the snapshot of your system shown above, device is not discovered with MQTT Explorer. Thank you in advace for ideas!

You do have zigbee2mqtt don’t you?