Multiple adc sensors on ESP32 for this sensor

Hi everybody,

I have multiple of these analog capacitive soil moisture sensors. Will this multiplexer work with them?

The reason I ask is because I have tried using (digital) multiplexers in the past (for different sensors), and some sensors were not compatible with them. The sensors themselves worked, the multiplexers worked, but ESPHome wouldn’t let me use the multiplexer pins to access said sensors.

I’d order the multiplexers and some more Soil Moisture Sensors right away if I knew they were compatible. But I don’t want to prepare a large project just to realize it won’t work when assembling / flashing it. (I need one ESP32 with 7 of those sensors, and two ESP32 with 5 each).

Can any of you confirm from experience that the multiplexers will be compatible with those sensors in ESPHome?

Thank you in advance for your help :slight_smile:

You don’t need multiplexer for 5 sensors on common esp32 devboard. Adc1 has 6 pins.

Yeah but ESPHome would not let me declare more than one of them as analog sensors. I thought multiple should work. But as soon as I declared a second one, the code block would get red underlining and the project would not be compiled.

I could even change the PINs. Idk which ones I just, but for the sake of example, let’s say 18 and 20 were adc-compatible PINs. If I made one sensor with 18, the next one would not accept 20. If I deleted the second one and changed 18 TO 20, it would work. But yeah, always just one single PIN seemed to have been allowed… unless I missed some configuration step?

Just compiled on ESP32:

sensor:
  - platform: adc
    pin: GPIO34
    id: adc_1
  - platform: adc
    pin: GPIO35
    id: adc_2

No issues.

Do not see Your code examples to have some ideas.

What board you have?
Esphome documentation says: “You can only use as many ADC sensors as your device can support.”

Sorry, forgot to paste it. Here is the relevant part

sensor:
  - platform: adc
    pin: 17
    id: moisture_sensor_00
    name: "Soil Moisture 00"
    unit_of_measurement: "%"
    update_interval: 300s
    filters:
  # Sensor dry around 0.825 Volt, sensor wet around 0.425 Volt. Volts are were flickering
        - calibrate_linear:
            - 0.0 -> 0.0
            - 1.0 -> 100.0
  - platform: adc
    pin: 18
    id: moisture_sensor_01
    name: "Soil Moisture 01"
    unit_of_measurement: "%"
    update_interval: 300s
    filters:
  # Sensor dry around 0.825 Volt, sensor wet around 0.425 Volt. Volts are were flickering
        - calibrate_linear:
            - 0.0 -> 0.0
            - 1.0 -> 100.0

When I read your reply, I thought the issue was resolved and that I forgot id… but just checked and realized, both do have this. So I don’t see what could cause this error.

The error, btw:

@Karosm I am currently using the esp32-s2-saola-1; but then I tested different other esp32 boards in my configuration, just to see whether the same error would still be there, and it is… for example, I used nodemcu-32s (the usual board I use for ESPHome), and the error is identical to the screenshot above.

You have to use 6 pins of adc1.
Gpio32 … 39

As @Karosm points out: You have to use GPIO 32-39 on adc1, which has 7 channels. You can’t use adc2 if you’re using WiFi.

See more here:

Please take a look at these screenshots; I took out the filter so it’s easier to see…


If I use 35 and 36, it says 36 will work and 35 won’t. Then when I use 31 and 35, it will accept 35 without an issue, but cause an error for 31.

Go for 38 and 31, 31 will work. Switch them around, 38 will work.


Using just the number, or adding GPIO in front of it, won’t make a difference:

Here 38 works, 35 won’t.

This is why I thought I’d need an adc multiplexer… it seems like while certain pins would work, they won’t work if another pin is also declared…?

I tried another ESP32 board now, and it seems like pin 36 and 39 work. I cannot test it atm but it looks promising that ESPHome does not throw an error.

Please attach esp board definition with sensors.
Cause pins depens on board.

GPIO35 & GPIO36 work fine together on esp32dev.

But NOT on ESP32S2 (f.e. esp32-s2-saola-1) - it have ADC connected to different set of pins: