Go Down

### Topic: [SOLVED] Analog read from PSU is higher than actual value (Read 605 times)previous topic - next topic

#### Bjerknez

#30
##### Oct 06, 2020, 07:24 am
Try the same code and the exact same setup with an Arduino too. See if that gives correct readings.

(This might be a very unpopular opinion, but in my humble nooby opinion the only thing ESP is good at is being cheap. It's an unreliable toy. It's not worth spending your time figuring out why it's giving out weird reading unless an Atmel chip is doing it)
I think you may have right. I feel the meassurement where more correct with Arduino Nano. The PSU was a little off, but all my batteries show right value in serial.

With ESP32 all readings from batteries was way off, but my PSU was spot on....

I'm just confused.

#### raschemmel

#31
##### Oct 06, 2020, 07:35 amLast Edit: Oct 06, 2020, 07:39 am by raschemmel
Quote
The voltage on the A0 pin is exactly 3V. Meassured with multimeter.
And what is the UUT (unit under test ) voltage with a meter ?
What is R1 ?
R2 ?

(which is 12k and which is 3.3k) ?

If R2=3.3k,R1=12k,

and UUT = 12V,
.'.

12* 3300/(12000+3300)=2.58V

Given above divider,
If UUT is UNK(X)

X=3V/0.21568 (3300/15300)
X=13.9V
UUT=13.9V

What is UUT voltage when A0 voltage =3V ?

BTW,
Pourduino is right. Always have at least two references, otherwise your data is unreliable.

#### Bjerknez

#32
##### Oct 06, 2020, 07:53 am
And what is the UUT (unit under test ) voltage with a meter ?
What is R1 ?
R2 ?

(which is 12k and which is 3.3k) ?

If R2=3.3k,R1=12k,

and UUT = 12V,
.'.

12* 3300/(12000+3300)=2.58V

Given above divider,
If UUT is UNK(X)

X=3V/0.21568 (3300/15300)
X=13.9V
UUT=13.9V

What is UUT voltage when A0 voltage =3V ?

BTW,
Pourduino is right. Always have at least two references, otherwise your data is unreliable.

#### raschemmel

#33
##### Oct 06, 2020, 08:11 amLast Edit: Oct 06, 2020, 08:47 am by raschemmel
You gave us your code but not your raw data. Do you or do you not know how to capture serial output
using PUTTY ?

If not, can you please tell us the raw data value reported for a battery voltage of 9V when the voltage on
the A0 pin is 3V ?

FYI, you still didn't tell us the Vcc pin voltage on the ESP32 when the A0 voltage was 3V (or the raw data
value reported for a 3V input.

Where is your voltage divider code ?

3V * 2700[/(100000+27000)]=0.637795

Does your ESP32 report voltage or raw analog data counts ?

Quote
Reading an analog value with the ESP32 means you can measure varying voltage levels between 0 V and 3.3 V. The voltage measured is then assigned to a value between 0 and 4095, in which 0 V corresponds to 0, and 3.3 V corresponds to 4095.
You haven't shared your raw data, and it is meaningless without the ESP32 Vcc voltage.

#### Bjerknez

#34
##### Oct 07, 2020, 06:16 am
I keep it short.

I switched back to Wemos D1 Mini, added 1.2Mohm before Analog input, and tweaked code a bit. I did not understand every thing i did and my technical english is not wery good, but i can say that now it finally works!

Batteries and PSU shows all spot on in serial and i'm happy with that.

ESP32 i never get to work regards to this. Crappy thing for usage like that i think.

#### johnerrington

#35
##### Oct 07, 2020, 06:48 am
I'm trying to help. If I find your question interesting I'll give you karma. If you find my input useful please give me karma (I need it)

#### Wawa

#36
##### Oct 07, 2020, 07:26 am
ESP32 > ratiometric A/D > good for ratiometric sources like potentiometers, bad for voltage measurements.
ESP8266 > absolute A/D > good for voltage measurements, bad for ratiometric sources.
So the ESP8266 should be much better for what you're doing.

See if 0volt input gives an A/D value of zero.
The ESP8266 I tested had an offset of about 8. (A/D range was a strange 8-1024!!!, not 0-1023).
If you have an A/D offset, then you should subtract that from the returned A/D value first, before using a multiplication factor to calculate voltage.
Code: [Select]
`float voltage = (analogRead(A0) - offset) * 0.01486; // calibrate`
Leo..

#### johnerrington

#37
##### Oct 10, 2020, 08:56 am

@ raschemmel
Quote
How exactly is the signal 'rapidly changing ' if it's a battery or a PSU ? That makes no sense.
My point exactly.  You can't compare the battery and PSU readings becasue the PSU may not be 100% DC.

Otherwise how do you explain battery readings are all fine and PSU not?

Remeber the ADC on the arduinos is a S/A ADC with saple&hold, while digital multimeters more likely use a simple integrating ADC that would give different results.
I'm trying to help. If I find your question interesting I'll give you karma. If you find my input useful please give me karma (I need it)

#### raschemmel

#38
##### Oct 10, 2020, 10:54 am
I think multimeters use RMS

Go Up