I'm either getting old or losing my marbles as I've done this before, I'm trying to create a simple voltmeter does not need to be supper accurate.
The trouble I'm seem to be having is battery reads 3.991 with my fluke meter(i don't expect to get this accurate with 10bits of arduino) but the readings that are been calculated are showing 6.04. My pro mini is running at 3.3V.
So I have a resistor divider set up With R2 to ground is 3.9K and R1 is 10K, I have been playing around with these values but for now these are the values I'm using.
1. What is the bias/excitation voltage for R1-R2 network -- 4V from Battery? 2. Include one of the following two codes in the setup() function of your sketch to decide the full scale of the ADC; also, answer to the questions of the comment field. (I don't know as I have no pro mini model.)
analogReference(INTERNAL); //how much is connected -- 1.1V or 3.3V or 5V?
analogReference(DEFAULT); //how much is connected -- 3.3V or 5V?
3. To carry out paper-pencil calculation, the above information is needed.
It would also be nice to know, which device is used. If it is a standard Arduino, you may get the actual reference/supply voltage with the "secret voltmeter" like this:
That is the direct connection to the battery.
What do you get at the junction of the potential divider that feeds A0?
Does the measured value, at A0, agree with the potential divider equation?
What raw ADC value do you get?
What calculated value do you get?
Sorry, yeah my pro mini is running on 3.3V,
Thanks guys I’ll try your suggestions never thought about the reference is 5v and it has just dawned on me that I’m multiplying by 5 and nit 3.3v.
My pro mini is running off 4.2v lithium battery stepped down to 3.3v and have A0 been fed from the resistor divider
If you want to monitor your Battery voltage, then you have to follow these steps: (Assume Vref = 5V) 1. With 4.2V Battery connected, compute input to ADC; Vin = 1.17 V 2. Vout (output voltage proportional to Battery)
= (5/1023)xanalogRead(A0)x(4.2/1.17)