Reference
Last revision 2025/12/14
The article provides detailed guidance on configuring and utilizing the IIC to dual UART module, including library installation, communication protocol description, API usage, and baud rate settings, allowing users to integrate efficient serial communication into their projects.
Communication Protocol Description
The IIC to dual UART module is a non-standard IIC device with various addresses. IIC address has 7 bits. When running the IIC scanning program, as long as the upper 4 bits are the same as that of the module, and there will be reponse. So you can scan multiple IIC addresses with same upper 4 bits on one module.
Module IIC Configuration:
| Bit | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|
| Value | IA1 | IA0 | 1 | 0 | C1 | C0 | 0/1 |
- The 6th bit: IA1 corresponds with the value of DIP switch Al on the module.
- The 5th bit: IA0 corresponds with the value of DIP switch A0 on the module.
The relation between DIP switch and IA1/IA0:
| A1 | A0 | IA1 | IA0 |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 |
- The 4th bit: fixed, 1.
- The 3rd bit: fixed, 0.
- The 2nd and 1st bits: C1/C0 represents the sub UART channel number, for example. 00 for UART1, 01 for UART2.
- The 0 bit: represents the operation object, 0 for register, 1 for FIFO.
API Description
Constructor
When construct IIC to dual UART object, it is required to specify the sub UART(UART1 or UART2) and the value of IA1 and IA0. The constructor is shown below:
DFRobot_IIC_Serial(TwoWire &wire = Wire, uint8_t subUartChannel = SUBUART_CHANNEL_1, uint8_t IA1 = 1, uint8_t IA0 = 1);
- For operating UART1, pass the parameter SUBUART_CHANNEL_1; for UART2, pass SUBUART_CHANNEL_2;
- If the status of the DIP switch on the module is A1(1),A0(0), then we should pass parameters 1 and 0 to the formal parameter IA1 and IA0.
For example, turn the DIP switch A1 to 1, A0 to 0;
- Construct object, UART1;
DFRobot_IIC_Serial iicSerial(Wire, SUBUART_CHANNEL_1, /*IA1=*/1, /*IA0=*/0);//consctruct object UART1
- Construct object, UART2;
DFRobot_IIC_Serial iicSerial(Wire, SUBUART_CHANNEL_2, /*IA1=*/1, /*IA0=*/0);//construct object UART2
Baud Rate Configuration
Just like other hardware serial ports, the baud rate of the extended UARTs on the module need to be set. For instance, set UART1 to 9600, UART2 to 115200, as shown below:
iicSerial1.begin(9600); //init UART1, set baud rate to 9600
iicSerial2.begin(115200); //init UART2, set baud rate to 115200
The IIC to dual UART module adopts 14.7456M crystal oscillator, and it supports the following baud rate:
| NO. | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|---|---|---|---|---|---|---|---|---|
| Baud Rate | 2400 | 4800 | 57600 | 7200 | 9600 | 14400 | 19200 | 28800 |
| Baud Rate | 38400 | 76800 | 115200 | 153600 | 230400 | 460800 | 307200 | 921600 |
Users can directly use the above baud rate or define their own baud rate, such as 12800, etc.
Since crystal oscillator and baud rate are closely related, and not all baud rates are supported by the former. So users have to do test on their own when using user-defined baud rate.
Was this article helpful?
