Modbus RTU and ESPHome #200
Replies: 9 comments 12 replies
-
What you really want to do is turn the ESP into a modbus proxy, so that the HA integration talks to the ESP over WiFi and then the ESP proxies the modbus-TCP into modbus over RS485. Surprisingly few hits on Github to do that, you'd think it would be quite a common thing to want to do? |
Beta Was this translation helpful? Give feedback.
-
I read that perhaps a recent SolarEdge firmware update enabled having MODBUS over WiFi. I haven't read more about this but you mentioned a SE WiFi module so I'm guessing you need that the WiFi they already have for the AP is different and can't be used for the MODBUS interface? I am a bit surprised that the solution I came up with doesn't appear to be used by anyone. It's far from ideal but it seems to be working and it a quick and somewhat easy solution for those not able to get an Ethernet cable to the inverter. That's still my ultimate goal but I was hoping for an interum solution for now. |
Beta Was this translation helpful? Give feedback.
-
Maybe I got lucky, but my inverter firmware never disabled modbus over WiFi. My inverter has the SE WiFi module in it and that enables the connection to solaredge cloud for the app and also allows modbus over TCP for this integration. I just had to enable modbus TCP in the inverter settings and then it just worked. Since it was installed I've pulled Ethernet round the house and now have a switch quite nearby the inverter, so at some point I should get around to cabling it in.... |
Beta Was this translation helpful? Give feedback.
-
My inverters were installed with hardwired Ethernet from day 1 so I've never had to look at any other options, but if I had to use something wireless I would probably try like a TP Link TL-WR802N since they're $23 on Amazon in the US. For me at that price it's not worth trying to do any custom workarounds. I could look into adding modbus/rtu serial support to the integration in addition to modbus/tcp if that would help. Maybe there's something that transparently bridges serial between two esp units instead of trying to convert it to tcp. |
Beta Was this translation helpful? Give feedback.
-
In case anyone comes across this thread I'll post what appears to be working for me:
I need to still clean up some sensors that were created during my testing that I've renamed and I think because I had this integration installed my sensor names are not coming through as solaredge_xxxx Note that in the SE spec if the register is |
Beta Was this translation helpful? Give feedback.
-
Maybe this would work: https://github.com/emelianov/modbus-esp8266/tree/master/examples/Bridge |
Beta Was this translation helpful? Give feedback.
-
Those do look interesting, I'll have to check them out later today when I have more time. I did work more on this over the weekend and finally got the bugs worked out and so far today it looks like it's handling the change in scale factors correctly. Even though ESPHome was reading multiple registers in one read when I used the
I did the same technique for status so in HA it displays the text version:
Probably would have been much easier just writing C code and not relying on ESPHome but I wasn't sure how to easily integrate with HA unless I piped the MODBUS to MQTT. Now I bet after I look at the 2 bridges you found I'll probably have wished I did more research before continuing down the ESPHome path! |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
So It's not a scope but I was able to enable
It does take 350ms for that to happen and it has a warning that it should only block for 20-30ms so I'm not sure what the best approach here is. I have the baud rate at 115,200 which I think is the highest SolarEdge supports. I could break up current, voltage, and power but then they would be out of sync when/if you tried to look at them together. I might have to pop on the ESPHome Developer Discord tomorrow and see if I can get anyone to take a quick look and offer any advice. There were maybe 20 scale changes today for power and the code worked for all of them except that one so at least that's a big improvement from the other day. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I've got an installation that doesn't afford connecting the inverter to ethernet easily. As a workaround I flashed a module with ESPHome and loaded Modbus and added sensors like this:
That works for now but I was wondering if anyone had any ideas on easily converting my setup in order to use this HA integration. The only idea I thought of was to drop ESPHome and write a program that uses RTU to read the inverter registers and then host a Modbus TCP to mimic an inverter. In theory that would work but that seems like a lot of work.
I know there's WiFi to Ethernet adapters that people have used but I already had this hardware so I thought I'd try it before throwing money at the "problem".
The other idea is that perhaps if I just create sensors with the same names as this integration then everything else would just work but there seems to be a bunch of sensors created and I'm not sure if all of them is needed.
Beta Was this translation helpful? Give feedback.
All reactions