I have an AlphaESS Smile-SPB Energy Storage System (ESS). I wanted local control, a straightforward way to control my ESS from HA, and a clean integration, so I built the following:
This should work with many AlphaESS systems. There are photos, screenshots, hardware details and more. This project creates a plug-and-play device that uses MQTT auto-discovery so that once you built/program the hardware, then just plug it in, and the device and entities will appear in HA all ready to be used. Just like a clean integration, no further steps are needed to get the device/entities configured. Unique IDs, units, classes, icons and even entity availability are all provided. Everything is ready to be used by the Energy Dashboard and/or your own dashboards and automations.
I want to be very clear that this is heavily based on another project which is:
I owe a huge amount of credit to that project. Thank you! I made a lot of changes to that code in order to get here, but without that project, I would not have gotten here.
Thanks David, Iām pretty excited about this. Iāve compiled it ok ( I was missing a few libraries like wifiwebserver and wifimanager i think).
Just waiting on the rest of my hardware to arrive and the battery to be installed.
-Nic
Itās a bit early to tell yet. The installers are coming back for a 3rd time to try and get the system working.
Compiling went ok you will also need to install WiFiManager.h, WebServer.h, PubSubClient.h, Adafruit_GFX.h, Adafruit_SSD1306.h.
The screen all works, but so far I cannot get the unit to connect to HA and I cannot get it to connect to the Alpha.
Iāve used an ESP32 wroom (because thatās what i had), rather than the same one David used and I changed my mind and mounted it inside in an old hard drive case. All my other parts should be the same but theyāre from Ali express.
My run to the inverter is 15m so I have yet to try pluging it directly in to solve the modbus communication issue.
The HA communication has me stumped. I can see the unit on my network but nothing in the MQTT logs
Nice job. Your esp is talking to the WiFi, but wonāt even try to connect to MQTT until the RS485 connects. So ignore MQTT for now. The RS485 is looping over different baud rates to try to send/rcv a basic message, just to establish that it is working (it isnāt) and to get the system serial number. That bottom line on the display says that the code is using hardware UART #2 on gpios 16 (rx) and 17 (tx) and gpio 33 is control (EN). Are things truly wired that way? I canāt quite see in your image. Those pins numbers look right for the WROOM.
If thatās all correct, then check the RS485 wiring. Which RJ45 pins are A and B wired to?
If you havenāt plugged it into the inverter/EMS yet, then that is your next step. It wonāt get any further until you do.
Thanks David, that explains the MQTT. I wondered if that was the case.
OK Iāve had another look at this, the code says: #define SERIAL_COMMUNICATION_CONTROL_PIN 33 // Transmission set pin #define RX_PIN 8 // Serial Receive pin #define TX_PIN 7 // Serial Transmit pin #define HW_UART_NUM 2 // Hardware UART
nowhere there are pins 7, 8 or 33 listed.
Iāve guessed 6 & 8 are 17 & 16 from your wiring explanation but no one knows which is pin 33.
Iāve guessed and changed the code to #define SERIAL_COMMUNICATION_CONTROL_PIN 9 and the screen has stopped cycling through baud rates but just has the ip address there now.
Iāll check a direct connection to the inverter rather than my long cabling
Grrr⦠I do get frustrated how esp32s are āstandardā yet theyāre all different.
I donāt see where you see 8&7 in the code for RX&TX. In RS485Handler.h I see 16&17. If your selected board package is right, that should get you to the right pins for GPIO16 & GPIO17. Those should use those GPIOs because that corresponds to a hardware UART. As for the comm pin, the 33 means GPIO 33. But you can change that to any GPIO that you like.
comparing your photo to the pinout you pasted, It looks like you did connect RX&TX to D16&D17 which are GPIO16&GPIO17. Thatās good. And it looks like you wired EN on the MAX3485 to D19 on the ESP32 which your pinout says is GPIO19. So Iād try changing SERIAL_COMMUNICATION_CONTROL_PIN to the value 19 and see how that goes.
Thanks again David, this is where Iām at at the moment.
#define SERIAL_COMMUNICATION_CONTROL_PIN 19 // Transmission set pin
#define RX_PIN 16 // Serial Receive pin
#define TX_PIN 17 // Serial Transmit pin
#define HW_UART_NUM 2 // Hardware UART
Iām afraid itās still cycling through baud rates.
Iām going to purchase another MAX3485 before I spend any more time on this. As i said, this one came from ali express. In my experience the Chinese would happily sell fake chips to an aeroplane safety manufacturer.
I once spent 9 months trying to repair a recording console power supply. The first chip I replaced was the fault. The next fault was replacing it with a fake chip from china. It may be a week or so before I can grab the replacement.
Iāll update then.
Nic
In a previous msg you said you had a different config that wasnāt looping through baud rates. What was that? And what did the display say?
And how does the MAX3485 connect to the inverter? I am guessing you have an RJ45 connection on the inverter. Yes? And is A connected to pin 5 and B to pin 4?
Itās working!
your perseverance kept me at it, Though Iāve already gone and ordered 4 more max modules from different suppliers.
Turns out mine was ok (Sorry China for my harsh words).
The installers had unplugged the RJ45 AND, after plugging it in it still didnāt work. I noticed the plug looked damaged so I replaced the plug. Then the display got stuck on whatever baud it was testing. Checking again I discovered Iād left the A & B the wrong way around in testing. After sorting that itās all good.
It all shows up in Home Assistant as it should!!
@BMorgan1296
Yes it all appears to work great. @SeaMonster and Daniel Young have done an amazing job on this (A big thanks to both).
The only alteration needed for me was changing the SERIAL_COMMUNICATION_CONTROL_PIN to 19
I assume thatās only because I used a different ESP32 board to David
Iāve actually got what they call farmers 2 phase. I think thatās whats causing the installers problems. As I understand it, the 2 phases are 180Ė out rather than 120Ė.
Single phase solar. At the moment the system is still not functioning. solar and power work but the battery is all over the shop.
So ours just got installed yesterday. Also, a SMILE-G3-B5.
We have a CT meter installed to measure the 3 phases while having only a single phase battery inverter.
From what I can see, the CT meter is plugged in on one of the RS485 ports, and the battery COM on another.
Are the 4x RJ45 ports for RS485 sharing the same underlying interface? If not, how do they operate? I would assume the inverter would always āwantā to be master, but in this case the ESP32 is going to be master.
OK, let me start with a warning. I do not own a SMILE-G3 system. Mine is a SMILE-SPB system, which is quite different. Also, I am NOT an AlphaESS employee or even a trained AlphaESS technician. Iām just a geeky engineer with a EE who likes to tinker. Now, given thatā¦
I looked at the SMILE-G3 manual just now (easily found on the web) and it appears that the furthest right RJ-45 is for the BMS (battery) connection. The 3rd from the right is the CT meter connection. In your picture and description, these are connected, so that all lines up. The 2nd RJ45 from the right is the RS485/CANBUS and that is where I think you want to plug in. I doesnāt appear that all those RJ45s are a common RS485 bus. Rather each seems to have a specific purpose so they are most likely separately wired.
If you need to know how the ports operate Iām guessing you will need to get a copy of the schematic (which may be difficult).
The fact that this is working (plugged into the RS485 port), implies your assumptions about both the inverter and the ESP32 wanting to be master may be incorrect?
On the SMILE-SPB, the RJ45 labeled āCOMā is the RS485 where I plug in the Alpha2MQTT (esp32) and SMILE-SPB is NOT master. The Alpha systems definitely are designed to have a RS485/MODBUS port where they are not master.
So @worldvirus are you saying that you are plugged into that 2nd from the right RJ45? That would certainly confirm that it is the right port.
And @worldvirus any update on how your system is going? Did the installers ever figure out the last bits? Is Alpha2MQTT working right? I notice it isnāt recognizing your battery type. Thatās just cosmetic, but we can fix that.