Sonoff Basic with DFRobot SEN0308 Moisture sensor

Hi

I am trying to use the GPIO3 pin on a Sonoff Basic to capture the readings from a DFRobot SEN0308 Moisture sensor but need some help with the YAML file configuration on ESPHome integration in Home Assistant.

I have the Sonoff working fine as a simple relay switch in ESPHome integration already so I know the device is working fine.

The next step is to connect the moisture sensor to the spare breakout pins on the Sonoff with:

vcc → vcc
gnd - > gnd
data → TX (which is on Pin GPIO3)

I need to know what to add to my YAML file to get the readings from GPIO3. Here is what I have tried:

# Get output from soil moisture sensor on pin 3
output:
  - platform: gpio
    id: "Irrigation_Sonoff"
    pin:
      number: GPIO3

If I understand correctly this will collect the moisture readings on GPIO3.
Then I try to set up the sensor with:

sensor:
  - platform: gpio
    output: "Moisture_Sensor"
    pin: GPIO3
    name: "mosture"

But this is giving a “x” when I try to put into my YAML file.

Any suggestions?

Regards
Gavin

if you hover over the x it should give a hint to the problem, I’m guessing it is just a formatting error.

Strange…it no longer gives me a hint when I hover over it. It used to though.

ok it seems to be back now. It says … Platform cannot be found: ‘sensor.gpio’

You need to use the adc component instead of gpio. You also need to use the an anolog input pin usually A0

sensor:
  - platform: adc
    output: "Moisture_Sensor"
    pin: A0
    name: "moisture"

Thanks @Mikefila . The Sonoff basic does not expose the A0 pin, so in the end I bought an ESP32 and hooked it up to the A0 pin…all working fine!