good day everyone
I am working in one project (smart battery charger ) . my issue I need to display in LCD 2 status of
battery (when it's connected or not connect ) . I try to read the input pin A1 witch one connected
with ACS712 current sensor , it's not working for me , but when i read pinA0 voltage measure , no issue
with that working fine . for me no need to read when voltage available , i
need to check if battery connected or not (current is there or not ) . my code :
#define BAT_V A0
int read_adc(int PIN)
{
int sum = 0;
int temp;
int i;
for (i = 0; i < AVG_NUM; i++)
{
temp = analogRead(PIN);
sum += temp;
delayMicroseconds(50);
}
return (sum / AVG_NUM);
}
void battery_situation(){
conn_battery = (read_adc(BAT_V) * 4.88) / 10000;
not_conn_battery = conn_battery ;
}
void acs712_RE_V(){
ValeurLue = analogRead(A1);
tension = ValeurLue * (5.0 / Integer_values);
courant = (tension - AcsOffset) / Sensibl;
}
void loop() {
up:
battery_situation();
if (conn_battery > 0.0) {
lcd.clear();
while (conn_battery > 0.0) {
battery_level();
battery_percent();
acs712_RE_V(); //to measure current
battery_status();
battery_level_icon();
lcd_display()
if (not_conn_battery == 0.0) {
lcd.clear();
break;
}
}
}
lcd.setCursor(0, 0);
lcd.print("connect Battery");
goto up;
}
}