You have no resistors hooked to A0 ?
I using the same resistors from above. Voltage divider
R1 = 120K, R2 = 33K
Right now on the Voltage Output Im getting 4
and on the Raw Im getting 1453
If your raw is 1453, then it is probably reading well. Now how do you convert that with math to 5V ?
Did you test the voltage with a volt meter. It may not really be 5v (probably a little off).
I normally do a test, and calibrate using the map() function.
Based on recent info, the input impedance of the analog input is sorta low. You may be better using some resistors a bit lower that you list.
using this.
Yes, I measured with voltmeter and is giving 5.0 v.
Im using a variable power source and on the sourse is giving the same number.
use this and you are good to go
const float voltsPerBit = 3.3 / 4095; // Calculate volts per bit of ADC reading
const float ratioV = (120000 + 33000) / 33000; //Calculates to 4.636363
void setup()
{
Serial.begin(9600);
}
void loop()
{
int Vin = analogRead(A0);
float rawVolts = Vin * voltsPerBit; //Calculate voltage at A0 input
float batteryVolts = rawVolts * ratioV;
Serial.print("Voltage ");
Serial.print(batteryVolts);
delay(3000);
}
Also,
for education purposes, this is a better way to induce delayed polling. Not the best but better.
const float voltsPerBit = 3.3 / 4095; // Calculate volts per bit of ADC reading
const float ratioV = (120000 + 33000) / 33000; //Calculates to 4.636363
unsigned long old_time = millis();
void setup()
{
Serial.begin(9600);
}
void loop()
{
if(millis() - old_time >= 3000){
int Vin = analogRead(A0);
float rawVolts = Vin * voltsPerBit; //Calculate voltage at A0 input
float batteryVolts = rawVolts * ratioV;
Serial.print("Voltage ");
Serial.print(batteryVolts);
old_time = millis();
}
}
Now It works, but is a little off. Im getting this.
Voltage 4.69 Raw 1.174.691455
I normally calibrate mine using map().
Don’t know whats going on. Now if I increase the voltage to 10.0 v , the output difference in the spark is bigger. Is showing 8.37 V.
May be the fact that the analogue input is sorta low impedance, and your resistors are a bit to large. I really don’t know tho.
Did the raw reading reach its max?
No. reading Raw 2599
did you get the 5 volt reading pretty accurate, and then it went asque testing the 10v range?
No. At 5.0V, I got this Voltage 4.69
At 10.0 V, I getting this 8.37
Oh, I see. You seem hesitant to try the map() function. Have you never used it before, or you just don’t like it?
to be honest, I don’t know how to do that )-; Sorry. Im new to this.
We are all new at some point. I am still about there.
I think it will be helpful to you. If you check the documentation it probably tells more than I could, but basicly
I think you can specify that 1322 raw = 4.5 volts, and that 3763 = 9.9 volts, then as the raw varies, the volts will follow, even it it not within the ranges that you specified. If you want to check it out, and have questions, I will try to answer.
Thank You. I would give a try and see how I handle it. (-:
I normally test the value about 10% above the lowest I expect, and about 10% below the highest I expect, and measure the voltage (or temperature) or whatever, and put that into the map() function.
Good luck,
if you have more questions, just ask.