gregmac / Genmon-ESP32-Serial-Bridge

ESP32 acting as an RS232 serial bridge for Genmon and Home Assistant
Mozilla Public License 2.0
39 stars 9 forks source link
esp32 esphome genmon homeassistant-integration

ESP32-based bridge to connect to a Genmon-supported standby generator.

The ESP32 is configured using ESPHome and everything is ultimately linked to Home Assistant.

Homeassistant Dashboard

Hardware

Antenna on side of generator Assembled ESP32 ESP32 close-up

Optional

Temperature sensors:

ESP32

Normally Genmon is installed on a Raspberry Pi that is wired to the generator, but I decided to take a different approach and use a simple, cheap ESP32 as an RS232-wifi bridge, connecting back to Genmon running on a server inside the house.

  1. Though the Pi can apparently work fine below its rated operating temperature of 0°C, the ESP32 is rated for –40°C to +125°C.
  2. The Pi is supposedly suspectiple to electromagnetic interference from the generator operating; my assumption is the ESP32, being much simpler, is less susceptible
  3. The ESP32 uses much less power, and unlike the Pi, can be powered entirely by the 5V supplied by the AUX port on the generator
  4. The ESP32 is significantly smaller and along with all the above, is much easier to mount and connect

I specifically went with the ESP32-WROOM-32U devkit board -- which has an external antenna that sticks out the side of the generator -- to get a decent signal, as the generator's metal enclosure blocks wifi.

The case is attached with veclro adhesive strips to the inside side panel next to the wifi antenna, since the antenna cable is very short.

Notes

Wiring

Wiring diagram

EPS connector:

MAX3232:

Note: I used GPIO22 instead of RX because I was having issues with receiving data which was a problem in my test setup, but I had changed the pin already. RX should work fine.

One-wire temperature:

All grounds need to be tied together.

ESP32 Software

I chose ESPHome because I was already using it for several other ESP32/ESP8266 devices, and it provides a lot of useful functionality out of the box.

This configuration uses:

See esphome/generator.yaml for the code.

Genmon

Install on Alpine Linux

I run genmon in an LXC container under Proxmox, on Alpine 3.11

  1. apk add bash python3 sudo make gcc build-base libressl-dev python3-dev rust py3-pip
  2. pip install -U pip (needs v22+ for the python cryptography package)
  3. cd /opt && git clone https://github.com/jgyates/genmon.git && cd /opt/genmon
  4. ./genmonmaint.sh -i

Configuration

Start genmon, and in the UI, set:

This can also be done via /etc/genmon/genmon.conf

Addons:

Home Assistant

  1. Add homeassistant/packages/generator.yaml to the Home Assistant packages folder and restart Home Assistant
  2. Add the contents of homeassistant/lovelace/generator-dashboard.yaml to your Home Assistant Dashboard