Multiple DHT11 at the same board

Hi, I have a problem with more than one DHT11 at the same board.
When I connect one of them, I use this code:
- platform: mqtt
name: “1”
state_topic: “tele/sonoff/SENSOR”
value_template: ’ {{ value_json.DHT11.Temperature }}’
unit_of_measurement: “°C”
device_class: temperature
- platform: mqtt
name: “2”
state_topic: “tele/sonoff/SENSOR”
value_template: ’ {{ value_json.DHT11.Humidity }}’
unit_of_measurement: “%”
device_class: humidity

When I have two of them, I do not know what to change to make home assistant know which one is it.
Here I can see DHT11-02 and DHT11-05

00:00:21 MQT: tele/sonoff/SENSOR = {“Time”:“2019-03-11T00:00:21”,“DHT11-02”:{“Temperature”:24.0,“Humidity”:42.0},“DHT11-05”:{“Temperature”:39.7,“Humidity”:13.0},“TempUnit”:“C”}

I tried to change DHT11 to DHT11-02 atc. but it doesnt work.
Can someone help me please ?

Try:
value_template: ‘{{ value_json.DHT11-02.temperature }}’

Excuse formatting and don’t just copy and paste this. Typing from mobile with doesn’t seem to allow full markdown.

1 Like

I am somewhat a novice at templates, but I think your problem is there.

So, I think the template should be:

value_template: ’ {{ value_json.DHT11-02.Temperature }}’

and

value_template: ’ {{ value_json.DHT11-02.Humidity }}’

1 Like

I tried it from both of you, and it doesnt work either :confused: , I added a relay to the board to make sure its connected and comunicate ok. The sensors shows up in main page but there is just -, and switch works.

switch:

  • platform: mqtt
    name: “Sonoff”
    state_topic: “stat/sonoff/RESULT”
    value_template: “{{ value_json.POWER }}”
    command_topic: “cmnd/sonoff/POWER”
    availability_topic: “tele/sonoff/LWT”
    qos: 1
    payload_on: “ON”
    payload_off: “OFF”
    payload_available: “Online”
    payload_not_available: “Offline”
    retain: false

Sensors

sensor:

Weather prediction

- platform: yr

- platform: mqtt
  name: "1"
  state_topic: "tele/sonoff/SENSOR"
  value_template: "{{ value_json.DHT11-02.Temperature }}"
  unit_of_measurement: "°C"
  device_class: temperature
- platform: mqtt
  name: "2"
  state_topic: "tele/sonoff/SENSOR"
  value_template: "{{ value_json.DHT11-02.Temperature }}"
  unit_of_measurement: "%"
  device_class: humidity
  
   
- platform: mqtt
  name: "3"
  state_topic: "tele/sonoff/SENSOR"
  value_template: "{{ value_json.DHT11-05.Temperature }}"
  unit_of_measurement: "°C"
  device_class: temperature
- platform: mqtt
  name: "4"
  state_topic: "tele/sonoff/SENSOR"
  value_template: "{{ value_json.DHT11.Temperature }}"
  unit_of_measurement: "%"
  device_class: humidity

13:04:39 MQT: tele/sonoff/STATE = {“Time”:“2019-03-11T13:04:39”,“Uptime”:“0T00:10:36”,“Vcc”:3.013,“SleepMode”:“Dynamic”,“Sleep”:50,“LoadAvg”:19,“POWER”:“OFF”,“Wifi”:{“AP”:1,“SSId”:“Tenda”,“BSSId”:“XX:8B:CA:XX:83:XX”,“Channel”:11,“RSSI”:100}}
13:04:39 MQT: tele/sonoff/SENSOR = {“Time”:“2019-03-11T13:04:39”,“DHT11-02”:{“Temperature”:27.1,“Humidity”:34.0},“DHT11-05”:{“Temperature”:23.4,“Humidity”:49.0},“TempUnit”:“C”}

Look here at Processing incoming data section:

You have to use square bracket notation for nested json.

1 Like

For those who have the same issue/question, this source:

tele/sonoff/SENSOR = {“Time”:“2019-03-11T16:09:23”,“DHT11-02”:{“Temperature”:29.5,“Humidity”:30.0},“DHT11-05”:{“Temperature”:23.9,“Humidity”:46.0},“TempUnit”:“C”}

Will have to be like this :

- platform: mqtt
  name: "3"
  state_topic: "tele/sonoff/SENSOR"
  value_template: "{{ value_json['DHT11-05']['Temperature'] }}"
  unit_of_measurement: "°C"
  device_class: temperature
- platform: mqtt
  name: "4"
  state_topic: "tele/sonoff/SENSOR"
  value_template: "{{ value_json['DHT11-05']['Humidity'] }}"
  unit_of_measurement: "%"
  device_class: humidity

Thank you !! I read this before, but I did not notice that it has to be between ’ symbols.

Hi all,
I thought that I had found the answer to my problem too but after plugging my esp-01 into the the serial connector and checking the interface it came up with this:

18:40:50 MQT: tele/Kitchtemp/SENSOR = {“Time”:“2019-05-05T18:40:50”,“DHT11”:{“Temperature”:null,“Humidity”:null},“TempUnit”:“C”}

I tried 2 other sensors which are fine on their own (after reconfiguring the .yaml each time) but do not work together.

My trouble is that the DHT11 does not have a suffix like yours. Could this be that it is just the esp-01 connected the serial interface without the DHT11 bridge or something else?

Below is the setup I am trying to get going:

Any pointers would be greatly appreciated.

Many thanks,

Kev

Did you set right pin in Tasmota ? Mine is D4 GPIO2
I have this one too, and my problem was, that I broke my sensor, and had to replace it.
The issue was, that they say you can use up to 12v, but in my case, the regulation was not there or did not work, so I fried my DHT11.

Hi @xxgmxx

I had them working individually (bit of a pain re-writing the .yaml and restarting as I’m on a pi zero and it takes ages to re-boot!) but they don’t play well together.

I’m struggling to find the individual labels for the dht 11’s (dht11-02 etc…) so that I can write it into the .yaml file.

I saw that @Binkoth has a solution but it only seems to be for temperature (see below), maybe I can separate the temp/humidity somehow and forget the json line as this is the part that seems to require the individual labels?

sensor guest_one:
name: “guest_one”
platform: mqtt
state_topic: “/sensor/ds18b20/d0c232”
unit_of_measurement: “°C”
expire_after: 300

Any guidance is greatly received as I am really just fumbling about with this trying to get it to work!

Thanks!

Try to check this, I still know almost nothing about HA :/, but I will try to provide my code, maybe it will help. Check the names, and the number after DHT11-xx ?? Mine is 02 and 05, I see one of your sensors is DHT11-02 and the other you must fill instead of DHT11-05, or if its the same, just try the code.

- platform: mqtt
  name: "1"
  state_topic: "tele/Kitchtemp/SENSOR"
  value_template: "{{ value_json['DHT11-02']['Temperature'] }}"
  unit_of_measurement: "°C"
  device_class: temperature
- platform: mqtt
  name: "2"
  state_topic: "tele/Kitchtemp/SENSOR"
  value_template: "{{ value_json['DHT11-02']['Humidity'] }}"
  unit_of_measurement: "%"
  device_class: humidity
  
   
- platform: mqtt
  name: "3"
  state_topic: "tele/Kitchtemp/SENSOR"
  value_template: "{{ value_json['DHT11-05']['Temperature'] }}"
  unit_of_measurement: "°C"
  device_class: temperature
- platform: mqtt
  name: "4"
  state_topic: "tele/Kitchtemp/SENSOR"
  value_template: "{{ value_json['DHT11-05']['Humidity'] }}"
  unit_of_measurement: "%"
  device_class: humidity

And also, ? (the names of the boards, like Kitchtemp, must be only for one board) ? I am not sure, but try every board with tasmota named different name like Kitchtemp1 Kitchtemp2. If you have two sensors with two ESP01 and both have the same name, it can cause errors. So, you will have to rename this in yaml code and tasmota and make every sensor unique.

state_topic: “tele/Kitchtemp1/SENSOR”
and
state_topic: “tele/Kitchtemp2/SENSOR”
if you named them Kitchtemp1 and Kitchtemp2.

Thanks,

I have plugged the esp01s (got 8 in total, 3 dht11s and 5 relays) into the serial connector and all im getting back is this:

I cant seem to find the individual names of the dht11s. Is there a simple way of retrieving this?

All the esp01s have different names btw so hopefully that is not the problem.

Thank you

:frowning: Theats weird, Are you sure, you have right GPIO ?

Here’s how my .yaml looks so far:

climate:
  • platform: generic_thermostat
    name: Living Room
    heater: switch.living_room_heater
    target_sensor: sensor.living_rm_temp
    min_temp: 15
    max_temp: 25
    ac_mode: false
    target_temp: 20
    cold_tolerance: 0
    hot_tolerance: 1.5
    min_cycle_duration:
    seconds: 5
    keep_alive:
    minutes: 3
    initial_operation_mode: “auto”
    away_temp: 5
    precision: 0.5

Sensors

sensor:

Weather prediction

  • platform: yr
    name: “Weather”

  • platform: mqtt
    state_topic: ‘tele/LRtemp/SENSOR’
    name: ‘Living Rm Temp’
    unit_of_measurement: ‘°C’
    value_template: ‘{{ value_json.DHT11.Temperature }}’

  • platform: mqtt
    state_topic: ‘tele/LRtemp/SENSOR’
    name: ‘Living Rm Humidity’
    unit_of_measurement: ‘%’
    value_template: ‘{{ value_json.DHT11.Humidity }}’

Switches

switch:

  • platform: mqtt
    name: ‘Living Room Heater’
    state_topic: ‘stat/LRheater/POWER’
    command_topic: ‘cmnd/LRheater/POWER’
    payload_on: ‘ON’
    payload_off: ‘OFF’
    qos: 2
    retain: true

  • platform: mqtt
    name: ‘Hall heater’
    state_topic: ‘stat/Hallheater/POWER’
    command_topic: ‘cmnd/Hallheater/POWER’
    payload_on: ‘ON’
    payload_off: ‘OFF’
    qos: 2
    retain: true

  • platform: mqtt
    name: ‘Dining heater’
    state_topic: ‘stat/Diningheater/POWER’
    command_topic: ‘cmnd/Diningheater/POWER’
    payload_on: ‘ON’
    payload_off: ‘OFF’
    qos: 2
    retain: true

  • platform: mqtt
    name: ‘Kitchen heater’
    state_topic: ‘stat/Kitchheater/POWER’
    command_topic: ‘cmnd/Kitchheater/POWER’
    payload_on: ‘ON’
    payload_off: ‘OFF’
    qos: 2
    retain: true

  • platform: mqtt
    name: ‘Bathroom heater’
    state_topic: ‘stat/Bathheater/POWER’
    command_topic: ‘cmnd/Bathheater/POWER’
    payload_on: ‘ON’
    payload_off: ‘OFF’
    qos: 2
    retain: true

The gpio’s must be ok as they all work on their own (dht 11 is gpio 2 and the relays are gpio 0, relay 1i for the esp01)

I really am stumped!

I am sorry, probably I gave you wrong advice with DHT11-02/05 because you use one DHT for one board yo It should be without the others numbers I hope
- platform: mqtt
name: “1”
state_topic: “tele/name of your board/SENSOR”
value_template: “{{ value_json.DHT11.Temperature }}”
unit_of_measurement: “°C”
device_class: temperature
- platform: mqtt
name: “2”
state_topic: “tele/name of your board/SENSOR”
value_template: “{{ value_json.DHT11.Humidity }}”
unit_of_measurement: “%”
device_class: humidity

And you can see the temperature in tasmota ? It will be weird if it sends empty MQTT if the tasmota has the values.
I tryed now to take the board and add it like new device, I just flashed added mqtt set GPIO and added the line in HA and it worked :roll_eyes:

I can see the temp in tasmota (web server) and it appears on the HA overview as a temperature dial as living room temp. The living room temp relay clicks on and off according to the desired temp setting too but I am not having any luck repeating this with the other sensor-relay setup.

The aim is to put a sensor in each room to control a heater so that each room has a comfortable climate and not just reliant on 1 central sensor.

The house varies quite dramatically from room to room so I think this would be necessary.

Achieving it on the other hand…!

Oh I see. But it should be as the code you already used.
Just copy the code and just rename “name” you want and “state_topic” for the tasmota name of other board, the code doesnt change.
There must be just some stupid mistake I hope.