Hi everyone,
I'm doing a project where I want to read the voltage from a sensor. See Figure 1 below for a sketch of the premiss.
I simply want to read the voltage over the 40kΩ resistor "R1". I have no control over the resistance of R4 and R1, they're the ones I want to measure.
With the equipment I had at hand I came up with what I thought would be a solution, see Figure 2. Which brings me to my two questions:
- I thought that since the resistance of R3 is about 1/6th of R2 => that R3 would be about a 1/6th of R1. Resulting in a ratio of about 6.
Multiplying the voltage read at A0 times that would give me the voltage of R1.
But instead I ended up having to multiply the voltage read at A0 with 7.94 to get back the voltage over R1, why is that? What am I missing?
- Using my multimeter I can measure that the voltage over R1 is 7,94 times greater than R3. But the voltage of A0 in the serial monitor isn't the same as the one shown on the multimeter.
The analog input reads a voltage about 10% higher than the multimeter, and the arduinos read voltage varies up an down by a couple steps.
Comparatibly when I connected one of the 3,3v pins to an anlog input it would give a stable and precise value.
Where is the 10% coming from and why is the voltage varying?
Code:
const int analogInputPins[] = {A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15};
float analogInputValues[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
const float voltPerUnit = 0.0049;
const float voltageScaling = 7.94;
void setup() {
//Starts the serial comunication that will be used for debugging.
pinMode(ledStatus, OUTPUT);
Serial.begin(9600);
}
void loop() {
//get the the analog values from the analog input pins, and scale it back to get the original voltage.
for (int i = 0; i < 1; i++) {
analogInputValues[i] = analogRead(analogInputPins[i]) * voltPerUnit * 0.893401 * voltageScaling;
delay(40);
}
for (int i = 0; i < 16; i++) {
Serial.print("Analog input ");
Serial.print(i);
Serial.print(" = ");
Serial.print(analogInputValues[i]);
Serial.print("\n");
}
}
