Hi,
I trying to mesure the voltage of my 12V battery with arduino , for that I’m using a LM317 DC-DC Voltage Regulator Step Down Module with those features:

• Output Current: 1.5A (min), 2.2A (typ)
• Input-output voltage differential (VI-VO): 40Vdc (max)
• Adjustable output voltage range: 1.2 ~ 37V
• Operating temperature: -55 Celsius ~ +150 Celsius
• Current output: 1.5A
• Voltage Input: 4.2 ~ 40 V
• Operating temperature: 0 Celsius ~ 125 Celsius
• Characteristic frequency: 100MHz
• Module size: 35.6 mm x16.8 mm
• Input Method: VIN input is positive, GND Input Negative
• Output: VOUT output positive, GND output negative

I adapted to have 4.5V at the output of the module.
I attached the diagram of the wirning. For the arduino part I used the analogRead, like this

``````void setup()
{
Serial.begin(9600);
}

void loop()
{
delay(5000);
}
``````

Normaly I should had a fixed value aroud 922, But I got differents and variables value in arduino serial monitor, I didn’t get what the cause of this problem, if someone have an idea?

Your diagram doesn't show a ground connection between your power supply and your Arduino - do you have one?

You need to have the grounds of the Arduino and the LM317 -ve output connected.

But that isn't measuring the battery input voltage to the regulator. The point of a regulator is that the output will stay constant until the input gets too low for the regulator to maintain it.

To measure a 12V battery voltage you just need a simple 2-resistor voltage divider.

Steve

Oww, my mistake, how stuped of me, I didnt connected with Arduino Gnd. I did use a voltage divider with this battery, but I'm just testing, I planing to use for my projet a bigger battery and I think the voltage divider won't be optimistic. Thank you so much.

You can't measure a battery's voltage through a regulator. Just look up what a regulator does if you don't know why.

You can measure any battery's voltage through a two-resistor voltage divider, regardless of the battery voltage and capacity. You just have to adjust the resistor values to the actual voltage of your battery.