How to know the adc pins and how to address in ESPHOME in a Wemos_d1_mini32

Dears,

Theoretically I have a Wemos_d1_mini32 board. And I want to use the following adc pins: adc2_7 and adc2_2 according with the following scheme that I find in internet:

According wiht the image there are 16 adc pins available for this board…
But is impossible to select in ESPhome. Without errors I only can select the following adc pins: A0, A3, A4, A5, A6, A7 with the following code:

  - platform: adc
    pin: A3
    unit_of_measurement: 'V'
    name: "vientobateria"
    update_interval: 1s
    attenuation: '11db'
    accuracy_decimals: 5
    filters:
      - multiply: 1.27
#      - lambda: if (x < 0.001) return 0; else return x * 1.27;

But these pins I can’t physically locate them…

Please I need help to know really how many adc pins I have and how to select in ESPHOME.

Thanks,

Jose

If you want to use, for example, the adc2_7 pin, you can try defining the pin
pin: GPIO17
That might work.

Dear pepe59,

If I try to use this sentence, ESPHOME shows an error, pin with the syntax GPIO don’t work, only with pin: A0 (A before the number the adc platform in this board seems to work, but only with the pins above

image

If I validate the code with you suggestion:

INFO Reading configuration /config/esphome/toldo.yaml...
Failed config

sensor.adc: [source /config/esphome/toldo.yaml:59]
  platform: adc
  
  ESP32 doesn't support ADC on this pin.
  pin: GPIO17

You are best to use the GPIO label.

You did not try to define a pin:
pin: 27
The Last Chance

I cannot see how the pinout diagram in post one can be right. GPIO17 is not an ADC pin.

See also Configuration Types — ESPHome

Yes, you are right that GPIO17 is marked 2x.
Once as IO17 and the second time as IO27.
I assume that IO27 will be GPIO27 and that should be ADC.

I agree, a small but important typo.

So you have that for real?

This 16 adc pins are theoretical on the other hand because all adc_2 channels are not usable when wifi is active :signal_strength:

  • Since the ADC2 module is also used by the Wi-Fi, only one of them could get the preemption when using together, which means the adc2_get_raw() may get blocked until Wi-Fi stops, and vice versa.

https://web.archive.org/web/20220615125719/https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/adc.html#adc-limitations

In the end what’s left are the 8 channels with adc_1. For esphome you have to define the gpio pins which are written in the pin out you posted (including errors).

In case this post magically disappears you can always find it again in the waybackmachine

That is a good point @minnie (and is also mentioned in the random nerds page I pointed to). However I didn’t click to this issue in the thread. Thanks for pointing it out.

Not working also…:

INFO Reading configuration /config/esphome/toldo.yaml...
Failed config

sensor.adc: [source /config/esphome/toldo.yaml:59]
  platform: adc
  
  ESP32 doesn't support ADC on this pin.
  pin: 27

Well you shouldn’t use it anyway. See How to know the adc pins and how to address in ESPHOME in a Wemos_d1_mini32 - #9 by minnie

OK,

With your help my understand is that I only we can use the adc in channel 1 (because channel 2 is not working when WIFI is active), then, there are 6 adc pins, and these adc pins are the A0, A3, A4, A5, A6 and A7 and the code with ESPHOME is “pin: A0” directly, it’s the only code thhats works, code with “pin: GPIO36” or “pin: 36” dont’ works, only with the A before the pin number.

Thanks to all.

pin: GPIOxx is always supported in esphome.

ESPHome always uses the chip-internal GPIO numbers. These internal numbers are always integers like 16 and can be prefixed by GPIO. For example to use the pin with the internal GPIO number 16, you could type GPIO16 or just 16.

Most boards however have aliases for certain pins. For example the NodeMCU ESP8266 uses pin names D0 through D8 as aliases for the internal GPIO pin numbers. Each board (defined in ESPHome section) has their own aliases and so not all of them are supported yet. For example, for the D0 (as printed on the PCB silkscreen) pin on the NodeMCU ESP8266 has the internal GPIO name GPIO16, but also has an alias D0. So using either one of these names in your configuration will lead to the same result.

I implemented a project using a mini d1 ESP32 and ADCs yesterday.

My yaml file used pin 32, 33, 34 35

  - platform: adc
    pin: 35

Worked for me.
Was hoping to get more than 4 ADCs, but 4 was just enough for the project.

There is any way to turn off the internal LED?, it’s always ON (not blinking) and drain my bateries. In the log th info says:

[18:42:11][C][status_led:019]: Status LED:
[18:42:11][C][status_led:020]:   Pin: GPIO22

I tried to turn off with the following sentences, but don’t woks, continues always ON:

status_led:
  pin:
    number: GPIO22

and

status_led:
  pin:
    number: GPIO22
    inverted: true

and

status_led:
  pin:
    number: GPIO22
    inverted: false

Are you sure it’s the internal LED on GPIO22? You can disable it by just deleting the block with the status_led: or comment it out like this:

#status_led:
#  pin:
#    number: GPIO22

But depending on the model of your esp32 it might have a “always on” power led which only can be snipped off but not disabled by software.

Dear tabularasa,

Originally, the code don’t have this section, and the LED is always ON with the log with:

[18:42:11][C][status_led:019]: Status LED:
[18:42:11][C][status_led:020]:   Pin: GPIO22

If the log says GPIO22 I understand thay is this pin that control the LED, then, I put the codes with 3 variations in order to try if I can put the LED OFF, but nothing of the tree variations works.

Take out the whole status_led stanza.

Dear nickrout

Without this code is the same that in my first attempt, and always the LED is ON…