Supported models:
ME3000SP - Full support
HYD-xx00-ES - Full support
Sofar2mqtt is a remote control interface for Sofar solar and battery inverters.
It allows remote control of the inverter and reports the invertor status, power usage, battery state etc for integration with smart home systems such as Home Assistant and Node-Red.
For read only mode, it will send status messages without the inverter needing to be in passive mode.
It's designed to run on an ESP8266 microcontroller with a TTL to RS485 module such as MAX485 or MAX3485.
Designed to work with TTL modules with or without the DR and RE flow control pins. If your TTL module does not have these pins then just ignore the wire from D5.
Subscribe your MQTT client to:
sofar2mqtt/state
Which provides:
running_state
grid_voltage
grid_current
grid_freq
battery_power
battery_voltage
battery_current
batterySOC
battery_temp
battery_cycles
grid_power
consumption
solarPV
today_generation
today_exported
today_purchase
today_consumption
inverter_temp
inverterHS_temp
solarPVAmps
With the inverter in Passive Mode, send MQTT messages to:
sofar2mqtt/set/standby - send value "true"
sofar2mqtt/set/auto - send value "true" or "battery_save"
sofar2mqtt/set/charge - send values in the range 0-3000 (watts)
sofar2mqtt/set/discharge - send values in the range 0-3000 (watts)
battery_save is a hybrid auto mode that will charge from excess solar but not discharge.
(c)Colin McGerty 2021 [email protected]
Thanks to Rich Platts for hybrid model code and testing.
calcCRC by [email protected] and [email protected]
Parts List:
- ESP8266 Microcontroller
- MAX485 or MAX3485 TTL to RS485 board
- Wemos 64x48 OLED Screen (optional)
- A small project board
- A few wires and a little solder
Cut the project board to a convenient size.
Wire the components according to this circuit diagram.
I tend to keep the wires on top of the board, poke them through and solder underneath. Your approach may be better and your soldering will almost certainly be better than mine!
Make sure you connect the DR and RE pins together. The red arrow below shows where a single wire from D5 connects to both DR and RE. (If you are using a TTL board without the DR and RE pins, ignore this step.)
Use long pinned mounts on your ESP8266 if you are stacking the optional OLED on top. Trim the legs so they fit comfortably into the sockets on the circuit board below.
I don't recommend soldering the ESP8266 permanently to your circuit board.
Here's how it looks when completed.
Open either ME3000SP.ino or HYBRID.ino (as appropriate for your inverter model) in the Arduino IDE.
Edit it with your wifi network name and password and your mqtt server details. If you need more than one Sofar2mqtt on your network, make sure you give them unique device names.
You'll need the libraries for the ESP8266. Follow this guide if you haven't completed that step before.
Add a few more libraries using the Manage Libraries menu:
- PubSubClient
- Adafruit GFX
- Adafruit SSD1306 Wemos Mini OLED
(Even if you are not using the OLED screen, you should install the Adafruit libraries or it will not compile.)
...and upload.
Run it on the desktop, not connected to you invertor, to test that wifi and mqtt are connected and see some messages in the serial monitor. The OLED screen should show "Online" to indicate a connection to WiFi and MQTT. It will alternate between "RS485 Error" and "CRC-FAULT" to indicate that the inverter is not connected.
Connect the Sofar2mqtt unit to a 5v micro USB power supply. Now connect wires A and B to the two wire RS485 input of your inverter, which is marked as 485s on the image of the ME3000SP below.
Nothing on the OLED screen? Make sure you solder all the pins on the OLED and ESP8266, not just those with wires attached.
No communication with the inverter? Make sure the slave IDs match. Sofar2mqtt assumes slave ID 1 by default. You can change this around line 93 or in the inverter user interface. But they must be the same.
Here's what the various things on the OLED screen tell you:
Line 1 is the device name, nothing else.
Line 2 will display "Connecting" during start up and lines 3 and 4 will show WIFI and MQTT getting connected.
Line 2 also has a dot that slowly flashes, once every few seconds. This is when a heartbeat message is being sent to the inverter.
If a message is read from the inverter that fails the CRC checksum, line 3 will display "CRC-FAULT". This could be caused by a loose or bad RS485 wire or by unsupported features. A few of these is normal, a lot could indicate a problem.
If no response is received to a heartbeat message, lines 3 and 4 show "RS485 ERROR". This could be caused by disconnected or reversed RS485 wires.
During start-up, line 4 shows the Sofar2mqtt software version. Check that you have the latest version at https://github.com/cmcgerty/Sofar2MQTT
In normal operation, line 2 shows "Online" which indicates that both WIFI and MQTT are still connected.
In normal operation, line 3 shows the inverter run state, Standby, Charging, Discharging etc.
In normal operation, line 4 shows the power in Watts in or out of the batteries when charging or discharging.