Closed tyeth closed 6 months ago
I tried to reproduce this on a QT PY ESP32 Pico with the following code.py:
import analogio
import board
import time
potentiometer = analogio.AnalogIn(board.A2)
while True:
print("Hellorld!",potentiometer.value)
time.sleep(10)
I got the same error after a soft reboot:
soft reboot
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
Traceback (most recent call last):
File "code.py", line 6, in <module>
espidf.IDFError: Requested resource not found
However the code.py wouldn't run on hard reset but gave a timeout error:
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
Traceback (most recent call last):
File "code.py", line 6, in <module>
espidf.IDFError: Operation timed out
Code done running.
It turns out that at least on the QT PY, the the AnalogIn object for board.A2 doesn't have a "value" function:
>>> dir(analogio.AnalogIn(board.A2))
['__class__', '__enter__', '__exit__', 'deinit', 'reference_voltage']
None of board.A0 - board.A4 (all ADC2 pins) have value methods. board.A5 and board.A6 (associated with ADC1) have value methods but when used with my test code.py don't cause the "resource not found" error. board.A7 doesn't appear to be associated with either ADC1 or ADC2 and returns an "Invalid pin" error when passed to AnalogIn.
I'm not sure what any of this means but on the Itsy Bitsy it looks like A3,A4 and A5 (and D32, D33) use ADC1 so for a test, if possible, you might try connecting the potentiometer up to one of those pins.
That could explain something. I had it written initially for a QTPY S2, and thought I'd seen valid values, but to be honest can't be sure. I did just realise at the pub I'm probably using analogio or the pin incorrectly.
On Sun, 24 Mar 2024, 18:10 RetiredWizard, @.***> wrote:
I tried to reproduce this on a QT PY ESP32 Pico with the following code.py:
import analogioimport boardimport timepotentiometer = analogio.AnalogIn(board.A2)while True: print("Hellorld!",potentiometer.value) time.sleep(10)
I got the same error after a soft reboot:
soft reboot
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable. code.py output: Traceback (most recent call last): File "code.py", line 6, in
espidf.IDFError: Requested resource not found However the code.py wouldn't run on hard reset but gave a timeout error:
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable. code.py output: Traceback (most recent call last): File "code.py", line 6, in
espidf.IDFError: Operation timed out Code done running.
It turns out that at least on the QT PY, the the AnalogIn object for board.A2 doesn't have a "value" function:
dir(analogio.AnalogIn(board.A2)) ['class', 'enter', 'exit', 'deinit', 'reference_voltage']
None of board.A0 - board.A4 (all ADC2 pins) have value methods but when used with my test code.py don't cause the "resource not found" error. board.A7 doesn't appear to be associated with either ADC1 or ADC2 and returns an "Invalid pin" error when passed to AnalogIn.
I'm not sure what any of this means but on the Itsy Bitsy it looks like A3,A4 and A5 (and D32, D33) use ADC1 so for a test, if possible, you might try connecting the potentiometer up to one of those pins.
— Reply to this email directly, view it on GitHub https://github.com/adafruit/circuitpython/issues/9079#issuecomment-2016890431, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTBZ47W5OVD5YRDVSAUUH3YZ4JH5AVCNFSM6AAAAABFFZ7UJ6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJWHA4TANBTGE . You are receiving this because you authored the thread.Message ID: @.***>
Possibly related to #9086 but unlikely as probably user error and a reasonable enough error message. -Edit- Originally closed as no longer using that hardware (mcu+potentiometer) so unable to continue.
I was curious if there was an explanation for why ADC2 association analog pins did not have value
attributes. If that's a limitation of the ESP32 module, I wonder if the pins should be renamed (assuming they can be used for digital I/O).
Possibly related to #9086 but unlikely as probably user error and a reasonable enough error message. Closing
This is probably an issue. A simpler example like the one @RetiredWizard is how to know for sure.
It turns out that at least on the QT PY, the the AnalogIn object for board.A2 doesn't have a "value" function:
I think this is a different bug around how dir()
figures out what is on an object.
This is strange. I installed 9.0.1 on QT Py ESP32 Pico, and used @RetiredWizard's test program, and it's not breaking for me:
Adafruit CircuitPython 9.0.1 on 2024-03-27; Adafruit QT Py ESP32 PICO with ESP32
>>>
soft reboot
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
Hellorld! 37076
Hellorld! 8797
Traceback (most recent call last):
File "code.py", line 7, in <module>
KeyboardInterrupt:
Code done running.
Press any key to enter the REPL. Use CTRL-D to reload.
soft reboot
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
Hellorld! 37414
Hellorld! 4150
Traceback (most recent call last):
File "code.py", line 7, in <module>
KeyboardInterrupt:
Code done running.
Press any key to enter the REPL. Use CTRL-D to reload.
soft reboot
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
Hellorld! 37017
To create the soft reboots, I was saving files to the device while code.py was running using web workflow.
OK, this is a hardware issue, specific to the ESP32. The ESP32 has two ADC's, ADC1 and ADC2. Only ADC2 is connectable to pins . (EDIT: this is wrong) But it is also used when WiFi is in use. So really, you can only use ADC2 when WiFi is off.
Quoting from https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf, section 29.3.1
... If Wi-Fi module is using the SAR ADC2, users can not measure the analog signal from the pins using SAR ADC2. After SAR ADC2 is released by Wi-Fi, users can use SAR ADC2 normally.
In practice, ADC2 is not available.
We should document this in a Limitations: section in AnalogIn
. Changing title to reflect that.
Also note:
https://esp32.com/viewtopic.php?t=30102#p104184
On the ESP32-S2 and newer chips, ADC can be used together with Wi-Fi, although usage by Wi-Fi has priority over the usage by software. So you may occasionally get an error code while getting an ADC sample, in which case you have to retry sampling.
CircuitPython version
Code/REPL
Behavior
Description
Saving a code change causes soft reset, then I'm assuming fails to bind pin presumably due to still being registered in use
Additional information
No response