Nodemcu dht22 more than one

Hello,
I want more than one Nodemcu and the DHT22 sensor to measure in different rooms.
I´ve flashed the nodemcu and they work. Now I have the problem that i can´t configure the yaml file so that two or more Nodemcus work at the same time.

this ist the code I used for one Node:

sensor:
platform: mqtt
name: “Temperature”
state_topic: “sensor/temperature”
qos: 0
unit_of_measurement: “ºC”

sensor 2:
platform: mqtt
name: “Humidity”
state_topic: “sensor/humidity”
qos: 0
unit_of_measurement: “%”

Thanks!!

You probably want to alter the topic published from each unit and publish to i.e.

room1/sensor/temperature
room1/sensor/humidity

room2/sensor/temperature
room2/sensor/humidity

or something like that.
Then adjust your sensor definitions accordingly in the name and state_topic part.

Hi @vergo,

One thing. Which firmware has installed your nodemcu?

Because depend about firmware, then mqtt works in one side or other.

thanks

Yes, I do the same as @winck describes. And you should name your sensors like this:

- platform: mqtt
  name: "Room 1 Temperature"

- platform: mqtt
  name: "Room 2 Temperature"

Hello,
thanks for your help. I solved the problem and did it like that:

sensor 1:
  platform: mqtt
  name: "Garden Temperature"
  state_topic: "garden/sensor/temperature"
  qos: 0
  unit_of_measurement: "ºC"

sensor 2:
  platform: mqtt
  name: "Garden Humidity"
  state_topic: "garden/sensor/humidity"
  qos: 0
  unit_of_measurement: "%"
  
sensor 3:
   platform: mqtt
   name: "Work Temperature"
   state_topic: "work/sensor/temperature"
   qos: 0
   unit_of_measurement: "ºC"
   
sensor 4:
   platform: mqtt
   name: "Work Humidity"
   state_topic: "work/sensor/humidity"
   qos: 0
   unit_of_measurement: "%"

Is there any way to get the code shorter?

Sure, there is no need to create a new sensor platform for each sensor. Just add them to sensor: You can find an exampe here: https://home-assistant.io/docs/configuration/devices/ And qos is 0 by default so you could remove that as well.

Thanks! Now it looks like this:

sensor:

  • platform: mqtt
    name: “Garden Temperature”
    state_topic: “garden/sensor/temperature”
    unit_of_measurement: “ºC”
  • platform: mqtt
    name: “Garden Humidity”
    state_topic: “garden/sensor/humidity”
    unit_of_measurement: “%”
  • platform: mqtt
    name: “Work Temperature”
    state_topic: “work/sensor/temperature”
    unit_of_measurement: “ºC”
  • platform: mqtt
    name: “Work Humidity”
    state_topic: “work/sensor/humidity”
    unit_of_measurement: “%”

If you update your post using a code block or the </> button we really know what your code looks like :wink:

Hello again, I´ve updated to hass.io. Now my sensors don´t work. My sonoffs work well. I used the same syntax as in the old confi.yamil.

Any idea?

Best Regards
Ingo