I need help with my circuit, I’ve hit a road block and not sure how to go about it. It might be an easy fix or might be more complicated, I am hoping someone out there could possible help me solve this problem, or give me an idea in how to go about it.
Battery = 12v lead acid
DC input = 13v or 14v
I have attached a print screen of the wiring setup I have.
I can measure the voltage of both battery and DC input; separately however the battery and DC input are connected in parallel. Which means I can’t measure them separately and this is the issue I face?
to sum up the project, I need to basically be able to tell when the DC input has been taken out, however since the battery and input are parallel, as soon as I disconnect the input I’m reading the input for the battery not a 0V
below is my code it is simple, i have also connect an lcd screen (not important)
/* Arduino Tutorial: Learn how to use an LCD 16x2 screen
More info: http://www.ardumotive.com/how-to-use-an-lcd-dislpay-en.html */
//Include LCD library
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
float input_voltage = 0.0;
float temp=0.0;
float r1=101000.0;
//float r1=98900.0;
float r2=10000.0;
float r3=101000.0;
//float r1=98900.0;
float r4=10000.0;
float input_voltage2 = 0.0;
float temp2=0.0;
void setup() {
Serial.begin(9600);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
//lcd.print("Hello World!");
//pinMode(led, OUTPUT);
}
void loop() {
int analog_value = analogRead(A0);
temp = (analog_value * 5.0) / 1024.0;
input_voltage = temp / (r2/(r1+r2));
int analog_value2 = analogRead(A1);
temp2 = (analog_value2 * 5.0) / 1024.0;
input_voltage2 = temp2 / (r4/(r3+r4));
if (input_voltage2 < 0.1)
{
input_voltage2=0.0;
}
if (input_voltage < 0.1)
{
input_voltage=0.0;
}
if(input_voltage == 13){
Serial.println("ok");
}
lcd.setCursor(0, 1);
lcd.print("B=");
lcd.print(input_voltage);
lcd.print(" V=");
lcd.print(input_voltage2);
delay(300);
}
If anyone can help me, I will be grateful
Thank you.