You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/hardware/03.nano/boards/nano-r4/tutorials/01.user-manual/content.md
+172-4Lines changed: 172 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,7 +63,7 @@ The bottom view of the Nano R4 board is shown in the image below:
63
63
Here is an overview of the board's main components shown in the images above:
64
64
65
65
-**Microcontroller**: At the heart of the Nano R4 board there is a Renesas RA4M1 family microcontroller ([R7FA4M1AB3CFM](https://www.renesas.com/en/document/dst/ra4m1-group-datasheet?srsltid=AfmBOoryT-HIws0lHBASVG1QdfHDNWNQ5FNnoQV3hpoQ0FbncC7FI3h4)). This single-chip microcontroller, recognized as one of the industry's most energy-efficient microcontroller, is based on a 48 MHz Arm® Cortex®-M4 core with up to 256 KB of flash memory and 32 KB of SRAM memory.
66
-
-**USB-C® connector**: The Nano R4 board features a modern USB-C connector for programming, power supply and serial communication with the external world.
66
+
-**USB-C connector**: The Nano R4 board features a modern USB-C connector for programming, power supply and serial communication with the external world.
67
67
-**Qwiic connector**: The Nano R4 board also includes an onboard Qwiic connector to expand the board's communication capabilities via I²C, facilitating connection with a wide range of boards, sensors, actuators and different peripherals.
68
68
69
69
-**Programmable RGB LED**: The Nano R4 board has an onboard user-programmable RGB LED to provide visual feedback about different operating states.
@@ -1383,6 +1383,172 @@ When working with EEPROM on the Nano R4, there are several key points to keep in
1383
1383
- Keep in mind that EEPROM stores data as individual bytes (0 to 255), so larger data types need to be broken down or use the `put()` and `get()` functions for automatic handling.
1384
1384
- The EEPROM retains data for over 10 years under normal conditions, making it excellent for long-term storage of configuration data and user preferences.
1385
1385
1386
+
## UART Communication
1387
+
1388
+
The Nano R4 board features built-in UART (Universal Asynchronous Receiver-Transmitter) communication that allows your projects to communicate with other devices through serial data transmission. UART is implemented within the RA4M1 microcontroller and provides two separate hardware serial ports: one connected to the USB-C connector for computer communication, and another available on pins `D0` and `D1` for external device communication. This makes it perfect for projects that need to communicate with sensors, modules or other microcontrollers while maintaining USB connectivity for debugging.
1389
+
1390
+
UART is particularly useful when your project needs to communicate with devices that require simple, reliable serial communication, rather than the more complex protocols like SPI or I²C. While SPI excels at high-speed communication and I²C is ideal for multiple device networks, UART provides straightforward point-to-point communication that works well with GPS modules, Bluetooth® modules, Wi-Fi® modules and other serial devices. UART communication is asynchronous, meaning it doesn't require a shared clock signal, making it robust over longer distances.
1391
+
1392
+
The Nano R4's UART interface offers the following technical specifications:
You can communicate via UART using the built-in `Serial` and `Serial1` objects. The `Serial` object is connected to the USB-C port for computer communication, while `Serial1` is connected to pins `D0` and `D1` for external device communication.
1412
+
1413
+
The following example demonstrates basic UART communication patterns:
1414
+
1415
+
```arduino
1416
+
/**
1417
+
UART Basic Example for the Arduino Nano R4 Board
1418
+
Name: nano_r4_uart_basic.ino
1419
+
Purpose: This sketch demonstrates basic UART communication
1420
+
using both USB Serial and hardware Serial1.
1421
+
1422
+
@author Arduino Product Experience Team
1423
+
@version 1.0 01/06/25
1424
+
*/
1425
+
1426
+
void setup() {
1427
+
// Initialize USB serial communication at 115200 baud
// Initialize hardware serial on pins D0/D1 at 9600 baud
1432
+
Serial1.begin(9600);
1433
+
1434
+
Serial.println("- Arduino Nano R4 - UART Basic Example started...");
1435
+
Serial.println("- USB Serial (Serial): 115200 baud");
1436
+
Serial.println("- Hardware Serial (Serial1): 9600 baud on D0/D1");
1437
+
Serial.println("- Connect logic analyzer to D0 (RX) and D1 (TX)");
1438
+
Serial.println("- Type messages in Serial Monitor to send via Serial1");
1439
+
Serial.println();
1440
+
}
1441
+
1442
+
void loop() {
1443
+
// Check for data from USB Serial (computer)
1444
+
if (Serial.available()) {
1445
+
String message = Serial.readString();
1446
+
1447
+
// Remove newline characters
1448
+
message.trim();
1449
+
1450
+
if (message.length() > 0) {
1451
+
Serial.print("- USB received: \"");
1452
+
Serial.print(message);
1453
+
Serial.println("\"");
1454
+
1455
+
// Send the message via Serial1 (D0/D1)
1456
+
Serial1.print("- Message from USB: ");
1457
+
Serial1.println(message);
1458
+
1459
+
Serial.println("- Message sent via Serial1 (D0/D1)!");
1460
+
}
1461
+
}
1462
+
1463
+
// Check for data from Serial1 (external device on D0/D1)
1464
+
if (Serial1.available()) {
1465
+
String response = Serial1.readString();
1466
+
1467
+
// Remove newline characters
1468
+
response.trim();
1469
+
1470
+
if (response.length() > 0) {
1471
+
Serial.print("- Serial1 received: \"");
1472
+
Serial.print(response);
1473
+
Serial.println("\"");
1474
+
}
1475
+
}
1476
+
1477
+
// Send periodic test data via Serial1
1478
+
static unsigned long lastSend = 0;
1479
+
if (millis() - lastSend > 3000) {
1480
+
lastSend = millis();
1481
+
1482
+
// Send test data with timestamp
1483
+
Serial1.print("Test data: ");
1484
+
Serial1.print(millis());
1485
+
Serial1.println(" ms");
1486
+
1487
+
Serial.println("- Periodic test data sent via Serial1!");
1488
+
}
1489
+
1490
+
delay(10);
1491
+
}
1492
+
```
1493
+
1494
+
***To test this example, no external UART devices are required, the code will demonstrate UART communication patterns that can be observed with a logic analyzer. You can type messages in the Arduino IDE's Serial Monitor to see them transmitted via `Serial1` on pins `D0`/`D1`.***
1495
+
1496
+
You can open the Arduino IDE's Serial Monitor (Tools > Serial Monitor) to interact with the USB serial port and observe the communication patterns. Connect a logic analyzer to pins `D0` (RX) and `D1` (TX) to observe the actual UART protocol signals.
1497
+
1498
+
The image below shows how the UART communication from our example appears in the Digilent Waveforms logic analyzer software, with the decoded protocol showing the transmitted data bytes and timing.
1499
+
1500
+
The Nano R4 board provides two distinct UART communication channels, giving you the flexibility to handle multiple communication tasks simultaneously. The first channel is the USB Serial (`Serial`), which is your primary interface for programming and debugging. This channel offers several key features:
1501
+
1502
+
- Connected to the onboard USB-C connector
1503
+
- Used for programming and debugging
1504
+
- Typically runs at 115200 baud
1505
+
- Automatic baud rate detection
1506
+
- No external connections required
1507
+
1508
+
The second channel is the Hardware Serial (`Serial1`), which is dedicated to external device communication. This channel provides robust connectivity for your project peripherals:
1509
+
1510
+
- Connected to pins `D0` (RX) and `D1` (TX)
1511
+
- Used for external device communication
1512
+
- Configurable baud rate (300 to 2000000)
1513
+
- TTL voltage levels (0 VDC/+5 VDC)
1514
+
- Requires external device connection
1515
+
1516
+
Here is a practical example of how to use both UART channels simultaneously, such as when connecting a GPS module:
1517
+
1518
+
```arduino
1519
+
// Example: Connecting a GPS module via Serial1
1520
+
void setup() {
1521
+
Serial.begin(115200); // USB debugging
1522
+
Serial1.begin(9600); // GPS module communication
1523
+
1524
+
Serial.println("GPS module communication started");
1525
+
}
1526
+
1527
+
void loop() {
1528
+
// Forward GPS data to USB Serial for monitoring
1529
+
if (Serial1.available()) {
1530
+
String gpsData = Serial1.readString();
1531
+
Serial.print("GPS: ");
1532
+
Serial.print(gpsData);
1533
+
}
1534
+
1535
+
// Send commands to GPS module from USB Serial
1536
+
if (Serial.available()) {
1537
+
String command = Serial.readString();
1538
+
Serial1.print(command);
1539
+
Serial.println("Command sent to GPS");
1540
+
}
1541
+
}
1542
+
```
1543
+
1544
+
When working with UART on the Nano R4, there are several key points to keep in mind for successful implementation:
1545
+
1546
+
- The dual UART design is different from the UNO R3 that shared one UART between USB and pins D0/D1. This separation allows simultaneous USB debugging and external device communication.
1547
+
- Always ensure that both devices use the same baud rate, data bits (typically 8), and stop bits (typically 1) for successful communication.
1548
+
- Keep in mind that UART communication uses TTL voltage levels (0 VDC for logic LOW, +5 VDC for logic HIGH). If you need to communicate over longer distances or with RS232 devices, you'll need a level converter.
1549
+
- When connecting external devices, remember that TX connects to RX and RX connects to TX (crossover connection).
1550
+
- The Nano R4's UART ports are full-duplex, meaning they can send and receive data simultaneously, making them perfect for interactive communication with modules like GPS, Bluetooth®, Wi-Fi®, or other microcontrollers.
1551
+
1386
1552
## SPI Communication
1387
1553
1388
1554
The Nano R4 board features built-in SPI (Serial Peripheral Interface) communication that allows your projects to communicate with external devices like sensors, displays, memory cards and other microcontrollers. SPI is implemented within the RA4M1 microcontroller and uses four dedicated pins to provide high-speed synchronous serial communication.
@@ -1650,17 +1816,19 @@ void loop() {
1650
1816
Serial.println("---");
1651
1817
}
1652
1818
```
1653
-
***To test this example, no external I²C devices are required. The code will generate I²C communication patterns that can be analized with a protocol analyzer. Without devices connected, read operations will typically return `0xFF`.***
1819
+
***To test this example, no external I²C devices are required. The code will generate I²C communication patterns that can be analyzed with a protocol analyzer. Without devices connected, read operations will typically return `0xFF`.***
1654
1820
1655
1821
You can open the Arduino IDE's Serial Monitor (Tools > Serial Monitor) to see the I²C operations being performed. Connect a protocol analyzer to pins `A4` (SDA) and `A5` (SCL) to observe the actual I²C protocol signals.
1656
1822
1657
1823

1658
1824
1659
1825
The image below shows how the I²C communication from our example appears in the Digilent Waveforms logic analyzer software, with the decoded protocol showing the device address and data bytes being transmitted.
1660
1826
1661
-
***The I²C protocol requires pull-up resistors on both SDA and SCL lines. __The Nano R4 board does not have internal pull-ups on A4 and A5 to avoid interference with their analog input functionality, so external 4.7kΩ pull-up resistors to +5 VDC are required for proper I²C operation__.***
1827
+

1828
+
1829
+
***The I²C protocol requires pull-up resistors on both SDA and SCL lines. __The Nano R4 board does not have internal pull-ups on `A4` and `A5` to avoid interference with their analog input functionality, so external 4.7kΩ pull-up resistors to +5 VDC are required for proper I²C operation__.***
1662
1830
1663
-
One of the main advantages of I²C is the ability to connect multiple devices to the same bus. Here's how to connect multiple I²C devices:
1831
+
One of the main advantages of I²C is the ability to connect multiple devices to the same bus. Here is how to connect multiple I²C devices:
1664
1832
1665
1833
```arduino
1666
1834
// Example: Communicating with multiple I2C devices
0 commit comments