How operate two sensors using different gpio pins on esp8266 using esphome

I have two esp8266s running on esphome measuring soil humidity and air temperature I would like to use one esp8266 with both sensors on the same esp8266 but I don’t know how to write a YAML file to do this. Any help would be appreciated

Depends what the sensors are as to how they are configured. Post the working YAML config for both devices, properly formatted as code so it looks like this:

esphome:
  name: "garage-sensor"
  platform: ESP8266
  board: d1_mini

This is a useful resource for pin selection:

esphome:
 name: test03
 friendly_name: test03


esp8266:
 board: nodemcu

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "8MV+4ktgsJKcAWp5FmZYKNGoorVgxHGSPTXg0egbN7E="

ota:
 - platform: esphome
   password: "738748e54c103a5827829cf4d7e6c1e5"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

 
 # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Test03 Fallback Hotspot"
    password: "U6cS0fsm3i47"

captive_portal:
sensor:
  platform: dht
 
  pin: GPIO4
  temperature:
    name: "Living Room Temperature"
    accuracy_decimals: 2
  humidity:  
    name: "Room Humidity"
  update_interval: 60s
    

esphome:
name: test1
friendly_name: test
platform: ESP8266

board: nodemcu

Enable logging

logger:

Enable Home Assistant API

api:
encryption:
key: “/PIXC5GXrfpntz25avChMS/O0ZZ0Wx+KQmjyp1zTKSk=”

ota:

  • platform: esphome
    password: “aaa9f3e9a9f16beaca5b76a4a8a9a118”

wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password

Enable fallback hotspot (captive portal) in case wifi connection fails

ap:
ssid: “Test1 Fallback Hotspot”
password: “PKiwoKBHiFia”

captive_portal:

sensor:
platform: adc
id: moisture_voltage
name: “Soil Moisture Voltage”
pin: A0
accuracy_decimals: 2
filters:

  • sliding_window_moving_average:
    window_size: 15
    send_every: 15

Just copy one sensor to another boards yaml

esphome:
 name: test03
 friendly_name: test03


esp8266:
 board: nodemcu

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "8MV+4ktgsJKcAWp5FmZYKNGoorVgxHGSPTXg0egbN7E="

ota:
 - platform: esphome
   password: "738748e54c103a5827829cf4d7e6c1e5"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

 
 # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Test03 Fallback Hotspot"
    password: "U6cS0fsm3i47"

captive_portal:
sensor:
  platform: dht 
  pin: GPIO4
  temperature:
    name: "Living Room Temperature"
    accuracy_decimals: 2
  humidity:  
    name: "Room Humidity"
  update_interval: 60s

  platform: adc
  id: moisture_voltage
  name: "Soil Moisture Voltage"
  pin: A0
  accuracy_decimals: 2
  filters:
    - sliding_window_moving_average:
         window_size: 15
         send_every: 15

Careful: because you didn’t format the second one properly, so-called “smart quotes” have made it in:

  name: “Soil Moisture Voltage”

should be:

  name: "Soil Moisture Voltage"

and I think you want to separate the sensors as a YAML list:

sensor:
  - platform: dht 
    pin: GPIO4
    temperature:
      name: "Living Room Temperature"
      accuracy_decimals: 2
    humidity:  
      name: "Room Humidity"
    update_interval: 60s

  - platform: adc
    id: moisture_voltage
    name: "Soil Moisture Voltage"
    pin: A0
    accuracy_decimals: 2
    filters:
      - sliding_window_moving_average:
           window_size: 15
           send_every: 15
1 Like

Good eyes! :+1:

Thanks guys. i have been busy with other projects and eating and sleeping. Afte fighting YA<L files and following your guidance i have gert an installation.
Can you suggest a YAML editor and a tutorial on yaml

I can’t suggest anything, the best editor for yaml I have used is the one inside Esphome dashboard.