0

I'm reading on the DFRobot website to implement this Voltage divider: Analog Voltage Divider SKU: DFR0051

void setup() 
{ 
  Serial.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;
      Serial.println(val);
      delay(1000);
}

Where does 40.92 come from? And even when printing only VAL it's 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. being measured? If it's divided by 5, why do you not multiply by 5 anywhere?

  • 1
    1023/25=40.92 – gre_gor Jun 27 '18 at 15:42
  • How is this Uno code? An Uno has no SerialUSB. – gre_gor Jun 27 '18 at 15:44
  • Im using it on another board, sam thing. just replae SerialUSB with Serial.... – Harry Jun 27 '18 at 17:19
  • Then why is it tagged arduino-uno? – gre_gor Jun 27 '18 at 18:40
1

The unit measures a maximum voltage of 25v. When the measured voltage is 25v it divides it by 5 to present a maximum of 5v to the Arduino. That is measured as a value of 1023 by analogRead(). If you divide 1023 by 40.92 you get 25.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.