Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ESP32] Read from ADC2 Pins #6219

Closed
jdjjm opened this issue Jul 2, 2020 · 8 comments
Closed

[ESP32] Read from ADC2 Pins #6219

jdjjm opened this issue Jul 2, 2020 · 8 comments

Comments

@jdjjm
Copy link

jdjjm commented Jul 2, 2020

Is there any way of accessing ADC2 Pins?
Even with WiFi off you cannot set up an ADC on any of the ADC2 Pins as you get the error
ValueError: invalid Pin for ADC

Looking at the esp32 port for machine_adc.c it seems only adc1 pins are supported. Is there any way to use ADC2?

@peterhinch
Copy link
Contributor

Please raise this in the forum rather than in the MicroPython bug tracker.

@jdjjm
Copy link
Author

jdjjm commented Jul 2, 2020

Okay thanks

@jdjjm jdjjm closed this as completed Jul 2, 2020
@jdjjm
Copy link
Author

jdjjm commented Jul 2, 2020

Is there a reason machine_adc only exposes ADC 1? I understand most uses case will have WiFi running however there are times when this isn't the case so what is the reason for not having them accessible? It seems a little restrictive to me.

@jdjjm jdjjm reopened this Jul 2, 2020
@WayneKeenan
Copy link

FYI: There is a workaround for getting ADC2 values whilst WiFi is running.
Also, an Espressif dev said (albeit a long time ago) "There is a fix coming for ADC2 and WiFi soon :)"

Ref: espressif/arduino-esp32#102 (comment)

@dpgeorge
Copy link
Member

dpgeorge commented Jul 2, 2020

This is simply not implemented (mainly because with WiFi enabled it's not possible to use ADC2). Also there's currently no standard way to select an ADC peripheral to use for a given pin, but in this case I think it could just automatically select ADC2 if a pin was given that only supported ADC on ADC2.

Summary: it can be implemented, feel free to make a PR for it.

jonathanhogg added a commit to jonathanhogg/micropython that referenced this issue Sep 14, 2021
Rework the ADC implementation to use the micropython#4213 API (mostly) adding 
support for calibrated voltage readings and the ADC2 block. Resolves 
micropython#6219. Part-resolves micropython#3943.
jonathanhogg added a commit to jonathanhogg/micropython that referenced this issue Sep 15, 2021
Rework the ADC implementation to use the micropython#4213 API (mostly) adding 
support for calibrated voltage readings and the ADC2 block. Resolves 
micropython#6219. Part-resolves micropython#3943.
jonathanhogg added a commit to jonathanhogg/micropython that referenced this issue Sep 15, 2021
Rework the ADC implementation to use the micropython#4213 API (mostly) adding 
support for calibrated voltage readings and the ADC2 block. Resolves 
micropython#6219. Part-resolves micropython#3943.
jonathanhogg added a commit to jonathanhogg/micropython that referenced this issue Sep 15, 2021
Rework the ADC implementation to use the micropython#4213 API (mostly) adding 
support for calibrated voltage readings and the ADC2 block. Resolves 
micropython#6219. Part-resolves micropython#3943.
@dpgeorge
Copy link
Member

Support for ADC2 was implemented in 63438a3

@MauroDiamantino
Copy link

Support for ADC2 was implemented in 63438a3

But, do I have to disable Wifi to use it?

@dpgeorge
Copy link
Member

dpgeorge commented Feb 2, 2022

But, do I have to disable Wifi to use it?

I'm not sure, you'll need to read the ESP datasheet, or just try it out.

leifbirger pushed a commit to leifbirger/micropython that referenced this issue Jun 14, 2023
Rework the ADC implementation to follow the improved ADC/ADCBlock API.
This adds support for calibrated voltage readings and the ADC2 block.  The
ADC API is backwards compatible with what it was before this change.

Resolves micropython#6219.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants