QTPY S2 - Analog 0 is at 3.3v when set as potentiometer input
tyeth opened this issue · 10 comments
-EDIT- <TLDR> It's part of the specification, the first analog input (A0) has (and requires in the datasheet) a 10k pullup resistor, which will affect things if unaware. see comment
Heya, was using potentiometer to represent a soil sensor. and the input was always maxed except when I hardwired it to ground.
turns out that A0 is always 3.3v, but choosing A1-3 works as expected
Device ID if useful
https://io.adafruit.com/tyeth/devices/qtpy-esp32s214035171
could well be my fault, but I haven't tested another similar device yet, be a slow progress one sorry
Hrm, A0 is mapped to D18 both in the arduino-esp32 variant and the WipperSnapper definition.
Could you test this via an Arduino Sketch, or CircuitPython Sketch, to rule out WipperSnapper being the culprit. Something like:
int analogPin = D18; // potentiometer wiper (middle terminal) connected to analog pin A0
// outside leads to ground and +5V
int val = 0; // variable to store the value read
void setup() {
Serial.begin(9600); // setup serial
}
void loop() {
val = analogRead(analogPin); // read the input pin
Serial.println(val); // debug value
}
Just to note, it may have been an artifact of arduino-esp32 v2.0.8, in v2.0.9 (latest) this fixed an issue with second use of analogWrite being ignored:
espressif/arduino-esp32#8137
-Edit- err no, read NOT WRITE
@brentru You'll be somewhat relieved to hear the behaviour is the same with latest wippersnapper on a new-ish qtpy. A0 (listed as A18 in serial) always registers 65k when set as potentiometer. Using A1 (listed as A17 in serial) is fine. It's a capacitive soil sensor remember.
In arduino land, with the code you wrote (i had to change D18 to A0 and A1) then A0 gave 8192 with nothing connected (floating) and same with my soil sensor connected (no matter with or without wet soil or held in fingers).
The A1 input gives between 4 and 5 hundred floating, and 7600 with no soil (unheld) and 3100 when held.
What do you get with a qtpy s2(or s3 probably) and A0 or A1 floating and then with something to read?
In arduino land, with the code you wrote (i had to change D18 to A0 and A1) then A0 gave 8192 with nothing connected (floating) and same with my soil sensor connected (no matter with or without wet soil or held in fingers).
From the Learn Guide...
"Note that A0 has a 10K pullup to 3.3V - we're not sure why but this is required by the hardware design notes for the ESP32-S2 (see Fig 1)."
Because of this, we may want to hide the A0 pin from a user or set it to output-only.
Well that explains it. Yeah I wonder if a note could be added for individual pins, so for any non pull-up or adc differential pairs, or unexpected things like this, rather than hiding functionality. Maybe when you select a pin the name has an asterisk and once selected the UI could show a label or link to notes (or rely on product link)
@lorennorman See above, maybe something to implement.
@tyeth For now, we can either hide the A0 pin and close the issue or keep this issue open for others. Either works!
Happy either way! I've edited the first post to provide an immediate answer.