Community
OpenEnergyMonitor

Community

Getting data from inverters via an RS485 connection

rs485
Tags: #<Tag:0x00007f16a60e8df0>

(Alan Sullivan ) #1

Hi. Been trying to get some code to read RS485 on my GoodWe inverter but all attempts so far have failed. Is your code available somewhere online if you are happy to share your approach.
Had Emoncms up and running for many rears now and also use Node-Red to control my heating with Slexa and a cheap 4ch really board over WiFi and the inverter input is the final part of my puzzle. Alan


My Electric Bar Graphs
(Ian Rogers) #2

I emailed the manufacturer of my inverter (Ginlong) and asked them for the communications protocol infrormation and they sent it to me, they used modbus rtu over the RS485 to communicate with the inverter.

I wrote a very basic edit of the example program using C# nuget packages in VS 2017, NModbus and NModbus.serial (not Nmodbus4, I couldn’t get that to work over serial)

I then just modified their example to read the registers and do a http get to the appropriate address to send the data to my emoncms server.

This has a timer controlling the fetch interval.

The software runs on a windows 10 PC using task scheduler to act as a watchdog (run every 5mins if it is not already running, but it is so simple and there is nothing else really on the PC so it doesn’t crash)

I have just received my emonpi and I installed it and various additional sensors to support the data from the inverter (temp sensor for hot water tank, CT clamp for hot water divert, pulse counter for generation meter)

My current plan is to finish my node red flow I have been working on this afternoon to monitor the hot water temperature and at specific times during the day send a command to the hive thermostat to boost heating if the solar has not generated sufficient hot water, but to then continue monitoring the temperature of the hot water and stop the boost depending on the measured temperature (this temperature will be different at different times of the day and days of the week)

Once I have done that, I have saved various discussions on how others have implemented the rs485 modbus rtu fetch in pi, and how to forward the data into the emonhub such that it then gets buffered and stored in the event of the remote server going down.
I have previously set up a python script to run as a service on a pi zeros, so I will try and implement this pi rs485script as a service on the pi with a watchdog if possible.

As I get to these I will be happy to share the code on how rs485 has been implemented.


(Alan Sullivan ) #3

Hi Ian,

I have a GoodWe 1000NS inverter also known as a Replus 1000TL2E with Wifi, USB and RS485 and I would be keen to hear your experiences of getting the data into Emoncms as its the last thing I would like to do on my system that I have had up and running for 4 years now. Any advice welcomed as I have tried a few options from Github with no success on USB or RS485.

Alan


Testing new device module integration
(Alan Sullivan ) #4

I look forward to any insight that you may have and I will contact the UK arm of the Goodwe Inverter to get the relevant spec. No C+ genius but once I have the ground rules I can usually work it through as I did for the 4CH relay board and several other project here with Node Red and others.

Will keep my eyes open for an update.

Alan


(Ian Rogers) #5

I managed to get the hive integration working this weekend.

When I get the rs485 functions working on the pi I will share it with you.

If you get the communications protocol from Goodwe PM it to me and I will take a look at it at the same time and see if I can do a version for your inverter.

I’m not totally sure what language it will be yet it depends on what modbus modules are available and the results from each.

If you don’t have an rs485 interface yet, I would recommend USB-RS485-WE-1800-BT which is what I have used for my inverter.


(Ian Rogers) #6

Hello Alan,

I have now got my emon-pi fetching data from the Solis-4G inverter (using FTDI USB-RS485-WE-1800-BT RS485-USB adatper) and forwarding the data to the Emonhub running on the emonpi using the socket interfacer functions.

The emonhub then forwards it to my main installation of emoncms.

The program has been written as a one-shot python script that is repeatedly called from a node-red flow conifugred to call it every 5 seconds, (after lots of research, I found that python does not seem to have a timer function that will run every 5 seconds, it only has functions that will delay 5 seconds after other code has been called! which is then dependent on execution time of the code).

The advantages of using the socket interfacer to the emonhub rather than just putting it straight into the emoncms are:

  • emonhub will buffer these messages so if the emoncms server is down the data will then be sent once the emoncms recovers
  • the data is also published to MQTT and so can be used in node-red flows.
  • the data can also be published to the secondary emoncms servers or emoncms.org configured in the emonhub configuration

I have uploaded the python file and instructions here:

I hope this helps in getting your interface to work.
Ian


(Bill Thomson) #7

Indeed it doesn’t. However, Advanced Python Scheduler can schedule events down to one second intervals, and uses a syntax that’s very similar to cron.

I use it to invoke a python script at 5 second intervals to read a WattsOn Modbus based headless kWh meter.

There’s a thread on the forum about reading an Eastron SDM220 Wh meter that has the details.


(Ian Rogers) #8

Hello @Bill.Thomson

Thanks for the feedback. I must admit I didnt find anything about the Advanced Python Scheduler when I was looking.

Main benefits for using Node-RED as the scheduler for me were that it is already installed and running on the emonpi and I was already using it for interfacing to hive to control the gas-hot-water heating. (Alan above has also been using Node-RED too).

I know I found quite a lot of information around the forum advocating minimalmodbus and doing the data collection which was useful as the basis for the python RS485 interface to collect the information from the inverter.

Howerver, I found only one reference to using the socket interfacer, but it was very useful as it detailed the issues experienced in getting it working, Unfortunately I did not find anything on how build the packet structure in python to send data to the socket interfacer in emonhub which I was keen to do.

My previous incarnation of this program was written in C# and ran on a windows PC, that version sent it directly to my main emoncms installation, however didnt have the benefits of the MQTT, buffering and being able to send to multiple emoncms installations offered by feeding it directly into the emohub functions.

Ian


(Alan Sullivan ) #9

Hi All,

After many hours of breaking down the code from the original thread on GitHub, I finally have the USB feed from my GoodWe1000TL2E inverter supply an update every 10 seconds to my Raspberry Pi and I added in some MQTT capabilities to send the information into Emoncms locally and then I have use Node-red to share the info in a basic Dashboard which I intend to put into HTML 5 when I get 5 min.

My main issue was that in a part of the code it was looking for data in the received which didn’t exist on my inverter. It was after something in response location [66] and my responses only went uptown [46].
So after fixing that data started to flow and then I had to change the code to reflect what was in my response and remove many used objects.

When I get 10 min I will upload my altered code just in case it helps anyone else onto GitHub with the relevant references to the original code…

Thanks to Ian Rogers who inspired me to try again after a 6 month gap and the fact the inverter supplier now has no UK presence as the unit I have was made by GoodWe for Renesola.

Now onto my next project with ESP8266 and e-paper displays.

Alan