Saturday, January 23, 2016

Arduino Car Battery Monitor

In this circuit, a resistor divider circuit with an effective divider ratio of 3.78.

(100K+56K)/56K = 3.78

This has a measurable voltage range of 0-18.9 volts, this take care of the potential voltage spike when the battery is on charge or at ignition.

The 22uF capacitor is to reduce the spike measured by Arduino.



#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

const int sensorPin = A0;
const float DivderRatio = 3.78;


void setup(){
  Serial.begin(9600);
  lcd.begin(16,2);
  lcd.print("KTM 690 ENDURO");   
  lcd.setCursor(0,1);
  lcd.print("Volt =");
}

void loop() {
  
  int sensorValue = analogRead(sensorPin);
  float sensorVoltage = (sensorValue/1024.0) * 5.0;
  float vcc = sensorVoltage * DivderRatio;
  Serial.print("Sensor Value=");
  Serial.print(sensorValue);
  Serial.print("\t volt=");
  Serial.print(sensorVoltage);
  Serial.println("\t Vcc=");
  Serial.println(vcc);
  lcd.setCursor(11,1);
  lcd.print(vcc);
  delay(150);
}

Saturday, January 16, 2016