AlphaESS RS485 plug-and-play local controller

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.

I appreciate any feedback, comments, etc.

2 Likes

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

Very cool. Let me know if I can help. What system are you installing?

Alpha ESS Smile-G3-B5. I’m copying your setup so we’ll see how i go.
Hopefully wont have too many questions, but i’ll post back when it’s done

Any luck? Looking at the same model. Does this project work or does it require modification?

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.

Good luck and let us know how it proceeds…

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

My problem is these pin numbers


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. :slight_smile:
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

What does the bottom line on the display say?

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

1 Like

Nice! Can you send a screenshot of the MQTT device page in HA?

ignore the data. apart from state of charge and solar all the other figures are wrong.
The installers are having trouble getting this going

Congrats!

Out of interest do you have a 3 phase system, and how does the hookup work with solar there as well?

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.

Hi,

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.