Arduino car battery voltmeter

I made an voltmeter for my car battery. But It's work so strange. If the multimeter mesaure 12,6 V my variable (vin) is 11,9 and if it mesaure 14,4 V my variable storage 12,25. What made I wrong?

bool VoltMeterTimerState =false;
int VoltMeterTimer;
float value;
float vout;
float vin;
String vinString;

void setup()
{

}

void loop() {
  //delay(30);
  if(VoltMeterTimerState==false)
  {
    VoltMeterTimer = millis();
    VoltMeterTimerState=true;
  }
  if(millis()-VoltMeterTimer>1000)
  {
  value = analogRead(A2);
  vout = (value * 5.0) /1024.0;
  vin = vout / (1.0/(1.0+4,7.0)); //1 kohm and 4,7 kohm resistors
  vinString = String(vin);
  VoltMeterTimerState=false;
  
  }
}
1.0+4,7.0)

What's that comma?

That's not how you spell "1.0 + 4.7"

The VoltMeterTimerState variable and it's code check are redundant - it's just excess baggage since you don't use it anywhere else... all you need is:

void loop() {

  if(millis()-VoltMeterTimer>1000)
  {
  value = analogRead(A2);
  vout = (value * 5.0) /1024.0;
  vin = vout / (1.0/(1.0+4,7.0)); //1 kohm and 4,7 kohm resistors
  vinString = String(vin);
  VoltMeterTimer = millis();  
  }
}

I think there is something else wrong. In one case you get 94.44% of the true reading and in the other you get 85.07%. I think your Arduino's '5V' power supply is not well regulated. How is the Arduino being powered? Have you checked the Arduino voltage at different input voltages?

Sorry it's 4.7

I use 7809 linear regulator. Linear regulator Input is a car battery.

Did you put on the required capacitor(s)? Does the regulator on the Arduino give you a rock-solid 5.0V for all battery voltages?

Does the 7809 get hot? What other hardware is attached to the Arduino 5V? Display, etc.?

Yes, I put 2 capacitors.
7809-Basic-Circuit

I attached Opel Astra f TID Display.

Where did you connect it? How did you connect?
What voltage source is the display powered from?
How much current does the display draw?
Give a connection diagram.

I turned it on the arduino for 1 hour. I have found that the varieble's value dropped lower and lower. Why?

Hi,
I think we need a concise circuit diagram of your project.
Include power supply, ALL hardware and label components and pins please.

A picture of your project will help as well.

Are you powering everything from the 9V regulator or 5V pin of the , what model Arduino?
Is the regulator getting hot?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

Without seeing your hardware, my guess is that something that is temperature-sensitive is changing temperature.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.