Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Read 12V battery charge
#1
Hello,
I am powering the board with a solar panel connected to a charge controller and a 12V battery. I have installed the ESPHome system on the board connected to Home Assistant, and it is working perfectly.

I would like to read the battery charge level using the analog sensor A1, but I know that this sensor reads a maximum of 5V, so the 12V from the battery (13V when fully charged) needs to be reduced. For this, I tried using a voltage divider circuit with two resistors, one 200KOhm and one 100KOhm. I connected the GND and A1 terminals of the analog sensors across the 100KOhm resistor, with the GND terminal going to the negative terminal of the battery.

+12V (Battery)
      |
      |
    [R1]  200kOhm
      |
      +------ A1
      |
    [R2]  100kOhm
      |
      |
    GND (Battery -)

The configuration in ESPHome is:

Code:
sensor:
  - platform: adc
    pin: 36
    name: 'Battery Charge - Voltage'
    id: battery_charge_voltage
    accuracy_decimals: 5
    device_class: "voltage"
    state_class: "measurement"
    unit_of_measurement: "V"
    update_interval: 5s
    filters:
    - multiply: 24.6

This configuration gives me readings of values below 0, which I had to multiply by 24.6 to get battery voltage values close to what I read using a voltmeter connected to the battery terminals.

Additionally, the values read are not stable, while the voltmeter provides a rather stable value.

Can you tell me if I am making any mistakes in the configuration or in the circuit? Is there a simpler way to perform this reading?

Thank you.

Darsh
Reply
#2
suggest you add KinCony MB board, it mainly use for monitor battery , support ESPHome, easy to use.
here is details: https://www.kincony.com/esp32-battery-monitor.html
Reply
#3
Than for your reply,
the battery monitoring board would be ideal for a more complex project but for a small and simple project like mine it seems a bit too much.

I would like a more precise reading of the battery charge but if this add too much complexity I can live with the values I read with the voltage divider.

What I would like to understand is why I get values ​​less than 1 (0.15) from the analog to digital converter instead of having positive readings.

Thanks

Darsh
Reply
#4
(11-25-2024, 11:57 AM)Ojalá Wrote: Gracias por tu respuesta,
la placa de monitoreo de batería sería ideal para un proyecto más complejo pero para un proyecto pequeño y sencillo como el mío me parece un poco demasiado.

Me gustaría una lectura más precisa de la carga de la batería pero si esto agrega demasiada complejidad puedo vivir con los valores que leo con el divisor de voltaje.

Lo que me gustaría entender es por qué obtengo valores menores a 1 (0.15) del convertidor analógico a digital en lugar de tener lecturas positivas.

Gracias

Darsh

Saludos,

Dependiendo de los AH de tu batería, puedes usar módulos como el INA219 que te brindarán los datos más estables a través de I2C.
Reply
#5
yes, add INA219 extend small module is a easiest way.
Reply
#6
(11-25-2024, 03:31 PM)JULIO Wrote: Saludos,
Dependiendo de los AH de tu batería, puedes usar módulos como el INA219 que te brindarán los datos más estables a través de I2C.

Hello, the battery is a small 7ah gel deep cycle battery.
I wasn't familiar with the INA219 module; a quick search suggests it's exactly what I need, thank you for pointing it out to me.

Hola, la batería es una pequeña batería de gel de ciclo profundo de 7ah. 
No conocía el módulo INA219; una búsqueda rápida parece que es justo lo que necesito, gracias por indicármelo.

Darsh
Reply
#7
Hi,
I was able to measure the battery charge using the INA219 module connected to the I2C bus of the KC868-A6 board.

To measure the voltage but not the current, I had to:
  • bridge the Vin+ and Vin- contacts
  • connect the positive terminal of the battery to one of the Vin contacts

This connection allowed me to connect the INA219 board in parallel with the battery instead of in series, as is often done.

In EspHome, I added a section dedicated to the sensor:

Code:
sensor:
  - platform: ina219
    address: 0x40
    shunt_resistance: 0.1 ohm
    bus_voltage:
      name: "INA219 Bus Voltage"
    max_voltage: 32.0V
    max_current: 3.2A
    update_interval: 60s

Thank you again for pointing me to this solution.
Reply
#8
You can refer to these, this use by INA226 chip:
[Image: MB-1_05.jpg]
[Image: MB-1_06.jpg]
ESPHome yaml: https://www.kincony.com/forum/showthread.php?tid=3975
Reply


Forum Jump:


Users browsing this thread:
1 Guest(s)