Giter VIP home page Giter VIP logo

hyd6000's Introduction

title author tags categories date
Sofar HYD6000-ES ModbusRead
Andy Whittaker
Modbus, Node-RED, Emon, RS485, Sofar Inverter, Hybrid, HYD6000-ES
Solar PV
2020-05-28

Sofar HYD6000-ES ModbusRead

This is a very badly written Python Script to Request and Read Data from the HYD6000 Inverter RS485 Port and Write To EmonCMS (or EmonPi).

Since we require the script to be called at regular intervals, I have also included a very simple Node-RED script to call the Python code (currently) at 30 second intervals.

Interfacing with the HYD6000

We require to interface between the Raspberry Pi and the Sofar HYD6000 inverter via RS485. On the bottom of the HYD6000 you can find the interface connections.

Sofar HYD6000 Interfaces

The CAN/485m connection goes off to the batteries. However, the next interface available is the RS485s connection, Sofar even gives you the correct connector to plug-in (it looks to me like a Phoenix/ Weidmüller Type).

We now need a cheap USB to RS485 (which is a two wire interface) to allow us to connect to our Raspberry Pi. Note RS485 is completely different from RS232, do not attempt to use the wrong interface. log-on to eBay and search for RS422 interfaces and you will have one in your possession within a few days. If you would like to read up about the differences between RS232, RS422 and RS485, please have a short Google search for them. RS422 and RS485 are similar, just full-duplex verses half-duplex.

RS485 Interface

Link the interface up with the inverter with a length of CAT5 pair of wire. Be sure to match-up the + and - connections on either end. In my case, TX- connects to D- and TX+ connects to D+.

Modbus

A quick word on the inverter (and almost all that I have seen) is that they communicate over the ModBus Protocol. This is entirely different from whether you are connected via RS232, RS422, RS485, TCP/IP, etc.

They have been used for Industrial Applications since the beginning of time! You can’t talk to them via a terminal by randomly typing in commands, nothing will work. You need a ModBus (generally) RTU emulator but the good news is that there are many available to download.

Setting up the Raspberry Pi

EmonPi

The guys over at openenergymonitor.org have created a really easy guide to have your Raspberry Pi up and running with emoncms in no time. If you would like to use emonpi head along to their GitHub repository and follow the instructions.

Don’t forget to do the usual sudo apt update && sudo apt full-upgradeafterwards to ensure your Pi is up to date. While you are setting up, make sure you enable SSH access so that you don’t have to connect a monitor and keyboard while you set the whole thing up.

For SSH access I love the Bitvise SSH Client because it not only allows you to bring up the remote bash console but it also enables you to exchange files with your PC. This is incredibly valuable when you are developing or setting up the Pi. It also allows you to copy to other UNIX devices as well.

On the PC end, I think NotePad++ is the editor to use at the moment.

USB Interface

Plug the USB RS485 interface into a spare USB port and reboot the Pi. SSH back in and type dmesg | grep ttydmesg displays a copy of the Pi’s boot log and grep does a search through it for anything that matches tty. This will give you the port number that your interface is attached to (look for ttyUSB0 or similar).

Once you know the USB port name, you will have to update its name within the sofar.py file, look for instrument = minimalmodbus.Instrument('/dev/ttyUSB0', 1) # port name, slave address.
For debugging, simply remove the comment lines (#) in front of the print statements.

Executing the Code

Assuming you can see sofar,py when you type “ls”, then to run it type python sofar.pyIf you get any errors, you are probably missing some python libraries which you will need to install using “pip”. Google is your friend here.

Node-RED

If your script is working, you need a way of executing it every, say, 30 seconds to log to the emonCMS database to give you pretty graphs to bore your friends with.

Node-RED Timer Script

The node-RED setup actually took me the longest to complete. I was looking everywhere to find a solution and downloading libraries and all sorts. In the end it was quite easy.
If you would like the above flow, it’s available in the repository under flows.json.

The Future

Everything we all do is never finished. I would like to get the script to write to my Domoticz server and, in future, instruct the inverter to charge up its batteries during cheap rate electricity.

Oh, did I mention batteries? I have adopted PylonTech US3000 units because they seem to be the best value units on the market (2020). Although this inverter will allow you to charge from your mains supply, this is actually frowned upon (i.e. illegal) here in the UK because every time you discharge the batteries, they are being metered as energy from your SolarPV panels. If you were to charge them from the mains during the night, you will probably be visited by some very angry men who will be in no mood for humour…

An alternative that anyone could do is to use the LuxPower LXP 3600ACS inverter. This is just wired up to your mains supply and is able to charge the batteries when it sees your system trying to export to the grid. By clever voltage monitoring, if export drops, it then discharges the batteries into your home. From what I can see, the Lux LXP 3600ACS is able to be monitored and controlled by ModBus. The only downside is that these inverters are limited to a maximum discharge load of 3600W unless you run them in parallel.

hyd6000's People

Contributors

andywhittaker avatar

Stargazers

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

Watchers

 avatar

hyd6000's Issues

485 port and can port do not work together

Hi,

I made a connection with the 485 port a few weeks ago. The battery was not installed yet, but the technician came today.

The inverter gives an error when connecting the batteries with the CAN port while the 485 port is connected as well.

Is there someone else having this issue? Are there people who are using the CAN port and 485 at the same time?

Modbus protocol

hello, sofarsolar sent me a file with the full modbus protocol used in this inverter. I can send it to you if you want

In french:
bonjour, sofarsolar m'a envoyé un fichier avec le protocole modbus complet utilisé dans cet onduleur. Je peux vous l'envoyer si vous voulez

amendment for FIT vs SEG

the readme says "every time you discharge the batteries, they are being metered as energy from your SolarPV panels"

this matters if you are receiving FIT payments

if you're on SEG, with a smart meter, then you don't get FIT payments and therefore charging the battery off the mains doesn't matter. I have a Sofar+pylontech combo and I have set it to top up at 03:40 to 04:20 from the cheap Octopus Go tariff, this puts in enough charge to carry us through the peak rate pricing until sunrise.

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.