Hello everyone,
I have the following problem in the Modbus area:
There are currently 6 devices in use, and a seventh has now been added, which communicates via Modbus ASCII. The existing ones communicate using TCP/RTU. The question is how to set up such a device in the .yaml.
I set the whole thing up as follows as a test, but it didn’t work.
I’m trying to connect an ABL emH1 to HA without EVCC. It works without any problems with EVCC, I use a Waveshare RS232 TO ETH (B).
However, the range of functions of EVCC is too high for my applications, so I need a “slim” solution.
I just stumpled upon this topic when looking for the ABL emH1 charger. I think I’m trying to do the exact same thing: connect the charger via a ESPHome + RS485 chip (sn75176) to Home Assistant.
I also tested with EVCC first, that works (Using pin 1+2 on RJ45 connector X2).
Next project is to make a two-way link between the charger and Home Assistant using ESPHome + Modbus Controller.
Please keep us informed about your progress, I will do the same!
I also have eMH1 and I would be very interested in similar setup (ESPHome + RS485). Do you have it working yet?
I did some Icmax modbus commands with an arduino + rs485 chip, but I’m not 100% certain how the LRC is calculated and hit a wall. Brute force iterated working LRC bytes so I can change the charging current though :D.
I wrote the Icmax value during charging when I brute force tested the LRC bytes without any issues so should be doable.
I was unable to find any complete MODBUS register list for the eMH1. All I got was this document:
…and re-reading it with open eyes I can see the register for Ic.
I changed the current Icmax at address 0x0014. The linked manual states: “Ic is internally limited to Icmax or Ics or other internal values (e.g. due to error conditions), whichever is lower”. As it worked, I didn’t bother to test other registers for limiting charging current.
It works with a laptop connected, running the ABL configuration software. But when I send the same code from the ESP, the charger seems to reboot itself, without changing the amps setting. Any code starting with :0110 (write) seems to do that, while :0103 (read) works fine.
Looking into your code, I noticed that in the emh1_modbus.cpp, there’s this line (361) in the current send subroutine:
uint16_t v = std::floor(16.67*x);
And in the end of the abl-emh1.yaml file:
min_value: 3
max_value: 32
step: 1
optimistic: false
lambda: "return (int)id(max_current) * 1.0; "
set_action:
lambda: |-
ESP_LOGD("main", "Sending modbus value = %f", x);
auto emh = new eMH1Modbus();
emh->send_current(x);
My limited understanding of these is, that the current is commanded in steps of 1, and e.g. 10A command would result in 166.7% Ic PWM setting to the Ic max register.
Any thoughts? Please take my input on your code with a grain of salt as I’m quite inexperienced programmer.
I found the bug, my code was creating a new instance of the class that sends the command to the ABL, instead of using the existing class. ESPHome still has a lot of secrets for me too!
Now my component works “more or less”, setting the amps works but not for all values. 10A and 16A work, but many others do not.
Most likely, cleaning up my code will fix that too. Will do that soon!
Stumbled upon this thread when doing research on how to connect the emh1 to homey. Rs485 and Serial interface is totally new for me so excuse my stupid questions. Anyway, from what I can see the emh1 support ascii mode on the Serial connection. Does all devices that convert from wifi/tcp to rs 485 support ascii mode or is there spesific ones that I should look for? I was looking at using the elfin-ew11a as a bridge between homey and the emh1 but not sure if that will work. Can I send the ascii commands on tcp aswell? Im a bit lost, so all help is appriciated.
The eMH1 supports modbus-ascii, most RS485-tcp adapters only do modbus-rtu. So if you can get one of those to talk modbus-ascii, it should work, but as far as I’ve seen, there’s people asking “how do I do that” but nobody saying “I just fixed this”.
Since my goal was not to support modbus-ascii on R486-tcp adapters but to get my ABL eMH1 working, I chose to make my own adapter based on a generic ESP32 and a serial->rs485 chip.
Hello,
Actually, it also has to work with a standard Modbus to TCP converter that does not speak Modbus ASCII (e.g. Waveshare RS485 TO ETH (B)), since this works in conjunction with EVCC.IO. Apparently the software converts Modbus ASCII. That’s exactly what I’m trying to recreate with Home Assistant’s on-board tools.
greeting
Michael