Skip to content
View in the app

A better way to browse. Learn more.

Power Forum - Renewable Energy Discussion

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

My Sunsynk 8Kw & data collection setup

Featured Replies

On 2021/09/16 at 11:28 AM, kellerza said:

@Sc00bs - seems like I finally have my Home Assistant energy dashboard working with my Sunsynk 🙂

image.png.5d2845888c9e80676419aa7dea8c5b87.png

Using only the following sensor config & the addon - https://github.com/kellerza/sunsynk

 

SENSORS:
  - total_pv_power
  - total_grid_export
  - total_grid_import
  - total_pv_power
  - total_battery_charge
  - total_battery_discharge

 

Hey @kellerza. Does this addon assume that the HA server is connected to the RS48?

(I've got a Pi by the inverter dropping to my separate HA server)

  • Replies 657
  • Views 179k
  • Created
  • Last Reply

Top Posters In This Topic

Most Popular Posts

  • If you want to try this card in home assistant follow these steps. 1. Create a new directory under www/community/ and name it sunsynk-card. If you don't have HACS installed you can create directo

  • Hi all. Here is my version to get Sunsynk 8.8 Modbus metrics in Home Assistant: Required Hardware: ESP32 Development Board @R149.95 https://www.diyelectronics.co.za/store/espressif-iot/1495-

  • Thought I would also contribute with something small. Not as impressive as what some of the others here but a contribution nonetheless. The GUI for Sunsynk System Mode, or lack thereof, has reall

Posted Images

23 hours ago, crash said:

Hey @kellerza. Does this addon assume that the HA server is connected to the RS48?

(I've got a Pi by the inverter dropping to my separate HA server)

You can deploy it in several ways:

The RS485 port can be local or remote. If remote you will need another device (like your Pi by the inverter) that runs a mbusd TCP-to-RS485 gateway. I use this method with a Pi running HomeAssistant OS near the inverter running mbusd as an addon, see https://github.com/kellerza/sunsynk/tree/main/hass-addon-mbusd . You can also run mbusd on any standard Linux OS (which means a Pi 1 could also perform this function)

The other way to do it is to have the Sunsynk Addon running on the pi close to the inverter and then connect to a the MQTT server on your main HomeAssistant server.

Edited by kellerza

  • 3 months later...

Would it be possible to set this up using the remote appraoch with an ESP32 and TTL to RS485 module? Does Esphome perhaps have the code for the modbus TCP gateway? Or maybe there is code that can run on the ESP32 to achieve this.

16 hours ago, BrettC said:

Would it be possible to set this up using the remote appraoch with an ESP32 and TTL to RS485 module? Does Esphome perhaps have the code for the modbus TCP gateway? Or maybe there is code that can run on the ESP32 to achieve this.

ESPhome cannot create a MODBUS-TCP gateway that I know of, but you can read/write modbus registers. If you create sensors with the correct state_class it should be possible to do this. You might have to write your own ESP lambda functions to do some math between the registers.

It could be a nice solution, but it does violate one of my home automation rules that it should not be too custom. And anything where you need a soldering iron (to connect the RS-485 to the ESP board) is too custom 😉 

  • 2 weeks later...

I went ahead and managed to set this up with an ESP32 and a R30 RS485 to TTL board I ordered off Banggood.

The Esphome code was surprisingly easy when I figured it out, and it was quite simple to set up the entities once I figured out how the Esphome modbus setup worked.

I am just reading the sensors for now. I still need to working on write updates to the settings.

image.thumb.png.c79effe5cacc69154480da429a121598.png

Here is a sample of the code if anyone else wants to try this approach.

uart:
  id: mod_bus
  tx_pin: 17
  rx_pin: 16
  baud_rate: 9600
  stop_bits: 1

modbus:
  id: modbus1

modbus_controller:
  - id: sunsynk
    address: 0x01
    modbus_id: modbus1
    setup_priority: -10
    update_interval: 20000ms

sensor:
  - platform: modbus_controller
    modbus_controller_id: sunsynk
    name: "Grid power"
    id: grid_power
    register_type: holding
    address: 169
    unit_of_measurement: W
    device_class: power
    state_class: measurement

 

  • 2 months later...

Hi all. Here is my version to get Sunsynk 8.8 Modbus metrics in Home Assistant:

Required Hardware:

ESP32 Development Board @R149.95
https://www.diyelectronics.co.za/store/espressif-iot/1495-esp32-development-board.html?search_query=esp32&results=26

MAX485 RS-485 to TTL Convert Module @R19.95 https://www.diyelectronics.co.za/store/serial/1204-max485-rs-485-to-ttl-converter-module.html?search_query=485&results=21

3D Printed Case I use to pack it all: https://www.thingiverse.com/thing:4670334

My code for ESPHome https://esphome.io/

Note: On the Sunsynk inverter side it is set to Modbus ID 1 and runs in Slave mode. (I think this is default for the inverter)

esphome:
  name: "sunsynk"

esp32:
  board: esp32dev
  framework:
    type: arduino

logger:
    baud_rate: 0

api:

ota:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "SOMEFALLBACKAP"
    password: "password"
  fast_connect: true
  power_save_mode: none

time:
   - platform: sntp
     id: sntp_time
     timezone: Africa/Johannesburg
     servers:
     - pool.ntp.org
     
uart:
 id: mod_bus
 tx_pin: 17
 rx_pin: 16
 baud_rate: 9600
 stop_bits: 1
 
modbus:
 id: sunsynk_modbus
 flow_control_pin: 4
 
modbus_controller:
 - id: sunsynk
   address: 0x01
   modbus_id: sunsynk_modbus
   setup_priority: -10
   update_interval: 20000ms
 
sensor:
 - platform: modbus_controller
   modbus_controller_id: sunsynk
   name: "Total Battery Charge (kWh)"
   id: total_battery_charge_kwh
   register_type: holding
   address: 72
   unit_of_measurement: "kWh"
   accuracy_decimals: 2
   device_class: energy
   state_class: total_increasing
   filters:
     - multiply: 0.1

 - platform: modbus_controller
   modbus_controller_id: sunsynk
   name: "Total Battery Discharge (kWh)"
   id: total_battery_discharge_kwh
   register_type: holding
   address: 74
   unit_of_measurement: "kWh"
   accuracy_decimals: 2
   device_class: energy
   state_class: total_increasing
   filters:
     - multiply: 0.1

 - platform: modbus_controller
   modbus_controller_id: sunsynk
   name: "Total Grid Export (kWh)"
   id: total_grid_export_kwh
   register_type: holding
   address: 81
   unit_of_measurement: "kWh"
   accuracy_decimals: 2
   device_class: energy
   state_class: total_increasing
   filters:
     - multiply: 0.1

 - platform: modbus_controller
   modbus_controller_id: sunsynk
   name: "Total Grid Import (kWh)"
   id: total_grid_import_kwh
   register_type: holding
   address: 78
   unit_of_measurement: "kWh"
   accuracy_decimals: 2
   device_class: energy
   state_class: total_increasing
   filters:
     - multiply: 0.1

 - platform: modbus_controller
   modbus_controller_id: sunsynk
   name: "Total Load Power (kWh)"
   id: total_load_power_kwh
   register_type: holding
   address: 85
   unit_of_measurement: "kWh"
   accuracy_decimals: 2
   device_class: energy
   state_class: total_increasing
   filters:
     - multiply: 0.1

 - platform: modbus_controller
   modbus_controller_id: sunsynk
   name: "Total PV Power (kWh)"
   id: total_pv_power_kwh
   register_type: holding
   address: 96
   unit_of_measurement: "kWh"
   accuracy_decimals: 2
   device_class: energy
   state_class: total_increasing
   filters:
     - multiply: 0.1

 - platform: modbus_controller
   modbus_controller_id: sunsynk
   name: "Grid Power"
   id: grid_power
   register_type: holding
   address: 169
   unit_of_measurement: "W"
   accuracy_decimals: 2
   device_class: power
   state_class: measurement
   filters:
    - lambda: |-
           float MIN_VALUE = 0.00;
           float MAX_VALUE = 8000.00;
           if (MIN_VALUE <= x && x <= MAX_VALUE) return x;
           else return {};
   
 - platform: modbus_controller
   modbus_controller_id: sunsynk
   name: "Load Power"
   id: load_power
   register_type: holding
   address: 178
   unit_of_measurement: "W"
   accuracy_decimals: 2
   device_class: power
   state_class: measurement
   
 - platform: modbus_controller
   modbus_controller_id: sunsynk
   name: "PV1 Power"
   id: pv1_power
   register_type: holding
   address: 186
   unit_of_measurement: "W"
   accuracy_decimals: 2
   device_class: power
   state_class: measurement
   
 - platform: modbus_controller
   modbus_controller_id: sunsynk
   name: "PV2 Power"
   id: pv2_power
   register_type: holding
   address: 187
   unit_of_measurement: "W"
   accuracy_decimals: 2
   device_class: power
   state_class: measurement

 - platform: modbus_controller
   modbus_controller_id: sunsynk
   name: "Battery SOC"
   id: battery_soc
   register_type: holding
   address: 184
   unit_of_measurement: "%"
   accuracy_decimals: 0
   device_class: battery

 - platform: modbus_controller
   modbus_controller_id: sunsynk
   name: "Battery Charging Efficiency"
   id: battery_charging_efficiency
   register_type: holding
   address: 216
   unit_of_measurement: "%"
   accuracy_decimals: 1
   device_class: battery
   filters:
     - multiply: 0.1

 - platform: modbus_controller
   modbus_controller_id: sunsynk
   name: "Grid Connected Status"
   id: grid_connected_status
   register_type: holding
   address: 194
   accuracy_decimals: 0

In Home Assistant, ensure to include the new sensors in the recorder:

recorder:
  include:
    entity_globs:
      - sensor.total_*
      - sensor.grid_*
      - sensor.load_*
      - sensor.pv*_power
      - sensor.power_production*



diagram.thumb.png.e3e763d00b76ed3a522ab796ad13677c.png

 

 

 

 

sunsynk.png

2.png

entities.png

sensors.png

 

energy_setup.png

energy_dash.png

Edited by sjlouw

  • Author

So @sjlouw, I have two questions, not sure if you know the answers

-  What is the effect of switching the inverter into Slave on overall inverter functioning 

- Any idea why it is necessary for the inverter to be set as Slave for the comms to work, it works using the RS485 without changing the settings using @Bloubul7 's node  red flows

 

On 2022/06/21 at 1:34 PM, Sc00bs said:

So @sjlouw, I have two questions, not sure if you know the answers

-  What is the effect of switching the inverter into Slave on overall inverter functioning 

- Any idea why it is necessary for the inverter to be set as Slave for the comms to work, it works using the RS485 without changing the settings using @Bloubul7 's node  red flows

 

1. If you have a single inverter, there is no effect. (The default setting for mine was Slave). Its only there if you have multiple inverters setup in parallel, then you have to define them each with a unique number and have at least one in MASTER mode on the modbus.
2. The ESP32 acts as a modbus master on the bus, from what I understand.

  • 3 weeks later...

Excellent work i have my setup all have gone with Pi zero sending Data to HA on pi 4b and all looking really good.
Now with the load shedding animal i need to be able to change my charge settings on my Sunsynk Inverter similar to the settings that you can change on Solar Assistant 
A lot of work that i still need to get going on grafana but i have some graphs working lekker thanks to Scoobs and Bloubul 7 

I just need to figure out how i can change these settings on my inverter and if possible have the schedule changed automaticlly with these hectic schedules we have at the moment but for now if i can just change it using Home assistant or Nodered and write back to the inverter 



 

Screenshot 2022-07-14 at 07.33.27.png

  • Author

Hi @Farcus

It is possible to write settings back to the inverter using the flows that @Bloubul7 created using the Node Red UI.

How exactly to set it up, I have no idea as I could never get it to work and I kept on overwriting my inverter settings but a number of people have so I was obviously doing something wrong. 

Maybe someone who has got it running could explain what needs to be setup for it to work.  

  • Author

@sjlouw Is it possible to write settings back to the inverter using you ESPhome solution? 

Would be nice to be able to store multiple setups the way the Node Red flows do and write them back to the inverter when required.

  • 3 weeks later...

Hi all,

I have downloaded the SunSynk Modbus document.  It would seem to be applicable to single phase inverters

I have a SunSynk 12 kW 3 phase inverter ... is this document valid for this model?

Or can anyone advise on where one might find the modbus register layout for the SunSynk 3 phase inverter?

  • 2 weeks later...
On 2022/08/04 at 10:26 PM, MoGuLza said:

 

Hi all,

I have downloaded the SunSynk Modbus document.  It would seem to be applicable to single phase inverters

I have a SunSynk 12 kW 3 phase inverter ... is this document valid for this model?

Or can anyone advise on where one might find the modbus register layout for the SunSynk 3 phase inverter?

Pretty much all Sunsynk and Deye models use same registers as described in the document.

Differences come with wiring pins and getting stable read.

 

 

On 2022/07/14 at 7:46 AM, Farcus said:

Excellent work i have my setup all have gone with Pi zero sending Data to HA on pi 4b and all looking really good.
Now with the load shedding animal i need to be able to change my charge settings on my Sunsynk Inverter similar to the settings that you can change on Solar Assistant 
A lot of work that i still need to get going on grafana but i have some graphs working lekker thanks to Scoobs and Bloubul 7 

I just need to figure out how i can change these settings on my inverter and if possible have the schedule changed automaticlly with these hectic schedules we have at the moment but for now if i can just change it using Home assistant or Nodered and write back to the inverter 



 

Screenshot 2022-07-14 at 07.33.27.png

You kinda almost there, as far as inputs for Time, Power, and SoC go fairly straight forward.

Actual register(s) holding value for charging state for given time slot on/off requires bit more elaboration.... Albeit if file access permission flag makes sense to you it kinda works in a similar way. 

Charge field in inverter registry is integer and holds values for, all possible states

State table should look something like this :

     GridChrg  GeneChrg
04   false     false           Both off
05   true      false           Grid on, Gen off 
06   false     true            Grid off, Gen on
07   true      true            Grid On, Gen on

So if you don't need anything fancy and/or care for states other than grid charge on/off having a simple map that binds 04 to false and 05 to true should do the trick ...

I'm assuming rest of the reg addresses and such like you have already worked out. 

Hope this helps

 


 

Edited by Padwan

  • 2 weeks later...

Thanks for this , this is excellent. The ESP32 method is by far the quickest and easiest.

Only issue I seam to be having is delayed readings, sometime no readings. @sjlouw did you remove the termination resistor (R7) off from the RS485 board? Or do you have similar issues using the esp32

Thanks for the effort 

  • 2 weeks later...

@Garreth

No, I have not removed the resistor. The module is used as-is. I'm not experiencing those issues.

I wonder, can it maybe be poor Wifi connection from your ESP to your access point? Mine is literally next to an Access Point. Also note that I have used an ESP32 which does have a little more processing power than the ESP8266, which I think is sort-off required for the modbus component in ESPHome to reliably work.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.