Modbus ASCII

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.

- name: 'EthernetGW4'
  type: tcp
  port: 504
  host: 192.168.0.43
  delay: 5
  timeout: 5
  sensors:
    - name: sensor_ascii_test_1                                                  
      slave: 1                                                             
      address: 51
      input_type: holding
      count: 6
      data_type: string

Using Modbus Poll I was able to establish a connection that also showed me correct results.

However, the corresponding address entered in the .yaml does not work - am I thinking wrong?

The address displayed refers to the following register:

Does anyone have an idea or hint for me?

Best regards
Michael

Hello everyone,

I’ve experimented a bit, but unfortunately still no solution…

Maybe someone else has a “crazy idea”

Try with: method: ascii

I dont know if it work in tcp

ASCII mode does not work with TCP

1 Like

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.

Hi Michael,

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!

Hi jrv

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.

Thank you!

Kind regards, Esa

Hi Esa,
It’s still work in progress… I made a ESPHome configuration that can talk modbus-ascii to the eMH1. Reading values works fine but I also want to change the Amps while charging. That part doesn’t work yet.
You can see my struggles at GitHub - jrv/esphome-abl-emh1: Esphome component for communication with ABL Wallbox eMH1
You can compile your own by downloading the abl-emh1.yaml file in there.

Hi jrv

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

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.

What issues did you run into?

Kind regards, Esa

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.

My code for creating the LRC seems to work fine, it creates the same output as I see when sniffing the ABL configurator output.

I wrote the Icmax register at 25 ms periods without any issues :thinking:

Hi jrv

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.

Kind regards, Esa

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!

This is excellent news!

Ok, it works, at least it’s doing what i need it to do:

  • shows the current on three phases
  • shows the status of the charger (waiting for EV, permission to charge, charging, output disabled)
  • allows you to change the max current while charging, car will adapt charge current
  • allows you to start and stop charging

The github repository is updated, I released v1.0 today: GitHub - jrv/esphome-abl-emh1: Esphome component for communication with ABL Wallbox eMH1

My component has it’sown topic on this forum now: Connecting the ABL eMH1 EV charger as ESPHome Component

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. :face_with_peeking_eye: 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. :blush:

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.

1 Like

Thanks, that clarified a lot! will need to investigate further. It seems I can send HEX, but not sure if that helps. :slight_smile:

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