• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

ADC2 problem

Q&A Forum › ADC2 problem
0 Vote Up Vote Down
ltorres_81 asked 3 years ago

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.

11 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

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

0 Vote Up Vote Down
ltorres_81 answered 3 years ago

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

0 Vote Up Vote Down
Steph answered 3 years ago

Hi Luis,
You’ll probably find some hints here:
https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/adc#class-adc

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

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

0 Vote Up Vote Down
Steph answered 3 years ago

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:

  • https://www.notion.so/SAM32-6b7e8ca318ff49418eec16e975d98f5d
  • https://circuitpython.org/board/sam32/ 

Even Adafruit’s Huzzah32 is not supported for CircuitPython… strange.

Sara, do you have more information about porting CircuitPython to ESP32?

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

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

0 Vote Up Vote Down
Steph answered 3 years ago

Yes… but CircuitPython runs on the SAMD51!
On the SAM32 board, the ESP32 is only a coprocessor that provides WiFi and Bluetooth…

0 Vote Up Vote Down
Steph answered 3 years ago

Good news about ESP32-S2!

Seen on Adafruit’s blog :

You will be able to use our popular TinyUSB free-and-open USB stack with these chips, to unlock USB CDC/HID/MIDI/MSC/and more

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!

0 Vote Up Vote Down
Rui Santos Staff answered 3 years ago

Those are great news! Really looking forward to have time to try it

0 Vote Up Vote Down
Steph answered 3 years ago

More detailed information can be found here… 😉

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Thanks 😀

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] SMART HOME with RPi, ESP32, and ESP8266 (version 1.2) March 8, 2023
  • [eBook Updated] ESP32-CAM Projects (version 1.3) January 7, 2023

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2023 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.