Giter VIP home page Giter VIP logo

hyd6000's Introduction

title author tags categories date
Sofar HYD6000-ES ModbusRead
Andy Whittaker, Matt Morgan
Modbus, Emon, RS485, Sofar Inverter, Hybrid, HYD6000-ES
Solar PV
2021-05-11

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 CRONTAB command and run script to call the Python code (currently) at 5 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.

Auto Publish Results

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

Add the CRONTAB command from the CRONTAB file, and reboot.

hyd6000's People

Contributors

andywhittaker avatar changeableface avatar

Watchers

James Cloos avatar

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.