sorry, i wrote 0x02 instead of 0x01
[17:22:33][D][uart_debug:114]: >>> 81 03 00 30 00 01 9B C5
[17:22:33][W][modbus:144]: Got Modbus frame from unknown address 0x51!
[17:22:33][D][uart_debug:114]: <<< 51 03 02 00 41 B8 78
[17:22:33][D][uart_debug:114]: >>> 81 03 00 30 00 01 9B C5
[17:22:33][W][modbus:144]: Got Modbus frame from unknown address 0x51!
[17:22:33][D][uart_debug:114]: <<< 51 03 02 00 41 B8 78
[17:22:33][D][uart_debug:114]: >>> 81 03 00 30 00 01 9B C5
[17:22:33][W][modbus:144]: Got Modbus frame from unknown address 0x51!
And it doesn’t pass it to the sensor value, right?
I had a quick look at modbus library and I think there is no way to get the data with it.
But you could get it from uart debug and output it in template sensor.
is there an example of how to do this?
I have never tried, but I’m positive that you can make it.
Read the documentation for debugging
and have a look at this thread:
No idea what’s going on there. Some parameters incorrect I guess.
Modbus request is always 8 bytes and reply for single register is always 7 bytes.
So the logic would be: if byte 0 is 0x51, result is byte 4
this is uart log
uart:
tx_pin: D6
rx_pin: D7
baud_rate: 9600
debug:
direction: BOTH
dummy_receiver: true
# after:
# delimiter: "\Q\x03"
# bytes: 127
sequence:
- lambda: |-
UARTDebug::log_string(direction, bytes);
UARTDebug::log_hex(direction, bytes, ':');
ESP_LOGD("main", "Response data only had %d bytes!!", bytes.size() );
interval:
- interval: 5sec
then:
- uart.write: [0x81, 0x03, 0x00, 0x00, 0x00, 0x7F, 0x1B, 0xEA]
I think you should have just one uart debug, try to remove the first line of your lambda.
Also, do you have automatic flow control on your rs485-converter ? Or DE RE pins?
The code above is the connection via uart.
To connect via rs485, other pins and an adapter are used
Deleting a row in a lambda does nothing
Data comes with different lengths
So even this was received without RS485 ?
it was received by rs485
I don’t follow you. Your BMS have options to communicate(modbus) through TTL or Rs485?
my BMS has both UART and RS485 connections
with identic protocol?
good news. I began to consistently receive 259 bytes per UART
the description of the protocols is identical
More importantly they begin with 51 !
Ok from there grab the byte 4 and you are good to go
Edit: response doesn’t look good even if it starts so…
You should go back to code where output is like this:
[17:22:33][D][uart_debug:114]: <<< 51 03 02 00 41 B8 78
[17:22:33][D][uart_debug:114]: >>> 81 03 00 30 00 01 9B C5
Requesting either with modbus component or just with uart without additional debug code.
When you have solid 7 bytes response, try with simple code
baud_rate: 9600
debug:
direction: BOTH
dummy_receiver: false
after:
delimiter: "\n"
sequence:
- lambda: |-
UARTDebug::log_hex(direction, bytes, ':');
ESP_LOGD("main", "Response data only had %d bytes!!", bytes.size() );
The problem is that on rs485 I get different response lengths. but through the UART connection I began to receive consistently the same length of response