![]() |
|
MODBUS - Printable Version +- Smart Home Automation Forum (https://www.kincony.com/forum) +-- Forum: Technical Support (https://www.kincony.com/forum/forumdisplay.php?fid=20) +--- Forum: KC868-A2v3 (https://www.kincony.com/forum/forumdisplay.php?fid=77) +--- Thread: MODBUS (/showthread.php?tid=9355) |
MODBUS - frasanc - 05-25-2026 We have a question about reading Modbus RTU: With A2: RS485: RXD:35 TXD:32 With A2V3: RS485: RXD:GPIO15 TXD:GPIO7 With A2 can read, but not with A2V3. Any idea? // A2v3: HardwareSerial MBus(1); MBus.begin(9600, SERIAL_8N1, 15, 7); pinMode(4, INPUT); // modo auto // A2: HardwareSerial MBus(2); MBus.begin(9600, SERIAL_8N1, 35, 32); ModbusMaster node; node.begin(1, MBus); uint8_t r = node.readInputRegisters(6, 2); // FC04 @ PDU 6 Someone could help us? RE: MODBUS - admin - 05-25-2026 you can try to exchange RXD and TXD pin. RE: MODBUS - frasanc - 05-25-2026 ![]() We use that PIN photo to identify A-B PIN. // src/modbus_reader.cpp void ModbusReader::applyUartPins(uint32_t baudRate) { int8_t rxPin = RS485_RX_PIN; // 15 int8_t txPin = RS485_TX_PIN; // 7 if (s_rs485SwapTxRx) { rxPin = RS485_TX_PIN; // swap: begin(9600, 8N1, 7, 15) txPin = RS485_RX_PIN; } _serial.begin(baudRate, MODBUS_SERIAL_CFG, rxPin, txPin); } ```cpp ModbusResult ModbusReader::readInputRegisters(uint8_t slaveId, uint16_t startAddress, uint8_t count) { flushRxQuiet(); _node.begin(slaveId, _serial); uint8_t status = _node.readInputRegisters(startAddress, count); silentBusGapAfterFrame(); // On success: values = _node.getResponseBuffer(i); } I put here some examples I'm following, including change pin number according your suggestion but is not working. I don't know if there is som example for that board. RE: MODBUS - admin - 05-25-2026 here is KC868-A2v3 board RS485 arduino demo code, you can test with it. https://www.kincony.com/forum/showthread.php?tid=7962 RE: MODBUS - frasanc - 05-26-2026 Thanks for your link...I detect my mistake and now works fine. RE: MODBUS - admin - 05-26-2026 ok, good. |