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 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.



  • Thanks for clearing that confusion. I assume that is true for the other functions like the Pin Function?



  • @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.


Log in to reply
 

Pycom on Twitter