Reading Growatt Inverter data into Home Assistant via the modbus using a MAX485 TTL to RS485 module and a Wemos D1 Mini. This setup completely eliminates the need to collect data via the cloud (the Chinese Growatt api servers). Also, it is possible to increase the update frequency of the data. My sensors are updating every 10 sec. The setup is also inexpensive: a few euro's for the D1 Mini, and the MAX458 to TTL module costs less than one euro!
In my example here I am using the standard ESPHome Growatt integration. As far as I can see it only supports the solar production part, I don't see any sensors that relate to the use of batteries.
A feature request for battery support for the ESPHome Growatt component already exists. If the standard ESPHome Growatt integration does not work for you, I suggest you to read the following interesting discussion where an alternative method for reading Growatt's modbus is proposed by reading values directly from their corrosponding registers. More info about the Modbus Controller Component can be found at the ESPHome site.
You will need a MAX485 TTL to RS485 Converter Module and a Wemos D1 mini (or similar such as ESP32 or ESP2866) to read out the modbus of the Growatt inverter. And a few female jumper wires to make the connections. First you'll need to find out which exact two pins on the Growatt Inverter communication socket provide the RS485 modbus communication signals. In the quick guide of my Growatt MIN 6.000TL3-XH inverter I see that the communication cable installation part shows that pin 3 (RS485A1, green in my setup) and pin 4 (RS485B1, green/white in my setup) can be used for RS485 communication.
My inverter came with an empty connector plug including a few ferrules. I just needed a crimping tool to connect the two RS485 communication wires to the ferrules and assemble the connection plug. In the photo you can see that I also connected pin 1 (+12V) and pin 15 (ground). In a later stage I would like to replace the USB charger plug and somehow power the D1 mini directly from the converter.
These two wires from pin 3 (A) and pine 4 (B) must be connected to the two screws labeled A and B on the MAX485 TTL to RS485 Converter Module.
The RS485 convertor module must be connected to the Wemos D1 Mini using five wires: Two wires are used to power the module from the D1 mini:
and three wires to communicate with the module:
(On the last photo DE and RE are connected. This is not required for this project as data is received only, but I used this module in another project before where it was needed to shorten DE and RE.)
After installing ESPHome in Home Assistant it can be reached via the lefthand menu. Adding a new device is easy, just make sure the Wemos D1 Mini is connected via a USB data cable (Be aware that some cheap USB charging cables don't support data communication). Follow the process of updating the first firmware to the D1 mini. When it is finished a new tile appears in the overview. This is the time to edit the code such that it starts listening and reading the Growatt Inverter:
Below is the exact code I use, and here is some explanation of the code first: esphome: This is just the name of the device.
esp8266: This is automatically filled with the correct board type
logger: As hardware serial is used, the logging via USB must be disabled. The serial logging uses the exact same pins we need to communicate with the MAX485TTL to RS485 module. Disabling logging is done by setting its bautrate to zero.
api: The encryption key
ota: Is just there such that updates can be done Over-The-Air.
wifi: the wifi credentials the device need to connect with. (the actual credentils are read from my secrets.yaml file)
all the rest is just copied from: https://esphome.io/components/sensor/growatt_solar.html
# Define the name of the ESPHome project
esphome:
name: esphome-growatt
friendly_name: Growatt
# Define the exact board being used
esp8266:
board: esp01_1m
# Disable hardware serial logging as it conflicts with the serial connection
# with the MAX485 TTL converter module by setting baud rate to zero
logger:
baud_rate: 0
# Enable Home Assistant API
api:
encryption:
key: "=heregoestheapikey="
# Enable over the air updates (ota)
ota:
# Define how the device connects to Wifi
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "esphome-growatt"
password: "SSw2Oy8kDY3r"
# Define a captive portal as fallback in case connecting ti Wifi fails
captive_portal:
# Define the UART communication settings
# GPIO1 and GPIO3 are the hardware supported serial TX and RX pins
uart:
- id: gw_uart
baud_rate: 9600
tx_pin: GPIO1
rx_pin: GPIO3
# Define the modbus specific settings
modbus:
uart_id: gw_uart
flow_control_pin: GPIO4
# Define the protocol version and the sensors for this device.
# Old inverters use RTU (default). Newer ones use RTU2 (e.g. MIC, MIN, MAX series)
sensor:
- platform: growatt_solar
update_interval: 10s
protocol_version: RTU2
inverter_status:
name: "Status Code"
phase_a:
voltage:
name: "Voltage Phase A"
current:
name: "Current Phase A"
active_power:
name: "Power Phase A"
phase_b:
voltage:
name: "Voltage Phase B"
current:
name: "Current Phase B"
active_power:
name: "Power Phase B"
phase_c:
voltage:
name: "Voltage Phase C"
current:
name: "Current Phase C"
active_power:
name: "Power Phase C"
pv1:
voltage:
name: "PV1 Voltage"
current:
name: "PV1 Current"
active_power:
name: "PV1 Active Power"
pv2:
voltage:
name: "PV2 Voltage"
current:
name: "PV2 Current"
active_power:
name: "PV2 Active Power"
active_power:
name: "Grid Active Power"
pv_active_power:
name: "PV Active Power"
frequency:
name: "Frequency"
energy_production_day:
name: "Today's Generation"
total_energy_production:
name: "Total Energy Production"
inverter_module_temp:
name: "Inverter Module Temp"
Now connect the thing to the Growatt Inverter and power the D1 mini from a usb charger.
Back in Home Assistant's ESPHome page, the tile provides the log function:
This is all the magic to setup the Wemos D1 Mini to listen via the RS458 to TTL module. In Home Assistant's settings -> integration page, the tile ESPhome will now detect the new 'Growatt' device, holding all the sensors: