I’m working with microphyton and ESP32 but I have had a problem to access into ADC2 (I need to capture some data).
I wonder if someone could help me with that.
Hi.
Can you specify what is the problem exactly? Otherwise, it is very difficult to find out what might be wrong.
Note that ADC2 pins cannot be used when Wi-Fi is used.
Regards,
Sara
Hello,
For example,
I’m using GPIO35, GPIO13, GPIO34, GPIO27, GPIO32, GPIO26, GPIO33, GPIO25; but with the next code I only can get data from GPIO35, GPIO34, GPIO32, GPIO33 because those are part of ADC1, the otherones are ADC2. So, I don’t konw if there is another way to get all the information with just one code like Arduino code (It works, no matter ADC1 or ADC2).
from machine import Pin, ADC
from time import sleep
pot = ADC(Pin(34))
pot.atten(ADC.ATTN_11DB) #Full range: 3.3v
while True:
pot_value = pot.read()
print(pot_value)
sleep(0.1)
Thanks,
Luis
Hi Luis,
You’ll probably find some hints here:
https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/adc#class-adc
Hi Luis.
After a bit more research, it seems that MicroPython firmware doesn’t allows you to set ADC2 pins as ADC pins. It only allows you to read ADC1 pins. See the documentation here: http://docs.micropython.org/en/latest/esp32/quickref.html#adc-analog-to-digital-conversion
The documentation that Stéphane shared is about another distribution of MicroPython (LoBo distribution). That firmware allows you to use ADC2, but with slight differences in the code. If you want to use that, you need to install that MicroPython distribution firmware in your board.
You can find more about the LoBo MicroPython distribution here: https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo
I hope this helps.
Regards,
Sara
I didn’t really look into the use of Python with microcontrollers, but I know that there is a reference on the subject (apart from MicroPyhton), developed by Adafruit : CircuitPython.
Unfortunately, I’m looking for it, but I have the impression that the ESP32 architecture is not supported as such. The only compatible board I could find integrates 2 chips, a SAMD51 and an ESP32, which is called SAM32:
Even Adafruit’s Huzzah32 is not supported for CircuitPython… strange.
Sara, do you have more information about porting CircuitPython to ESP32?
Hi Stéphane.
I haven’t experimented with CircuitPython yet.
But accordingly to that page, it seems that the Huzzah32 is not supported. Only the SAM32 board that contains an ESP32 chip.
I don’t know much about this subject.
Regards,
Sara
Yes… but CircuitPython runs on the SAMD51!
On the SAM32 board, the ESP32 is only a coprocessor that provides WiFi and Bluetooth…
Good news about ESP32-S2!
Seen on Adafruit’s blog :
We’re also planning on porting CircuitPython to this chip, it would make for a great set of easy-to-use IoT products. We really think this chip is going to be the ‘winner’ for embedded IoT projects where cost, power and size are most important.
Pythonistas… Keep an eye on it!