-
Notifications
You must be signed in to change notification settings - Fork 4
How to change UART pin
Quốc Hùng edited this page Dec 29, 2022
·
3 revisions
Default Modbus UART pin
Board | ESP32 | ESP8266 | STM32 | Raspberry Pi |
---|---|---|---|---|
RX | 16 | 14 | PA3 | 15 |
TX | 17 | 12 | PA2 | 14 |
Method 1:
Change it by adding the following two define lines
#define MODBUS_RXD_Pin <newRxPin>
#define MODBUS_TXD_Pin <newTxPin>
Before
#define ERA_AUTH_TOKEN "*"
Method 2:
Create HardwareSerial object
HardwareSerial serialMB(1);
Then using
serialMB.begin(9600, SERIAL_8N1, newRxPin, newTxPin);
ERa.setModbusStream(serialMB);
Before
ERa.begin();
Create ERaSerialLinux object
ERaSerialLinux serialMB;
Then using
serialMB.begin("/dev/*", 9600);
ERa.setModbusStream(serialMB);
Before
ERa.begin();
Create HardwareSerial object
HardwareSerial serialMB(newRxPin, newTxPin);
or SoftwareSerial object
SoftwareSerial serialMB(newRxPin, newTxPin);
Then using
serialMB.begin(9600);
ERa.setModbusStream(serialMB);
Before
ERa.begin();
If board have Modbus DE pin then using
ERa.setModbusDEPin(dePin);
Before
ERa.begin();
Default Zigbee UART pin
Board | ESP32 | Raspberry Pi |
---|---|---|
RX | 32 | USB |
TX | 33 | USB |
Method 1:
Change it by adding the following two define lines
#define ZIGBEE_RXD_Pin <newRxPin>
#define ZIGBEE_TXD_Pin <newTxPin>
Before
#define ERA_AUTH_TOKEN "*"
Method 2:
Create HardwareSerial object
HardwareSerial serialZB(1);
Then using
serialZB.begin(115200, SERIAL_8N1, newRxPin, newTxPin);
ERa.setZigbeeStream(serialZB);
Before
ERa.begin();
Create ERaSerialLinux object
ERaSerialLinux serialZB;
Then using
serialZB.begin("/dev/*", 115200);
ERa.setModbusStream(serialZB);
Before
ERa.begin();