# Sunways NT4000 The Sunways NT4000 is a solar inverter. It stores data locally, which can be retrieved via eighter a RS485 or a RS232 interface. When using multiple Sunways inverters, you can connect them to each other via the RS485 interface, so that one acts as master and handles the communication. ### RS485 Interface This serial interface is used for communication with the inverters. With the help of for example the [HALJIA USB zu RS485 Konverter](https://www.amazon.de/RS485-Konverter-Converter-Adapter-Unterst%C2%A8%C2%B9tzung/dp/B06Y1JTGZX/ref=sr_1_5?__mk_de_DE=%C3%85M%C3%85%C5%BD%C3%95%C3%91&crid=3D1KW5V0ERBP4&keywords=usb+rs+485&qid=1644772202&s=ce-de&sprefix=usb+rs+485%2Celectronics%2C106&sr=1-5) you can connect the inverters to your computer or Raspberry Pi. For me I could only communicate via RS485 when the inverters where actually receiving solar power. [![USB_to_RS485.png](https://bookstack.greinet.com/uploads/images/gallery/2022-02/scaled-1680-/usb-to-rs485.png)](https://bookstack.greinet.com/uploads/images/gallery/2022-02/usb-to-rs485.png) ### Settings for the Interface
Baud rate9600
Data bits8
ParityNone
Stop bits1
Handshakenone
### Software There are multiple different software solutions to read and write data via software. The software from the manufacturer is called *Sunways Monitor 2.0*, but it is not available for download anymore. #### FHEM Another software to communicate with the inverters is the house automation software **FHEM***.* It support many different modules and Prof. Dr. Peter A. Henning created a module for Sunways NT inverters called [NT5000](https://github.com/mhop/fhem-mirror/blob/master/fhem/contrib/70_NT5000.pm) (seems to be moved to [70\_SolarView](https://github.com/mhop/fhem-mirror/blob/master/fhem/contrib/70_SolarView.pm)). Targeted actually at the NT5000, the inverters NT1800, NT2600, NT4000 and NT6000 have the same protocol. Further information can be found in the [wiki](https://wiki.fhem.de/wiki/NT5000). To use the module you firstly need to get your FHEM installation up and running, for example as docker container. There you need to mount a volume for the configuration to be persistent and also pass the USB device to the container. ``` docker run -d -p 8083:8083 --device=/dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0:/dev/ttyUSB0 -v /home/pi/fhem:/opt/fhem fhem/fhem ``` After that you need to copy the 70\_NT5000.pm ([fhem.txt](https://bookstack.greinet.com/attachments/244)) file from contrib to the FHEM folder so that the module can be loaded. Test if the module can be loaded by running the command **reload NT5000** on the FHEM web interface. If it succeeds, you can then create the solar module object by running **define solar NT5000 /dev/ttyUSB0**. Then you should see the values of the inverter on the website. Sadly I could not find any option to get support for multiple inverters. So the only way to use this software with multiple inverters would be to wire each inverter to the computer on its own. Publishing the received data can be done for example via MQTT. ``` define mosquitto MQTT : define mqttGeneric MQTT_GENERIC_BRIDGE attr mqttGeneric IODev mosquitto attr mqttGeneric globalPublish *:topic={"/$device/$reading"} ``` Example config: [config.txt](https://bookstack.greinet.com/attachments/247) #### SolarView aka SolarMax-Proxy Another software to read and write the data is [SolarView](https://www.solarview.info/default.aspx), a data logger for various solar inverters. While it doesn't support Sunways support out of the gate, a community member of [this forum](https://www.photovoltaikforum.com/) created a proxy for the inverters. The software proxies the Sunways inverter to act like a SolarMax inverter, which the software supports. The solarmax-proxy is available on [SourceForge](https://sourceforge.net/projects/solarmax-proxy/), but no longer maintained by the the original creator. In [this thread](https://www.photovoltaikforum.com/thread/38605-sunways-wechselrichter-mit-solarview-betreiben-smp/) the evolution and usage of the proxy is discussed and also multiple different binary files where shared. Here are multiple files saved for preservation: - [solarmax-proxy-code.zip](https://bookstack.greinet.com/attachments/114) - [ssl\_7-patch.zip](https://bookstack.greinet.com/attachments/115) - [smp\_rpi single always log message only with parameter debug.zip](https://bookstack.greinet.com/attachments/116) - [smp-0.21-mipsel.zip](https://bookstack.greinet.com/attachments/117) - [smp\_v0.23 code and binary rpi and 7390.zip](https://bookstack.greinet.com/attachments/118) - [smp 0.22 all binaries 7170 7270 73xx 7272 7490 x86 rpi.zip](https://bookstack.greinet.com/attachments/120) - [smp 0.22 all binaries 7170 7270 73xx 7272 7490 x86 rpi NEW.zip](https://bookstack.greinet.com/attachments/119) - [smp 0.22.zip](https://bookstack.greinet.com/attachments/121) - [smp compiled to raspberry pi changed for clear code.zip](https://bookstack.greinet.com/attachments/122) - [smp compiled for raspberry pi.zip](https://bookstack.greinet.com/attachments/123) - [useful\_infos.txt](https://bookstack.greinet.com/attachments/124) The requirement for smp to work are: - RS485 from the inverter connected to a serial to network adapter (or connected to the raspberry pi and forwarded via ser2net software via network) - SMP connected to the adapter - SolarView configured to use SMP as SolarMax inverter Example calls: - ./smp -c 1 -l 11200 -f /var/log/smp.log - ./smp -c 2 -l 11200 - ./smp -t 5 -c 1 -f smp.log -l 5000 - ./smp.rpi -h 192.168.178.74 -p 6000 -d 2 -c 3 -f smp.log As all these step dont seem like a stable solution for me, I did not try this route, but the source code gained from this proxy was more than helpful. #### Python Script Which leads to the last software, a little python script written by myself. As it still is a work in progress, here is the current version of the software. [test-2.py](https://bookstack.greinet.com/attachments/125) Backup: [SMP.zip](https://bookstack.greinet.com/attachments/245) and [SUNWAYS.zip](https://bookstack.greinet.com/attachments/246) Example output: [![stats.png](https://bookstack.greinet.com/uploads/images/gallery/2022-07/scaled-1680-/stats.png)](https://bookstack.greinet.com/uploads/images/gallery/2022-07/stats.png) ### Working Software - [sunways.zip](https://bookstack.greinet.com/attachments/396) File collection backup: [Multiusb.zip](https://bookstack.greinet.com/attachments/248)