Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analog input voltage can be 3.3V #5020

Merged
merged 5 commits into from
Aug 14, 2018
Merged

Analog input voltage can be 3.3V #5020

merged 5 commits into from
Aug 14, 2018

Conversation

SarenT
Copy link
Contributor

@SarenT SarenT commented Aug 9, 2018

According to this tutorial and my personal test with my Amica, 1.0V delivers 320 and 3.3V delivers 1024 at 10-bit resolution. I guess 3.3V is possible.

According to this tutorial and my personal test with my Amica, 1.0V delivers 320 and 3.3V delivers 1024 at 10-bit resolution. I guess 3.3V is possible.
@devyte
Copy link
Collaborator

devyte commented Aug 9, 2018

The voltage range that can be applied to the ESP8266 ADC is 0-1.0V. If you go above 1V you will fry the electronics.
Some boards incorporate a voltage divider* so that a range of 0-3.3V applied to the board ADC pin scales down to 0-1V on the chip ADC. Some boards don't have this divider and break out the chip ADC directly to the board pin.
So the voltage range allowed on the board ADC pin depends on the board.

*many users don't know about, or at least don't know the implications of, this internal voltage divider, and apply a voltage to the board pin from another external voltage divider. This interacts with the board divider and can produce apparently wrong readings from the ADC.

@SarenT
Copy link
Contributor Author

SarenT commented Aug 9, 2018

Can we write it in a way that people need to be careful when trying to read ADC? I was looking around but this issue isn't addressed at all and I was confused that my readings at 1.0V are 320. As a safe method, one can start reading 1.0V to make sure that they don't fry with 3.3V. If the readings are 1/3 of 1024 -> then they can be sure about 3.3V.

Added warnings.
@duncan-a
Copy link

duncan-a commented Aug 9, 2018 via email

@SarenT
Copy link
Contributor Author

SarenT commented Aug 9, 2018

In my case, I didn't find the schematics and many new electronic hobbyists might need further explanation/warnings to avoid fatal mistakes.

@duncan-a
Copy link

duncan-a commented Aug 9, 2018 via email

Copy link
Collaborator

@devyte devyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SarenT go ahead and rephrase as discussed.
The suggestion for unknown boards to start with 1V is actually not too bad. Users won't have a 1V power source, but they should have a pot. They can power it with 3.3V and measure the midpoint output with a voltmeter to make sure it's below 1V, then connect it to the ADC pin. If the ADC reading is of the order of 1000, then there's no divider on the board, and max voltage is 1V.
OTOH, if the reading is about 1/3 of 1024, then the divider is there and max voltage is 3.3V.

@@ -42,7 +42,7 @@ either to read voltage at ADC pin, or to read module supply voltage
(VCC).

To read external voltage applied to ADC pin, use ``analogRead(A0)``.
Input voltage range is 0 — 1.0V.
Input voltage range is 0 — 1.0V or 0 — 3.3V.

To read VCC voltage, use ``ESP.getVcc()`` and ADC pin must be kept

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There also should be mentioned, that many boards (it means basicaly all boards which are not bare esp) has voltage divedr in theirs design, so ESP.getVcc() will produce totaly wrong results - possible resistor connected to A0 pin has to be removed before using this function

@devyte devyte merged commit cbcefa7 into esp8266:master Aug 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants