Overview
This project is about creating a multi battery charger that is smart enabled. The circuit allows up to 8 batteries to be charged from a single battery charger. When the battery charger is started, it starts charging one battery at a time, until all batteries have been charged. At this point, the battery charger will turn off.
Features of the charger
- Multiple batteries can be charged
- Auto turn off when completed
- Automatic changing to next battery when charged
- Capable to handling 30A charge current
- Simple interface
- Voltage/Current display
- Built with ESPHome
- WiFi Enabled – allow to be integrated into Home Assistant
- Bring your own charger – This device just switches between batteries, it is not responsible for the type of battery connected
Components
- 8 Channel WiFi enabled relay board
Inputs / Output
Inputs
- On/Off button
- Start/Pause button
- Next/Stop button
- Current – ADC connection
Outputs
- 8 Relay outputs
- 8 LED’s showing relay status
- Running LED
- Charger relay on/off
- Unit on LED
Connections
- Running LED connected to the Charger relay on/off output
- 8 LED outputs added as an extension on the built in HC595 serial/parallel converter
- Current through the ADC pin
- Unit On LED – on when power to the unit
Pseudo Code
Here is some pseudo code for the battery charger
Variables
- unit_state (default value is on as unit will be on) – states can be on, off, pause, running
- relay_active ( number of the current active relay) – default is 1
- current_countdown – counts down number of below threshold readings – default 3
On/Off Button
- Button press
- If unit_state is off
- set unit_state to on
- Turn on all LEDs for 0.5 second (LED test)
- Turn on LEDs to show number of active outputs
- set relay_active=1
- if unit_state is pause, running, on
- Turn unit_state to off
- Turn off all relays
- Disable relays
- Turn off charger relay
- If unit_state is off
Start/Pause Button
- Button Press
- if unit_state is on or pause
- if unit_state is on, then set relay_active to 1 (reset to start)
- set unit_state to running
- Turn off all LEDs
- Turn on LED for active relay
- Turn on relay for active LED
- Enable relays
- Enable charger relay
- if unit_state is running
- Turn off charger relay
- Turn off active relay
- Disable relays
- set unit_state to pause
- (Leave LED on to show current battery being charged)
- if unit_state is on or pause
Next / Reset Button
- Button Press
- if the button is pressed less than than 0.5 second (Next)
- if unit_state is running
- Turn off battery relay
- Turn off battery LED
- Increment relay_active
- if relay_active > 8, then relay_active=1
- Turn on battery LED
- Wait 15 (?) seconds
- Turn on battery relay
- If unit_state is paused
- Turn off battery LED
- Increment relay_active
- if relay_active > 8, then relay_active=1
- Turn on battery LED
- if unit_state is running
- if button is pressed > 3 seconds (Reset)
- Turn off battery relay
- Disable relays
- Turn off charger
- set relay_active = 1
- Turn on LEDs showing active outputs
- set unit_state = on
- if the button is pressed less than than 0.5 second (Next)
Current Sense Reading
Current sense will be read every 15 seconds, and filtered to give an average over 3 readings.
- if reading > minimum threshold
- current_countdown = 3
- if reading < minimum threshold
- decrement current_countdown
- if current_count = 0
- Turn off battery relay
- Turn off battery LED
- Increment relay_active
- if relay_active > 8,
- Disable relays
- Turn off charger
- Turn off LEDs
- set relay_active = 1
- set unit_state to off
- else
- Turn on battery LED
- Wait 15 (?) seconds
- Turn on battery relay
Pin Outs for the Charger
ESP-12 Pin | Function |
---|---|
IO 0 | |
IO 2 | On/Off Start/Pause Button |
IO4 | Next Button |
IO 5 | 595 Relay OE pin |
IO 12 | 595 Relay Latch Pin |
IO 13 | 595 Relay Latch Clock Pin |
IO 14 | 595 Relay Data Pin |
IO 15 | Charger Relay |
IO 16 | Status LED |
TX | |
RX | |
ADC | Current ADC |
Relay control
The board comes with an HC595 controlling the relays. The pin-outs are hard coded. The following table shows the pins that are used on the ESP32, along with the connections to the chip
ESP-12 Pin | Function | 74HC595 Pin | ESPHome name |
---|---|---|---|
5 | !OE | 13 | oe_pin |
12 | RCLK | 12 | latch_pin |
13 | SRCLK | 11 | clock_pin |
14 | SER | 14 | data pin |