# APC7921-esp
The APC7921 controls the relays via an I2C bus which is supplied via a flatcable from the controller-board.

By putting an intermediate board between the controller and the relay-board, we are able to take over the i2c handling, but leave the rest (PSU, etc) to the controller-board to handle for now.

# the PCB for on the ESP32

There are two versions of the pcb. One to mount on top of the WT32-ETH01. The other to mount under the WT32-ETH01.

We implemented the following features
  *  combine the 2 x 24VDC power sources with diodes
  *  add pull up/down to A0-A3 for I2C address as power up
  *  add voltage detection wiring to ESP32 with step down to 3.3V max (for now using easy 2 resistor method 1KOhm + 12KOhm for 36V down to 3.3V)
  *  fix the grounding of power sources / relais / control circuits
  *  created footprint for power converter 24V -> 3.3V to power control circuit
  *  remove 4 pins from ESP32 header to accomodate the 3d printed part fixing it to the case

# Making the WT32-ETH01 fit the APC

The WT32-ETH01 is a useful board but rather cumbersome to mount. While fitting it into the original Ethernet-jack hole would be preferable, it became clear that mounting it in the former SerialPort seems to be much more straightforward. In short, the board fits by putting the bottom of the PCB onto the metal bottom-plate of the APC and sticking the ethernet-jack through the hole for the serial port. This has some implications:

  *  The APC-bottomplate should be taped with Kapton-tape or somesuch to prevent shorts
  *  There are 3 mounting-points on the front-panel of the APC that allow for mounting the original PCB.
  *  Mounting the board using these mounting-points requires a plastic adapter-plate

Design for the adapterplate was easy as early ideas for this project involved just replacing the PCB with another; so measurements had been taken and a FreeCad model of the PCB outline existed to be able to 3dprint it for a test-fit.

The current iteration of the adapterplate has:

  *  Three 5mm standoffs to make the space between front-panel and adapter-plate fit the ethernet-jack perfectly
  *  a cup enveloping the ethernet-jack should supply extra stability and can be used to glue-in
  *  a hexagonal grid of ribbing stiffens the design against bending while reducing needed filament

An .stl is provided here. 

# Software for the WT32-ETH01; ESPHome

On the software side things are quite easy for us. Using ESPHome , we have direct support for:

  *  Ethernet (done)
  *  Home-Assistant (done)
  *  Direct web UI (done)
  *  pcf8574 i2c expander (done)
  *  PSU sensing via ADC (wip)
  *  Current sensing via ADC (wip)

A reference .yaml file is provided here.

# Why no Bat43???

There seems to be no good reason to use a BAT43 in this project.

