ArduinoGeneral

Voltage devider sensor

userHead Account cancelled 2018-06-27 19:01:06 2054 Views1 Replies
Hi there,

I'm reading on the dfrobot website to implement this Voltage divider:

https://www.dfrobot.com/wiki/index.php/ ... U:_DFR0051


void setup()
{
SerialUSB.begin(9600);
}
void loop()
{
float val;
float temp;
val=analogRead(2);//This divider module will divide the measured voltage by 5, the maximum voltage it can measure is 25V.
temp= val/40.92;
val=(float)temp;
SerialUSB.println(val);
delay(1000);
}

where does 40.92 come? And even when printing only VAL its something like 210 and I'm not sure what this is supposed to be. I don't get how to get the ACTUAL voltage of the battery etc been measured? If its divided by 5, why do you not multiply by 5 anywhere?
2018-06-28 16:40:29 Because the val here is the analog value read from the analog pin, and its range is 0~1023, and the maximum voltage it could read is 25V, 1023/25=40.92 userHeadPic robert.chen