Micro Python ADC Class pin assignments
-
In dealing with the ADC Class function I have the following questions;
I have 2 prototype designs, 1 based on LoPy and the other on Gpy.
On the Gpy design I am trying to read the Battery Voltage (range between 5.5v and 3.3v) through a 1M ohm and 47K ohm resistor divider connected to ADC1_CH7 (GPIO35 ESP32 pin 11).Can I use the ADC Class Function to read that channel? My code would be;
adc = machine.ADC()
BatterySensorPin = adc.channel(pin='P11', attn=machine.ADC.ATTN_11DB)
BatterySensorPinVoltage = BatterySensorPin.voltage()My concern is that when I read the ADC Class documentation it says valid pins are 13-20. Is that a documentation error? If that is correct how are the other available ADC pins read? As an example, in my case how would I read ADC1_CH7 (GPIO35 ESP32 pin 11)?
-
@guyc ADC 1_7 is GPIO35, and addresses with 'P17' or 'G31'. The 'Pxx' numbers are not the physical chip numbers are not the GPIO numbers are not the 'Gxx' numbers. If you look at the LoPy pinout sheet, they are all printed side-by-side. https://docs.pycom.io/gitbook/assets/lopy-pinout.pdf
P.S.: Better ignore the 'Gxx' numbers. They are printed on the expansion boards and a constants source of confusion. -
Thanks for clearing that confusion. I assume that is true for the other functions like the Pin Function?
-
@guyc Yes, it is. In the repository there are tables which set the Gxx, GPIOxx and Pxx numbers side by side. For Lopy, it's here: https://github.com/pycom/pycom-micropython-sigfox/blob/Dev/esp32/boards/LOPY/pins.csv
For the other boards the tables are in the respective paths.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login