Git Product home page Git Product logo

sofarsolar_esp_rs485_logger's Introduction

SofarSolar ESP RS485 logger to MQTT

Background

From the shelf logger is only works with SolarMan cloud, but I wanted to have full local integration with Home Assistant, because of poor internet connection. Additionally refresh interval from orginal logger (I managed to integrate with Home Assistant too, see HA Add-One project) is not synchronized with energy meter sensor which checks consumption and production from/to grid. The result was weird, because power wheel shows that house produced energy.

I asked SofarSolar for documentation of RS485 communication, but no lack. I managed to read register based on old SofarSolar documentation for other inverters models other than KTL-X (my inverter) and reversed engineered data based on information sent to SolarMan cloud.

At the end I finished with two working loggers in parallel ;-)

Other projects

Here is a list of other project that you may be intrested:

Supported inverters

For sure SofarSolar KTL-X 8.8 and other powers from KTL-X. There is a chance that other brands from the same familly with work, so if someone check please let me know.

Tested supported devices:

  • Sofar KTL-X 8.8 (whole series of KTL-X should work)
  • Sofar 4K TLM-G2

Parts needed to build own local logger

  • "ESP-07 WiFi serial" - you will find the part under this name
  • RS485 to TTL converter compatible with 3v3 (3v3 is an important, because ESP-07 operates on 3v3 TTL levels)
  • External antena with connector
  • RJ45 connector and cables

I bought everything from China directly. Total cost is around $5, so much cheaper than orignal logger and more freedom with integration.

Schematic

Firmware choice

My first approach was to write custom firmware, because I couldn't find any other solution, but overtime I realized that there can by some other solutions which can integrate with modbus like Tasmota or ESPHome. With Tasmota and ESPHome the same goal can be achived. In this project you can find all solutions that I tried:

I prefer ESPHome script, because of seamless integration with ESPHome including correct support for icon and device class.

Custom software is ok only for my use, because it's dedicated to my setup and my hardware, so I see some issues and it's hard to maintain this solution, comparing to Tasmota and ESPHome supports where there is huge community to support it.

Tasmota SMI script is not fully tested, but I'm leaving script maybe someone wants to use it for some other integrations for example Domoticz (my goal was HomeAssistant integration)

Images

Prototype

Final solution

sofarsolar_esp_rs485_logger's People

Contributors

markvader avatar maxgerhardt avatar pawelka avatar pawelkaridemia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sofarsolar_esp_rs485_logger's Issues

Brak danych z RS485

Witam

Posiadam model Sofara KTLX-G3 który ma złączę COM i USB
Próbowałem użyć złącza COM podłączając się do pinów 5 i 6

piny 1,2,3,4 = Monitorowanie falownika i sterowanie systemem
piny 5,6 Port miernika energii
pin 7 Uziemienie

Niestety nie dostaje żadnych danych (same zera) z ESPCAM które sflashowałem z funkcją monitoringu energii
Jest jakiś sposób na "zdebugowanie" problemu?

How i can debug what happened?

I make this project. Used ESP07 with different plate. I connect TXD, RXD, power supply. In project You show connectRS485 converter to 5V directly. Why? Logic work at 5V too, but ESP cannot. I damaged one ESP by this. Ok, i program new one, RXD led on module blink by 20-40ms every 5s (i set this interval) but nothing else not happened. TX LED not blinks, telnet show every 5s something like "took loop 2110", homeassistant not receive any mqtt data. In MQTT broker i see connected module, but no any data.
Please tell me about prepare inverter to work, how look correct log from telnet, how read raw data between ESP and HomeAssistant, how set correct topic, detailed pinout ESP<>RS485, Any way to debug why not work.....

Json from ESP local server

Hi, would it be possible to present data in json format on local (on ESP) Web server?
I want to integrate it with smart home solution based on plc.

I don't have mqtt server and gateway for my plc so it would be much easier to work with json or any other format with i can get by http request from.

Build for WemosD1 mini.

Dear Sir,

I would like to utilize Wemos D1 mini for this project. Will "esp-07.bin" work with this device ?
And how to connect RX and TX (Converter -> Wemos) ? Your prototype was connected: RX->D1 , TX->D2.
Thanks.

Sofar documentation

Hi,
if you still are interested Sofar documentation please email me - I cannot find your email here.

Check RS485 comunication

Thank your work on this.
Is there a way to test if the rs485 is working, and what would the baud rate be at the serial port to check comms with the uart to ttl adapter?
My setup:
I have the ESP-07 and an aliexpress rs485 adapter like the one in the photo, my inverter is a little different as the connection is a terminal block type not rj45. When I reset the ESP-07 I get an rs485 symbol on the display of the inverter but it goes out after a short time and I get nothing over MQTT. I am not sure if my adapter is ok or if something is not correct with programming of the ESP. Web interface is working and I can configure the device, I can also connect to the telnet.

KTL-X G3

Cześć, planujesz dopasować binarki pod wersje falowników G3? Aktualnie mimo odbioru danych i przesyłu na MQTT wartości są puste

{ "status": "off", "fault_message": "", "dc_voltage_1": 0, "dc_current_1": 0, "dc_voltage_2": 0, "dc_current_2": 0, "ac_power": 0, "ac_frequency": 0, "ac_voltage_1": 0, "ac_current_1": 0, "ac_voltage_2": 0, "ac_current_2": 0, "ac_voltage_3": 0, "ac_current_3": 0, "energy_total": 0, "running_time": 0, "energy_today": 0, "temperature_module": 0, "temperature_inverter": 0, "bus_voltage": 0, "vice_cpu_input_voltage_1": 0, "countdown_timer": 0, "pv1_insulation_resistance": 0, "pv2_insulation_resistance": 0, "isolation_impedance": 0, "country_code?": 0, "phase_a_distribution": 0, "phase_b_distribution": 0, "phase_c_distribution": 0 }

Does it work on Wemos??

been trying with this.. does it work?

played with the code... and also tried the Wemos bin file.. it just drops to the AP without trying mqtt etc

output just does

0:49:23.476 -> Loaded config 'iwcThingName'= 'sofarsolar2mqtt'
00:49:23.514 -> Loaded config 'iwcApPassword'= <hidden>
00:49:23.550 -> Loaded config 'iwcWifiSsid'= '<removed>'
00:49:23.588 -> Loaded config 'iwcWifiPassword'= <hidden>
00:49:23.625 -> Loaded config 'iwcApTimeout'= '30'
00:49:23.700 -> Loaded config 'mqttServer'= '10.0.1.7'
00:49:23.737 -> Loaded config 'mqttUser'= 'mqtt'
00:49:23.776 -> Loaded config 'mqttPass'= <hidden>
00:49:23.811 -> Loaded config 'mqttTopic'= 'Sofar'
00:49:23.846 -> Loaded config 'checkInterval'= '5'
00:49:23.883 -> SkipApStartup is requested, but either no WiFi was set up, or configButton was pressed.
00:49:23.956 -> AP password was not set in configuration
00:49:23.994 -> State changing from: 0 to 1
00:49:24.030 -> Setting up AP: sofarsolar2mqtt
00:49:24.066 -> With default password: <hidden>
00:49:24.099 -> AP IP address: 192.168.4.1
00:49:24.137 -> State changed from: 0 to 1
00:49:24.173 -> Connection to AP.

opened the config page multiple time and entered info.. it just never connects to the wifi or mqtt.. just opens the AP right away

energy meters

Did you test this solution for reading parameters from energy meters that have Modbus RTU, e.g. F&F LE-01MW?

SofarSolar MQTT Domoticz

Dobry wieczór, mam dwa pytania:
Czy może jest rozważany projekt identycznego loggera ale obsługującego Domoticza?
Jaki dokładnie rejestr odpowiada za "energy_today" ?

PDF sofar Communication Protocol

I've just to found a Communication Protocol file of sofar, at the moment i dont understand how to use it for measure, the energy I consume or feed into the grid.

PDF 1

PDF 2

I hope you like it @pawelka.

Also i have had to change the attributtes in esphome config due to not possible to add to the energy monitoring with statistics that has home assistant.
One example would be like this:

  - platform: modbus_controller
    modbus_controller_id: sofarsolar
    name: ${friendly_name} Energy today
    id: inverter_energy_today
    register_type: holding
    address: 0x0019
    unit_of_measurement: "kWh"
    device_class: "energy"
    state_class: "total_increasing"
    value_type: U_WORD
    accuracy_decimals: 2
    filters:
      - multiply: 0.01

device_class and state class needed for the problem i said
The info for resolve this problem. https://www.home-assistant.io/docs/energy/faq/#troubleshooting-missing-entities

Am I able to do it?

Hi there,
I am writing in english - maybe will be helpfull to somebody else, but I am polish. I guess there is such thing as private messages on github? I am interested in your project as I have Sofar KTL-X inverter. Thing is I have never had contact with anything like this in terms of software. Hardware is not a problem I found all the parts needed. I am engineer, handy man but never used any programming tools or language. The question is: am I able to do this basing an YT or web tutorials or would be better to stick to Solarman. Please advise here or on toolpusher13(malpka)gmail.com If you like to...
Cheers,
Piotr

"inverter_energy_total" not recognizsed as Energy entity

Obie wartości pomiaru energy [dzienny i total] nie dają się zastosować do pomiaru statystycznego oraz nie występują w panelu ENERGY.

Próbowałem dodać "sensor.sofarsolar_energy_today" lub "sensor.sofarsolar_energy_total" do panelu licznika energi, ale to entity nie zostaje wyświetlone podczas przeglądania listy. Posiadam także licznik ZAMEL MEW01 i pomiary energii [kWh] tego urzadzenia są wyświetlane. Myślę że problem jest nie z użytą [device_class: "power"] a brakiem [State class "total_increasing"].
Proszę o komentarz.

Pozdrawiam i dziękuję za udostępnienie integracji.

Jarek.

Tasmota?

Czy tasmote trzeba kompilować od nowa z tym dodatkiem ? czy jest gdzieś dostępny cały kod?jak dodać te ustawienia dodatkowe jak już jest zainstalowana tasmota?

Brakuje last_reset

Cześć,

Ładnie widzę dane z falownika, ale jak dodaję dzienną produkcję do zakładki Energia to dostaję takie info:

Last reset missing
The following entities have state class 'measurement' but 'last_reset' is missing:
sensor.sofarsolar_energy_today

No i oczywiście nie widzi, że coś falownik produkuje (w oknie wyboru widzi tylko produkcję dzienną - nie widzi mocy)

Pozdrawiam
Marcin

Fault register

My Sofar's Fault registers start from 0x0405 to 0x416, each register splits into two bytes and each byte splits into eight bits. How can I modify your code to read Faults?

  • platform: modbus_controller ## Inverter Fault Message ##
    modbus_controller_id: zcs ## Fault 1 ##
    name: Errore Inverter
    id: inverter_fault_message
    register_type: holding
    address: 0x0405
    skip_updates: 20
    response_size: 2
    lambda: |-
    std::string z = "";
    int idx = item->offset;
    //byte[0]
    if ((data[idx] & 0x1) != 0) z += "ID001 GridOVP,";
    if ((data[idx] & 0x2) != 0) z += "ID002 GridUVP,";
    if ((data[idx] & 0x4) != 0) z += "ID003 GridOFP,";
    if ((data[idx] & 0x8) != 0) z += "ID004 GridUFP,";
    if ((data[idx] & 0x128) != 0) z += "ID008 IslandFault,";

what should be written here?

 if(z.length() > 0){
    z.pop_back();
  }
  return {z};

Screenshot (45)
Screenshot (46)
Screenshot (47)

Feature doubt and request?

Does this give the following parameters?

today_generation
today_exported
today_purchase
today_consumption

Which MQTT library did you use ?

Hey Mate, Love what you have done here - i have a Solis 4G 3 phase unit and wish to adapt your code to work with that - trying to work out which of the ESP8266 MQTT libraries you used ?

I think i have worked out the other deps OK - just this one has got me stumped at the moment

Craig

Logger na nodemcu

Hej Paweł, zrobiłem ten logger na nodemcu zamiast ESP07. Widzę wszystkie encje w HA, ale ze statusem "nieznany" (oprócz sekcji Diagnostyka, tam encje są ok). Czy jakieś zmiany w kodzie ESPHome trzeba zrobić, aby to zaskoczyło?

ESPHome brak odczytu z falownika

Hej, zastosowałem twój projekt do odczytu mojego falownika, jednak falownik nie jest skory do rozmowy z esp.
Znaczek RS485 nie podświetla się na ekranie falownika po podłączeniu modułu a logi w ESPHome pokazują coś takiego:
[modbus_controller:029]: Modbus command to device=1 register=0x00 countdown=0 no response received - removed from send queue

no access point

Hello to all.
I was able to successfully flash esp-07.bin file on ESP07 with NodeMCU Flasher.
After the flash I unplug the card, move the selector from "program" to "uart", and restart it. But I can't find any access points to connect to.
What did I do wrong?
Thanks.
esp07

Missing Data

Hello.
Congratulations again for the excellent work
I switched from custom firmware to esphome
I noticed that this data is missing

pv1_insulation_resistance
pv2_insulation_resistance
isolation_impedance

is it possible to add them?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.