Home
This project is a custom data logger for Growatt inverters with an USB connector.
Usually, you connect a ShineWifi-X or ShineLan-X connector (sold by Growatt) to the USB connector of your inverter to monitor your data, but you are restricted to the Growatt Cloud, aka ShineServer. This project replaces the need for a Shine* module by exposing the ModBus interface via MQTT.
Benefits:
- Works without internet / no cloud connection needed
- Access more data than is usually exposed via ShineServer
- Faster update speed. If you want, you can even read the data once every second
- Further process your data / integrate into your Smart Home
This project is heavily inspired by the ShineWifi-S firmware replacement project: https://github.com/otti/Growatt_ShineWiFi-S
Thanks a lot for giving the important hint that the USB connector is just a wrapper for RS232
What the Growatt Inverter wants to see on the USB port is a CH340 USB => Serial converter so this project is compatible with ESP devices that have such a serial interface, for example the NodeMCU Lolin V3, Wemos D1, ESP01, etc
- Grab any ESP board with an CH340 USB <=> serial chip
- Connect the ESP board to your computer via USB
- Open this project in Arduino IDE and upload to your ESP board
- Connect the ESP board to your Growatt inverter
- Connect to the Wifi AP named
GrowattMB2USB
with passwordGrowattMB2USB
and adjust your Wifi Settings and MQTT settings - Wait until the LED flashes about two times per second.
Of course, you can also setup the Wifi connection before connecting the ESP to your inverter if preferred. Just power the ESP via any USB cable.
As there are too many different inverters with varying ModBus registers, I kept this project generic. You can request register values via MQTT, the response will be a register => value map as json. Mapping these registers to useful values is on your own. I use Node-RED to do this, be sure to checkout my Node-RED example flow.
The ESP communicates via MQTT in json format. Once you've installed everything, you can send an MQTT messages to
energy/gromodbus/request
Responses will be sent on
energy/gromodbus/response
Request a set of ModBus register from your Growatt inverter. Example:
{
"command": "readinputregisters",
"index": 1000,
"count": 125
}
You can use readinputregisters
to read input registers or readholdingregisters
to read holding registers.
The ESP will respond with a message such as this upon success:
{
"status": "ok",
"request": {
"command": "readinputregisters",
"index": 100,
"count": 25
},
"data": [
100,
101,
102,
......
],
"timestamp": 1151448
"baud": 115200,
"rssi": -66,
"ssid": "YourWifiName",
"ip": "192.168.0.123"
}}
In case of an error, an error response is returned:
{
"status":"error",
"request":{
"command":"readinputregisters",
"index":3093,
"count":3
},
"error":"Failed to read modbus registers, error code 1 - Modbus protocol illegal function exception.",
"timestamp":1227115
"baud": 115200,
"rssi": -66,
"ssid": "YourWifiName",
"ip": "192.168.0.123"
}
Writing to a holding register is now possible, too. Only use if you absolutely know what you're doing!
To write value 0 to register 122, send the following message:
{
"command": "writeholdingregister",
"index": 122,
"value": 0
}
The response is either an ok or an error response, similar to as described above.
Every response contains the following data
Key | Description |
---|---|
status |
either "ok" or "error" |
request |
The incoming request which this response is a reply to |
timestamp |
Always sent, milliseconds since boot of the device |
baud |
Always sent, the baud rate at which the device is connected to the inverter. 0 if not connected |
rssi |
Wifi connection signal strength |
ssid |
The name of the Wifi that the device is connected to |
ip |
The device ip address |
Furthermore, the following data is optionally available and depends on the context
Key | Description |
---|---|
data |
Array of register values if the request was a register read. Omitted otherwise |
error |
Only sent if the status is "error", provides a human readable error description |
The connection status of the device is published at
energy/gromodbus/status
The status is either online
or offline
The project has been created with compatibility in mind. The Arduino part does not make any assumptions about the data so as long as it is able to connect to the inverter via ModBus, it will work. Parsing / interpreting the sent data is up to you. Feel free to use my Node-RED flow as an example, proven to work with a Growatt SPH-5000TL3 BH.