|
Hi,
I have the A16 wired up to a RS485 expansion board (16 inputs, 16 outputs) that is controlled by modbus RTU.
I have the ESP32 programmed with ESPHome. I can send commands to the expansion board, and I have control over the outputs (I see the onboard output-LEDs toggling), and I can see from the onboard communication LED on the expansion board that the expansion board sends a modbus response, but the ESP32 on the A16 does not receive anything on pin 16 (485RX).
I have verbose logs activated on the UART defined in ESPHome. I can see the raw bytes leaving on pin 13 (485TX), but no bytes are arriving on pin 16.
Obviously, I also cannot read the inputs of the expansion board (as that would require receiving the modbus response).
Are you sure that the RX pin number is correct? Could it be that I have a broken pcb trace?
Best regards,
Victor
P.S. Below is the relevant part of the esphome configuration
Code: logger:
level: VERY_VERBOSE
uart:
id: mod_bus
tx_pin: 13
rx_pin: 16
baud_rate: 9600 #115200
stop_bits: 1
debug:
direction: BOTH
dummy_receiver: false
after:
timeout: 1s
sequence:
- lambda: UARTDebug::log_hex(direction, bytes,' ');
modbus:
id: modbus1
send_wait_time: 250ms
disable_crc: true
modbus_controller:
- id: eletechsup
## the Modbus device addr
address: 0x1
modbus_id: modbus1
setup_priority: -10
sensor:
- platform: modbus_controller
modbus_controller_id: eletechsup
name: "read channel 1 state"
id: eletech_channel1_state
custom_command: [ 0x01, 0x03, 0x00, 0x01, 0x00, 0x01 ]
value_type: U_WORD
switch:
- platform: modbus_controller
modbus_controller_id: eletechsup
id: eletech_toggle_1
name: "Eletech toggle 1"
icon: "mdi:toggle-switch"
address: 0x1
register_type: holding
skip_updates: 0
lambda: |-
return true;
write_lambda: |-
ESP_LOGD("main","Modbus Switch incoming state = %f",x);
// return false ; // use this to just change the value
payload.push_back(0x1); // device address
payload.push_back(0x6); // write register
payload.push_back(0x0); // high byte address of the register
payload.push_back(0x1); // low byte address of the register
payload.push_back(0x3); // command (3=toggle)
payload.push_back(0x0); // delay (0)
return true;
|