ESPHome modbus Growatt ShineWiFi-S

Hello all. I have a growatt solar inverter. This has a ShineWiFi-S module to read the inverter with modbus. i found https://github.com/otti/Growatt_ShineWiFi-S and converted the arduino code to esphome.

I would like to share the ESPHome yaml.

The EnergyTotal sensor is configured to get it in the energy dashboard.

substitutions:
  device_description: Growatt Inverter
  friendly_name:  Growatt Inverter
  name: Growatt
  
esphome:
  name: growatt

esp8266:
  board: esp07s

# Enable logging
logger:
  baud_rate: 0
# Enable Home Assistant API
api:

ota:
  password: "yourpassword"

wifi:
  ssid: !secret ssid
  password: !secret pswd

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Growatt Fallback Hotspot"
    password: "Yourpassword"

captive_portal:

output:
# Blue Led
  - id: light_bl
    platform: gpio
    pin: 16
# Green Led
  - id: light_gr
    platform: gpio
    pin: 0
# Red Led
  - id: light_rd
    platform: gpio
    pin: 2

uart:
  id: mod_bus
  tx_pin: 1
  rx_pin: 3
  baud_rate: 9600
  
modbus:
  id: modbus1
  uart_id: mod_bus
  
modbus_controller:
  - id: growatt
    ## the Modbus device addr
    address: 0x1
    modbus_id: modbus1
    setup_priority: -10  


sensor:
  - platform: modbus_controller
    name: "${name} DcPower"
    address: 1
    register_type: "read"
    unit_of_measurement: W
    icon: mdi:flash
    value_type: U_DWORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1
    
  - platform: modbus_controller
    name: "${name} DcVoltage"
    address: 3
    register_type: "read"
    unit_of_measurement: V
    icon: mdi:flash
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1
    
  - platform: modbus_controller
    name: "${name} DcInputCurrent"
    address: 4
    register_type: "read"
    unit_of_measurement: A
    icon: mdi:flash
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1
    
  - platform: modbus_controller
    name: "${name} AcFrequency"
    address: 13
    register_type: "read"
    unit_of_measurement: Hz
    icon: mdi:flash
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.01
  
  - platform: modbus_controller
    name: "${name} AcVoltage"
    address: 14
    register_type: "read"
    unit_of_measurement: V
    icon: mdi:flash
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1
  
  - platform: modbus_controller
    name: "${name} AcOutputCurrent"
    address: 15
    register_type: "read"
    unit_of_measurement: A
    icon: mdi:flash
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1
    
  - platform: modbus_controller
    name: "${name} AcPower"
    address: 16
    register_type: "read"
    unit_of_measurement: W
    icon: mdi:flash
    value_type: U_DWORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1
    
  - platform: modbus_controller
    name: "${name} EnergyToday"
    address: 26
    register_type: "read"
    unit_of_measurement: kWh
    icon: mdi:flash
    value_type: U_DWORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1
    
  - platform: modbus_controller
    name: "${name} EnergyTotal"
    address: 28
    register_type: "read"
    unit_of_measurement: kWh
    state_class: total_increasing
    device_class: energy
    icon: mdi:flash
    value_type: U_DWORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1

    
  - platform: modbus_controller
    name: "${name} Temperature"
    address: 32
    register_type: "read"
    unit_of_measurement: C
    icon: mdi:thermometer
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1
5 Likes

I was super excited to find growatt solar support added to esphome today so I jumped on it and its deployed already on my ShineWIFI-S dongle. I’ll jave to wait until the sun comes up to see if it actually works. Until then I’d like to ask you a question:
There are some anecdotes on the internet about the inverter not having an RTC and needing a write via modbus to the registers keeping the current time for daily energy production to be counted correctly. Did you notice anything strange regarding this? Would it be OK to add this functionality (if needed)?

So happy that you are so excited!

I understand your question and i’d like to dive into that if you want.

Know that the daily is (in our case) not important. If you have the EnergyTotal in your energy dashboard, it calculate it for you. If you don’t have it in the energy dashboard, you can make a utility sensor for daily, weekly and monthly also with the EnergyTotal. I have not that much experience with the modbus and i like to have, for example, the status text (“Normal”, “Waiting” enz). Nevertheless i like to learn, so i will look into that.

@paperPenguin I have thought about it and i think i do the timing en calculation in esphome it self. The inverter does not care when the daily resets imo. Do you agree?

@WilbertV, how did you download the bin file to the stick?
Just as a normal esp?

1 Like

@Hendrik1 With a USB to TTL adapter. When you have te PCB out of the black case, you can simply get a few header pins to connect the 4 pins and gpio 0. The manufacturer has done a great job in making the connections available.

If you need more help, please let me know.

Thanks, i have just ordered a WiFi stick, so will try it soon.
Its now connected with a network connection, but need that one for something else.

I have also another stick, that one had usb-c, Will it workshop on that one also?

did anyone happen to try this with a ShineWIFI-X yet?

quickly checking the code of the original project i’d assume it should work as there are no different pin definitions … but there seems to be a reconnect-function specific to the X/USB version

I think the mane difference is the baud rate. In the code it is trying a connection with 115200 and when it is succes it defines it as shine x.

Working YAML for my ShineWIFI-X

substitutions:
  devicename: "esphome-growatt-01"
  upper_devicename: "ESPHome Growatt 01"
  
esphome:
  name: $devicename
  platform: ESP8266
  board: esp07s



# Enable logging
logger:
  baud_rate: 0
  
# Enable Home Assistant API
api:

ota:
  password: !secret ota_passwd

wifi:
  ssid: !secret iot_ssid
  password: !secret iot_passwd
  fast_connect: on

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Growatt 01 Fallback Hotspot"
    password: "xxxxxxx"
    
  # Enable Web server
web_server:
  port: 80

captive_portal:

time:
  - platform: homeassistant
    id: homeassistant_time

output:
# Blue Led
  - id: light_bl
    platform: gpio
    pin: 16
# Green Led
  - id: light_gr
    platform: gpio
    pin: 0
# Red Led
  - id: light_rd
    platform: gpio
    pin: 2

uart:
  id: mod_bus
  tx_pin: 1
  rx_pin: 3
  baud_rate: 115200
  
modbus:
  id: modbus1
  uart_id: mod_bus
  
modbus_controller:
  - id: growatt
    ## the Modbus device addr
    address: 0x1
    modbus_id: modbus1
    setup_priority: -10  


sensor:
  - platform: modbus_controller
    name: "${devicename} DcPower"
    address: 5
    register_type: "read"
    unit_of_measurement: W
    device_class: power
    icon: mdi:flash
    value_type: U_DWORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1
    
  - platform: modbus_controller
    name: "${devicename} DcVoltage"
    address: 3
    register_type: "read"
    unit_of_measurement: V
    device_class: voltage
    icon: mdi:flash
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1
    
  - platform: modbus_controller
    name: "${devicename} DcInputCurrent"
    address: 4
    register_type: "read"
    unit_of_measurement: A
    device_class: current
    icon: mdi:flash
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1
    
  - platform: modbus_controller
    name: "${devicename} AcFrequency"
    address: 37
    register_type: "read"
    unit_of_measurement: Hz
    icon: mdi:flash
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.01
  
  - platform: modbus_controller
    name: "${devicename} AcVoltage"
    address: 38
    register_type: "read"
    unit_of_measurement: V
    device_class: voltage
    icon: mdi:flash
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1
  
  - platform: modbus_controller
    name: "${devicename} AcOutputCurrent"
    address: 39
    register_type: "read"
    unit_of_measurement: A
    device_class: current
    icon: mdi:flash
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1
    
  - platform: modbus_controller
    name: "${devicename} AcPower"
    address: 40
    register_type: "read"
    unit_of_measurement: W
    device_class: power
    icon: mdi:flash
    value_type: U_DWORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1
    
  - platform: modbus_controller
    name: "${devicename} EnergyToday"
    address: 53
    register_type: "read"
    unit_of_measurement: kWh
    device_class: energy
    icon: mdi:flash
    value_type: U_DWORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1
    
  - platform: modbus_controller
    name: "${devicename} EnergyTotal"
    address: 55
    register_type: "read"
    unit_of_measurement: kWh
    state_class: total_increasing
    device_class: energy
    icon: mdi:flash
    value_type: U_DWORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1

    
  - platform: modbus_controller
    name: "${devicename} Temperature"
    address: 3093
    register_type: "read"
    unit_of_measurement: C
    device_class: temperature
    icon: mdi:thermometer
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1
2 Likes

I have the ShineWifi-F and I’m trying to flash it without luck. TX to TX, RX to RX (and I’ve tried the reverse), 3.3V and Ground and then Gnd to GPIO0 on startup and the light is just red at the point, but I can’t get it to accept the firmware.

Any suggestions on how to get this device into flashing mode?

what esp chip is on board of the F series? i can not find any documentation except the original user manual.

Chip: ESP-07s

Have you tried holding GND and gio0 when you started flashing?
Any startup logs when not holding GND and gpio0? Even not readable so you can see the communication is correct? Can no longer remember if i have seen them.
Is it possible to measure the connections between the gpio pins and the board? It sounds to me like you have done everything i should try so it seems to me it can only be the connection between the gpio pins and the ESP chip.

Exciting! I have a shine wifi E, would this code work on that too? I’m not using it for privacy reasons.
I’ll open it to check what esp it has.

It is looking similar so if it has a esp ship it should work. Please let us know!

while im trying to get everything documented i read that otti (GitHub - otti/Growatt_ShineWiFi-S: Firmware replacement for Growatt ShineWiFi-S) added a 1k resistor between the output of the SW1 and GPIO0 to get it into boot mode. maby thats the solution.

I’ve tested for continuity and the gpio0 marker on the board is definately connected to gpio0, and I’ve tried tx and rx in both directions. The red light goes on by itself when I short gpio0 to ground, but no dice.

I tried what I thought was the output of SW1, but I’m not sure what that actually is. I also tried shorting the pin beside gpio0 between it and ground to ground like the esp docs say, and that doesn’t work.

1 Like


Not sure this is an esp on the shine wifi E
Edit: it’s not: MT781

I am going to buy the shinewifi s. Did you find any guide with pictures how to flash (connector pins and such)?