Hi everyone,
I’m having some problems with the ADC component. I’m using an Wemos ESP32-S2 mini (That with the purple board):
And I want to set up sampling on three ADC sensors, for GPIO7, 8 and 9. When I configure the ADC component by default (1 sample), it compiles without a problem. But when I add the "samples: " entry, it refuses to compile.
This is the yaml that compiles (Note that I cannot add the “samples” entry):
esphome:
name: nevera
friendly_name: nevera
esp32:
board: esp32-s2-saola-1
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "+-----="
ota:
password: "-------"
wifi:
networks:
- ssid: !secret wifi_ssid3
password: !secret wifi_password3
manual_ip:
static_ip: 192.168.1.19
gateway: 192.168.1.1
subnet: 255.255.255.0
dns1: 192.168.1.1
dns2: 8.8.4.4
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Nevera Fallback Hotspot"
password: "----------"
captive_portal:
web_server:
port: 80
text_sensor:
- platform: wifi_info
ip_address:
name: Direccion IP
ssid:
name: Nome da rede
scan_results:
name: Redes Dispoñibles
sensor:
- platform: adc
pin: GPIO7
name: "Tension ADC1"
attenuation: 11db
id: ADC1
update_interval: 1s
- platform: adc
pin: GPIO8
name: "Tension ADC2"
update_interval: 1s
attenuation: 11db
id: ADC2
- platform: adc
pin: GPIO9
name: "Tension ADC3"
update_interval: 1s
attenuation: 11db #Segun a web de espresif, desde 0 a 2500 mV
id: ADC3
Notes:
I use GPIO7, 8 and 9 because the recomended 32-39 raises an error:
The documentation lets me use this pins on an ESP32-S2, with the ADC1:
Analog To Digital Sensor — ESPHome
This is what I get when I write the “samples” entry:
I have also read that if I am using auto gain, samples are ignored. But I am setting the gain to a value, so this should not be the problem. Or am I missynderstanging something?
I unploaded screenshots of the error because I don’t know if it makes sense to upload a faulty code, does it?
Thank your everyone for your help!
Karosm
(Karosm)
June 23, 2024, 8:05pm
2
Difficult to follow…
Ok, your pins should be ok, 32-39 are not adc pins on your board.
On your yaml I don’t see line “samples: 10”, but in your error there is…
board: esp32-s2-saola-1
Have you tried some other boar definition ?
ps. when prototyping, use wroom 32 board. After everything works, try to adapt for “weird” boards if you need to.
Hi @Karosm
Thank you a lot for reading!.
Karosm:
Difficult to follow…
Sorry for that. I edited the post a little, I hope it helps.
Yes. I uploaded the code that compiles. Should have I posted the code that gives me an errror? If so, I will post it.
Nope, I didn’t know that I could change the boards. I will try with the Wroom32 as you suggest.
Thank you again!
EDIT:
I tried to change the board definition. When I set the board name to “nodemcu-32s” (The wroom 32 as mencioned here:
And I can’t compile, because GPIO definition is different. So I tried with the “lolin_s2_mini” as suggested here:
And I get the same error.
If it helps, here is the faulty code (with the new board definition):
esphome:
name: nevera
friendly_name: nevera
esp32:
board: lolin_s2_mini
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key:
ota:
password:
wifi:
networks:
- ssid: !secret wifi_ssid2
password: !secret wifi_password2
# O 3 é Cacharrada
- ssid: !secret wifi_ssid3
password: !secret wifi_password3
manual_ip:
static_ip: 192.168.1.19
gateway: 192.168.1.1
subnet: 255.255.255.0
dns1: 192.168.1.1
dns2: 8.8.4.4
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Nevera Fallback Hotspot"
password: "7DXF1upJDny3"
captive_portal:
web_server:
port: 80
text_sensor:
- platform: wifi_info
ip_address:
name: Direccion IP
ssid:
name: Nome da rede
scan_results:
name: Redes Dispoñibles
sensor:
- platform: adc
pin: GPIO7
name: "Tension ADC1"
attenuation: 11db
id: ADC1
update_interval: 1s
samples: 10 ##### HERE IS THE PROBLEM#####
- platform: adc
pin: GPIO8
name: "Tension ADC2"
update_interval: 1s
attenuation: 11db
id: ADC2
- platform: adc
pin: GPIO9
name: "Tension ADC3"
update_interval: 1s
attenuation: 11db #Segun a web de espresif, desde 0 a 2500 mV
id: ADC3
Thanks!
Karosm
(Karosm)
June 24, 2024, 9:37am
4
Board looks good
Gpios look good
Still the same “samples is an invalid option” error?
Yes, it still has the error:
Hi
I got rid of this using one ads1115
If you need accurate values, I recomend this.
1 Like
I just tried it on an ESP32-C3 and got no errors, but as I do not have an ESP32-S2, the following might be the reason:
Support for ESP32 variants such as the S2, S3 and C3 is still in development and there could be issues.
I recommend opening an issue here: Issues · esphome/issues · GitHub
Hi @zenzay42
I have it open ritgt now.
opened 06:47PM - 05 Jul 24 UTC
### The problem
Hi everybody.
I think that I found a bug on the ESP-S2. I … know that saying that can sound a little pretentious for my side, but I have no other explanation. If I am wrong, please tell me so I can learn. Thank you so much.
# Problem:
On an ESP-S2, I can add one adc component (as shown here https://esphome.io/components/sensor/adc.html). But when I try to set up the "samples" configuration variable, ESPhome tells me that [samples] is an invalid option for [sensor.adc].
I am using an ESP-S2 mini, the one with the purple board. I set the board type as a "lolin_s2_mini"
![540fd75e61e261d3f9a98c1f30ec45923e0fba99_2_500x500](https://github.com/esphome/issues/assets/93524123/c66777c3-a595-4876-b732-86324d991a80)
### Which version of ESPHome has the issue?
2024.3.2
### What type of installation are you using?
Docker
### Which version of Home Assistant has the issue?
2024.4.3
### What platform are you using?
ESP32
### Board
lolin_s2_mini
### Component causing the issue
adc
### Example YAML snippet
```yaml
esphome:
name: nevera
friendly_name: nevera
esp32:
board: lolin_s2_mini
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "-"
ota:
password: "-"
wifi:
networks:
- ssid: !secret wifi_ssid2
password: !secret wifi_password2
manual_ip:
static_ip: 192.168.1.19
gateway: 192.168.1.1
subnet: 255.255.255.0
dns1: 192.168.1.1
dns2: 8.8.4.4
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Nevera Fallback Hotspot"
password: "-"
captive_portal:
web_server:
port: 80
text_sensor:
- platform: wifi_info
ip_address:
name: Direccion IP
ssid:
name: Nome da rede
scan_results:
name: Redes Dispoñibles
sensor:
- platform: adc
pin: GPIO7
name: "Tension ADC1"
attenuation: 11db
id: ADC1
update_interval: 1s
samples: 10
```
### Anything in the logs that might be useful for us?
```txt
I don't have a log because I can't compile
```
### Additional information
![imaxe](https://github.com/esphome/issues/assets/93524123/93ed59a7-fa9e-4bb0-b404-8112ad46a800)
I oppened this issue because of this note:
> Note
>
> Support for ESP32 variants such as the S2, S3 and C3 is still in development and there could be issues.
https://esphome.io/components/esp32.html
Thank you all for your time. You are doing a great job with ESPhome!
(And sorry if I did something wrong 😥)
I will update info as soon as possible.
Thank you for your time!
Well, this is embarrasing. I was using an old version of Esphome.
I updated to 2024.6.6 and now it works perfectly
Thanks to everybody!!!