Unable to send commands from an ESP-ETH01 controller to an audio amplifier via RS232 serial connection

Hello,
I’d like to control my audio amplifier from Home Assistant for on/off and volume up and down.

I have an ESP32-ETH01 controller connected via RJ45, equipped with a MAX3232 connector. The DB9 port is connected to my amplifier with a DB9 null modem cable (male/female).

I can’t get it to work. Absolutely nothing happens.

However, all the instructions worked when using the USB port directly between my Home Assistant PC and the amplifier.

I’ve tried other connectors, and each time I’ve also tested swapping the TX and RX ports, but nothing works.
Can anyone help me


ma carte max3232mon controlleur ESP32-ETH01?

esphome:
  name: primare-bridge3

esp32:
  board: esp32dev
  framework:
    type: arduino

# si on ne met pas la commande "power_pin: GPIO16"
# la carte ethernet n'est pas reconnue
ethernet:
  type: LAN8720
  mdc_pin: GPIO23
  mdio_pin: GPIO18
  clk_mode: GPIO0_IN
  phy_addr: 1
  power_pin: GPIO16

uart:
  id: uart_bus
  tx_pin: GPIO04
  rx_pin: GPIO32
  baud_rate: 4800
  stop_bits: 1
  data_bits: 8
  parity: NONE
  debug:
    direction: BOTH

# Création des boutons de commande 
# Ces commandes ont été testées en liaison serie directe sur mon PC HA
# avec l'instruction PRINTF   (car la commande  "echo -ne" ne fonctionnait pas)
button:
  - platform: template
    name: "Primare - Power ON"
    on_press:
      - uart.write: [0x02, 0x57, 0x0F, 0x02, 0x10, 0x03]

  - platform: template
    name: "Primare - Standby"
    on_press:
      - uart.write: [0x02, 0x57, 0x0F, 0x01, 0x10, 0x03]

  - platform: template
    name: "Primare - Mute"
    on_press:
      - uart.write: [0x02, 0x57, 0x0F, 0x31, 0x10, 0x03]

  - platform: template
    name: "Primare - Volume +"
    on_press:
      - uart.write: [0x02, 0x57, 0x0F, 0x10, 0x10, 0x10, 0x03]

  - platform: template
    name: "Primare - Volume -"
    on_press:
      - uart.write: [0x02, 0x57, 0x0F, 0x11, 0x10, 0x03]

  - platform: template
    name: "Primare - Entrée PLATIN"
    on_press:
      - uart.write: [0x02, 0x57, 0x0F, 0x3C, 0x10, 0x03]

  - platform: template
    name: "Primare - Entrée DAPHILE"
    on_press:
      - uart.write: [0x02, 0x57, 0x0F, 0x06, 0x10, 0x03]

# Service pour envoyer des commandes manuelles si besoin
api:
  services:
    - service: send_primare_command
      variables:
        payload: int[]
      then:
        - uart.write:
            id: uart_bus
            data: !lambda |-
              std::vector<uint8_t> data;
              for (auto val : payload) { data.push_back((uint8_t)val); }
              return data;

ota:
  - platform: esphome

logger:
  level: DEBUG
  baud_rate: 0

Perhaps my reasoning is flawed and my hardware configuration is unsuitable.
Do you have any ideas?
Thanks in advance.

Is null modem cable required here?
Is your baud rate correct?
Did you try other pins, those that don’t have any special function? 4 and 14 for example.
What you get on esphome logs?

Thank you very much for your help.

I’ve addressed each of your questions.

Is a null modem cable necessary?

Yes, because I ran tests in PC Home Assistant with my amplifier as a null modem, and from my Windows 11 PC as a null modem. It worked in both cases.

Is your baud rate correct?
My amplifier is a Primare I22, which requires a speed of 4800 baud.

In the two tests mentioned above, I specified a speed of 4800 baud.

Have you tried other pins, those without a specific function? For example, pins 4 and 14?

Yes, I also tried that. I tried pins 17 and 32, 17 and 5, and 4 and 32.

What information is displayed in the ESP Home logs?

No information is being received from the ESP32. Regarding the ESPHOME to ESP32 direction, I can see the command I’m sending, for example: “[17:45:44.051][D][button:022]: ‘Primare - Standby’ Pressed.
[17:45:44.164][D][uart_debug:113]: >>> 02:57:0F:01:10:03
[17:46:00.955][I][safe_mode:066]: Boot seems successful; resetting boot loop counter
[17:46:03.485][D][esp32.preferences:155]: Writing 1 items: 0 cached, 1 written, 0 failed”

What’s also strange is that the MAX3232 LED remains solid red and doesn’t blink when I send a command.

Here are some answers…

They don’t necessarily have rx/tx LEDs.
Since MAX is translator, not uart device, the correct wiring with esp is likely tx-tx, rx-rx.
Use gpio 4 and 14.
Connect DB9 pin 2 to pin 3 (nothing else connected), it should loop back the tx to esp rx. Do you get the rx on logs?

Hello
I connected pin 2 of the DB9 connector to pin 3 (with nothing else connected). The log is unchanged. I get the same message after issuing a command (in this case, power on): “[21:10:50.610][D][button:022]: ‘Primary - Power ON’ Pressed.
[21:10:50.723][D][uart_debug:113]: >>> 02:57:0F:02:10:03”

I think this means I’m not getting any response?

Yes, but you have to have everything spot on, esp wiring and the code…

Thank you…
My cable is exactly the one I showed in the photo of the board.

Do you think it’s a wiring problem?

And regarding the standards, I didn’t quite understand your comment. Are you referring to the standards my boards must meet? Could they be non-compliant?
In any case, I reflashed the board and I’m still getting the same result.

I mean, make sure your wiring is matching the uart component. tx to tx and rx to rx, gpio4 and 14.
Add this to your config, so you should see TX and RX hello every 5s.

interval:
  - interval: 5s
    then:
      - uart.write: "HELLO\r\n"

Hello
I modified the YAML file and updated the controller via OTA. I set TX (IO14) to TX and RI (IO4) to RI of the MAX3232.
I left the bridge in place to connect pins 2 and 3 of the DB9 connector.

I get this message every 5 seconds: “[08:26:56.017][D][uart_debug:113]: >>> 48:45:4C:4C:4F:0D:0A” and nothing else.
I don’t know what this means.

The hex you are seeing 48:45:4C:4C:4F is the ASCII code for “HELLO” followed by a carriage return and line feed. Looks like the outgoing message you are sending that @Karosm suggested.

I also tried swapping TX and RX, but leaving pins 2 and 3 connected to the DB9 connector.

I get this message: “[14:37:44.450][D][uart_debug:113]: >>> 48:45:4C:4C:4F:0D:0A
[14:37:44.571][D][uart_debug:113]: <<< 48:45:4C:4C:4F:0D:0A” A return signal is visible.

think.
So, I replied to @Karosm and I also tried swapping tx and rx. And I got a response. And in the yaml file, I had to add “dummy_receiver: true” to get the return.

Looks like you have two way comms first line is you sending ‘HELLO’ then it echoes it back to you by the looks.

So you are good to forward, up to DB9 connector hardware is correct now.
Remove the interval and try with your amplifier.

I removed the bridge and connected the amplifier. I flashed the controller and removed the “hello” test, leaving the following in the YAML file: “debug:
direction: BOTH
dummy_receiver: true”.

But nothing works.
I get the following message in the log:

“16:37:15.896][D][button:019]: ‘Primary - Volume +’ Pressed.
[16:37:15.999][D][uart_debug:113]: >>> 02:57:0F:10:10:10:03”.

It’s hopeless.
It seems like something else is interfering, but what? (Because I’m using the same RS232 commands that worked with a direct serial connection to the amplifier.)

For your information, during my serial connection tests with my PC’s Home Assistant, the PRINTF instruction worked, but the “echo -ne” command did not. Is UART write equivalent to PRINTF? I don’t know.

Your uart looks ok to me. To be sure form it like this.

  on_press:
    - uart.write:
        id: uart_bus
        data: [0x02, 0x57, 0x0F, 0x10, 0x10, 0x10, 0x03]

May be your MAX module crosses the rx/tx lines and with null cable it gets double-crossed. Can you measure voltage between gnd pin and pin3 on iddle and while sending?

Hello
I measured the voltages between pin GND (5th) and pin 3 (3rd from the right in the top row of 5 pins). I have nothing (0 volts) for a weak signal and nothing (0) for transmission.
My DB9 connector is female
I modified the YAML and reflashed.
My voltmeter is very basic and analog.

Hmm…
Your esp- MAX 3.3V/GND are surely connected?
Your chip is really MAX3232? You can see the marking with magnifying glass…

I also tried the same thing with pin 2. It’s different. Weak signal: I have a negative voltage. With a pulse, the voltmeter needle moves a little, while remaining negative.

Yes, I measured the voltage coming from the controller to the MAX3232, I have almost 8 volts
It is marked on the back: RS232 TO TTL