Skip to content
Skip to content
Gooseleggs Site

Ramblings

← Updating code into ESP chip from factory
Getting correct image size from Eagle PCB →
-->

Multi Battery Charger – WiFi enabled

Posted on August 19, 2023 by admin

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

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)

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 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

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 PinFunction
IO 0
IO 2On/Off Start/Pause Button
IO4Next Button
IO 5595 Relay OE pin
IO 12595 Relay Latch Pin
IO 13595 Relay Latch Clock Pin
IO 14595 Relay Data Pin
IO 15Charger Relay
IO 16Status LED
TX
RX
ADCCurrent 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 PinFunction74HC595 PinESPHome name
5!OE13oe_pin
12RCLK12latch_pin
13SRCLK11clock_pin
14SER14data pin
This entry was posted in Electronics. Bookmark the <a href="https://www.thesmithcave.nz/?p=364" title="Permalink to Multi Battery Charger – WiFi enabled" rel="bookmark">permalink</a>.
← Updating code into ESP chip from factory
Getting correct image size from Eagle PCB →

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

© 2025 | Blog info WordPress Theme | By Bharat Kambariya