按照mb_serial_master和mb_serial_slave的要求搭建了环境,用的是MAX485转TTL模块
参考链接
https://github.com/espressif/esp-idf/bl ... /README.md
https://github.com/espressif/esp-idf/bl ... /README.md
我的芯片是ESP32-S3,用了2个S3开发版,1个做Master,1个做Slave
MAX485 线路接线参考/serial/mb_master/README.md
idf.py menuconfig master和slave都配置了GPIO
MAX485 TTL 到 RS485模块 与 ESP32 的连接应如下所示:
MAX485 TTL 转 RS485 >> VCC >> ESP32的+5V
MAX485 TTL 转 RS485 >> GND >> ESP32 的 GND
MAX485 TTL 转 RS485 >> ESP32 的 RO >> GPIO39
MAX485 TTL 转 RS485 >> DI >> ESP32 的 GPIO40
MAX485 TTL 转 RS485 >> RE >> ESP32 的 GPIO41
MAX485 TTL 转 RS485 >> DE >> ESP32 的 GPIO41
DE和RE共同接了ESP32S3的GPIO41
应用程序的示例输出和/mb_master/README.md列的不一样,我的输出是这样的
I (3124) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 2.560000 (0x4023d70a) read successful.
W (3134) TRANS_INFO: Id: 2843752, Addr: 1, FC: 0x3, Exception: 0, Err: 4
W (3144) USER_ERR_CB: The transaction 2876908, error type: 4
W (3154) Received buffer: 04 04 d7 0a 40 63
W (3154) Sent buffer: 04 00 04 00 02
I (3164) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 3.560000 (0x4063d70a) read successful.
W (3174) TRANS_INFO: Id: 2876908, Addr: 1, FC: 0x4, Exception: 0, Err: 4
W (3184) USER_ERR_CB: The transaction 2910145, error type: 4
W (3184) Received buffer: 03 04 eb 85 40 71
W (3194) Sent buffer: 03 00 4e 00 02
I (3194) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 3.780000 (0x4071eb85) read successful.
W (3204) TRANS_INFO: Id: 2910145, Addr: 1, FC: 0x3, Exception: 0, Err: 4
W (3224) USER_ERR_CB: The transaction 2943290, error type: 4
W (3224) Received buffer: 03 74 aa aa aa aa aa aa aa aa aa aa aa aa aa aa
W (3224) Received buffer: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa
W (3234) Received buffer: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa
W (3244) Received buffer: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa
W (3254) Received buffer: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa
W (3254) Received buffer: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa
W (3264) Received buffer: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa
W (3274) Received buffer: aa aa aa aa aa aa
W (3274) Sent buffer: 03 00 52 00 3a
I (3284) MASTER_TEST: Characteristic #6 Test_regs (__) value = (0xaaaaaaaa) read successful.
W (3294) USER_ERR_CB: The transaction 3024506, error type: 4
W (3294) Received buffer: 01 01 15
W (3304) Sent buffer: 01 00 02 00 06
I (3304) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x15) read successful.
W (3314) USER_ERR_CB: The transaction 3048445, error type: 4
W (3324) Received buffer: 01 01 2a
W (3324) Sent buffer: 01 00 0a 00 06
I (3334) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x2a) read successful.
W (3344) USER_ERR_CB: The transaction 3072422, error type: 4
W (3344) Received buffer: 02 01 15
W (3354) Sent buffer: 02 00 02 00 07
I (3354) MASTER_TEST: Characteristic #9 DiscreteInpP1 (on/off) value = OFF (0x15) read successful.
W (3364) USER_ERR_CB: The transaction 3096895, error type: 4
W (3374) Received buffer: 03 04 00 55 00 55
W (3374) Sent buffer: 03 00 00 00 02
一直报USER_ERR_CB错误,不知道error type: 4是啥意思
代码本身未做修改,主要是改了配置,定义了GPIO 引脚,用于 UART 连接。
esp-modbus-1.0.16的serial应用程序的示例输出不正确,问题出在哪?
Who is online
Users browsing this forum: No registered users and 24 guests