I have calibrated my NANO this way to measure an unknown DC voltage (range: 0 to 5V) --
1. NANO is powered by USB.
2. Measure DC Voltage by DVM at 5V point of NANO, and it is found as 4.82V.
3. Measure DC Voltage by DVM at 3V3 point of NANO, and it is found as 3.25V.
4. I have executed the following sketch to get the ADC value by --
(a) Connecting 4.82V at analog channel 0 (A0). The ADC value is 1023. This is point A(4.82, 1023).
(b) Connecting 3.25V at analog channel 0 (A0). The ADC value is 688. This is point B(3.25, 688).
(c) The unknown point is C(v, x) = C(unknown DC voltage, ADC value).
void setup()
{
Serial.begin(9600);
analogReference(DEFAULT);
}
void loop()
{
int x = analogRead(A0);
Serial.print(highByte(x), HEX);
Serial.println(lowByte(x), HEX);
Serial.println(x, DEC);
delay(2000);
}
5. From the readings of Step-4, I have found the following equation for v(unknown voltage) in terms of x(the ADC value) --
v = 0.0047*x + 0.0256.
6. The execution of the following sketch shows the unknown voltage on the Serial Monitor at 2-sec interval.
void setup()
{
Serial.begin(9600);
analogReference(DEFAULT);
}
void loop()
{
float v = (float) 0.0047 * analogRead(A0) + 0.0256;
Serial.println(v, 2);
delay(2000);
}
7. Testing Procedures
(a) Upload the sketch of Step-6 into NANO.
(b) Connect 4.82V point (5V -point of NANO) at Ch-A0; the Serial Monitor shows: 4.83V
(c) Connect 3.25V point (3V3-point of NANO) at Ch-A0; the Serial Monitor shows: 3.26V