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
+122-6Lines changed: 122 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1102,9 +1102,9 @@ For best results, connect an oscilloscope to pin `A0` to visualize the smooth si
1102
1102
1103
1103
## Real-Time Clock (RTC)
1104
1104
1105
-
The Nano R4 features a built-in Real-Time Clock (RTC) that allows your projects to keep track of date and time. The RTC is integrated within the RA4M1 microcontroller and can maintain accurate timekeeping for applications that require scheduling, data logging or time-based events. With optional backup power support, the RTC can continue running even when the main power is disconnected.
1105
+
The Nano R4 features a built-in Real-Time Clock (RTC) that allows your projects to keep track of date and time. The RTC is integrated within the RA4M1 microcontroller and can maintain accurate timekeeping for applications that require scheduling, data logging or time-based events. With optional backup power support via the board's `VBATT` pin, the RTC can continue running even when the main power is disconnected, using a 100-year calendar from 2000 to 2099 that automatically adjusts dates for leap years.
1106
1106
1107
-
The RTC provides accurate timekeeping with a 100-year calendar from 2000 to 2099 that automatically adjusts dates for leap years. It can maintain time and date information even when the main power is disconnected by using an optional backup battery.
1107
+
The RTC is particularly useful when your project needs to know the actual date and time, rather than just measuring time intervals. While Arduino functions like `millis()`and `delay()` are perfect for timing operations (like blinking an LED every second), the RTC is essential for applications like data loggers that need timestamps, alarm clocks, scheduling systems or any project that needs to know "what time is it right now?" even after being powered off and on again.
1108
1108
1109
1109
The Nano R4's RTC offers the following technical specifications:
1110
1110
@@ -1223,11 +1223,12 @@ To maintain RTC timekeeping when the main power is disconnected, you can connect
1223
1223
- Connect the positive terminal of a 3V coin cell battery (CR2032) to the `VBATT` pin of the board
1224
1224
- Connect the negative terminal of the battery to `GND`
1225
1225
1226
-
With this configuration, the board's RTC will continue running on backup power when main power is removed. You can also set the board's RTC time programmatically using the following functions:
1226
+
With this configuration, the board's RTC will continue running on backup power when main power is removed. You can also set the board's RTC time programmatically using the following format. Remember to update the date and time values to match the current date when you upload your sketch:
When working with the RTC on the Nano R4, there are several key points to keep in mind for successful implementation:
1237
1238
1238
1239
-**The RTC requires an initial time setting** before it can provide accurate timekeeping, so make sure to configure the date and time when you first start your project. For applications that need continuous timekeeping even when the main power is disconnected, connecting a backup battery to the VBATT pin is highly recommended.
1239
-
- Keep in mind that **the RTC stores time exactly as you set it**, so you'll need to handle time zone conversions and daylight saving time adjustments in your application code if needed.
1240
+
- Keep in mind that **the RTC stores time exactly as you set it**, so you'll need to handle time zone conversions and daylight saving time adjustments in your application code if needed.
1241
+
1242
+
## EEPROM (Non-Volatile Memory)
1243
+
1244
+
The Nano R4 board features built-in EEPROM (Electrically Erasable Programmable Read-Only Memory) that allows your projects to store data permanently, even when the board is powered off. The EEPROM is implemented using flash memory emulation within the RA4M1 microcontroller and provides 8 KB of non-volatile storage space for applications that need to remember settings, sensor calibrations, or user preferences between power cycles.
1245
+
1246
+
EEPROM is particularly useful when your project needs to remember information permanently, rather than just during program execution. While variables stored in SRAM are lost when power is removed, EEPROM retains data indefinitely. This makes it essential for applications like saving user preferences, storing sensor calibration values, keeping configuration settings, or any project that needs to "remember" data even after being unplugged and reconnected.
1247
+
1248
+
The Nano R4's EEPROM offers the following technical specifications:
| Memory Type | Data flash memory | SuperFlash® technology |
1254
+
| Write Cycles | 100,000 | Program/erase cycles max |
1255
+
| Programming Unit | 64-bit | Minimum write unit |
1256
+
| Erase Unit | 1 KB | Minimum erase unit |
1257
+
| Read Speed | 6 clock cycles | Time to read data |
1258
+
| Retention Time | 10+ years | Data retention period |
1259
+
| Operating Voltage | +5 VDC | Same as board |
1260
+
1261
+
You can read and write to EEPROM using the dedicated `<EEPROM.h>` library, which is included in the Arduino UNO R4 Boards core. The library provides simple functions to store and retrieve individual bytes or larger data structures.
1262
+
1263
+
The following example demonstrates how to store and retrieve data from EEPROM:
1264
+
1265
+
```arduino
1266
+
/**
1267
+
EEPROM Basic Example for the Arduino Nano R4 Board
1268
+
Name: nano_r4_eeprom_basic.ino
1269
+
Purpose: This sketch demonstrates how to store and retrieve data
1270
+
from the built-in EEPROM memory.
1271
+
1272
+
@author Arduino Product Experience Team
1273
+
@version 1.0 01/06/25
1274
+
*/
1275
+
1276
+
#include <EEPROM.h>
1277
+
1278
+
void setup() {
1279
+
// Initialize serial communication at 115200 baud
1280
+
Serial.begin(115200);
1281
+
1282
+
Serial.println("- Arduino Nano R4 - EEPROM Basic Example started...");
1283
+
1284
+
// Read a counter from EEPROM address 0
1285
+
int bootCounter = EEPROM.read(0);
1286
+
1287
+
// If this is the first time (EEPROM starts with 255), set counter to 0
1288
+
if (bootCounter == 255) {
1289
+
bootCounter = 0;
1290
+
Serial.println("- First boot detected!");
1291
+
}
1292
+
1293
+
// Add 1 to the counter
1294
+
bootCounter = bootCounter + 1;
1295
+
1296
+
// Save the new counter value to EEPROM
1297
+
EEPROM.write(0, bootCounter);
1298
+
1299
+
// Show the results
1300
+
Serial.print("- This board has been reset ");
1301
+
Serial.print(bootCounter);
1302
+
Serial.println(" times");
1303
+
1304
+
// Store a user preference (LED brightness)
1305
+
int brightness = 128; // Value from 0 to 255
1306
+
EEPROM.write(1, brightness);
1307
+
Serial.print("- LED brightness setting saved: ");
1308
+
Serial.println(brightness);
1309
+
1310
+
// Read the brightness setting back
1311
+
int savedBrightness = EEPROM.read(1);
1312
+
Serial.print("- LED brightness setting loaded: ");
1313
+
Serial.println(savedBrightness);
1314
+
1315
+
Serial.println("- Reset the board to see the counter increase!");
1316
+
}
1317
+
1318
+
void loop() {
1319
+
// Nothing to do in the loop
1320
+
// The counter only increases when you reset the board
1321
+
delay(1000);
1322
+
}
1323
+
```
1324
+
1325
+
***To test this example, no external connections are needed. The EEPROM operates internally within the microcontroller.***
1326
+
1327
+
You can open the Arduino IDE's Serial Monitor (Tools > Serial Monitor) to see the EEPROM operations. Each time you reset the board, the boot counter will increment, demonstrating that the value persists in EEPROM memory.
1328
+
1329
+

1330
+
1331
+
For storing larger data structures, you can use the `EEPROM.get()` and `EEPROM.put()` functions:
When working with EEPROM on the Nano R4, there are several key points to keep in mind for successful implementation:
1352
+
1353
+
- The EEPROM requires careful management of write operations since flash memory has a limited number of write cycles (100,000). Avoid writing to the same address repeatedly in tight loops, as this will quickly wear out the memory. Instead, only write when values actually change, and consider spreading data across different addresses to distribute wear evenly.
1354
+
- 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.
1355
+
- The EEPROM retains data for over 10 years under normal conditions, making it excellent for long-term storage of configuration data and user preferences.
0 commit comments