RockBee Arduino UNO R4
Synopsis
The new Arduino UNO R4 WiFi runs on a Renesas RA4M1 (Arm Cortex®-M4) at 48MHz, which is 3x faster than the UNO R3. In addition, the SRAM has been increased from 2kB to 32kB in the R3 and the flash memory has been increased from 32kB to 256kB as a way to accommodate more complex projects. Additionally, as requested by the Arduino community, the USB port has been upgraded to USB-C and the maximum power supply voltage has been increased to 24 V. The board offers a CAN bus that allows users to minimize cabling and perform different tasks by connecting multiple expansion boards, and last but not least, the new board includes a 12-bit analog DAC.
Equipped with the Espressif S3 WiFi module, this version offers more creative opportunities for makers, educators and hobbyists.
The UNO R4 offers a cost-effective alternative for those looking for a new microcontroller without the extra features.
Building on the success of the UNO R3, the UNO R4 is the best prototyping and learning tool for all. While retaining the known features of the UNO family (standard form factor, shield compatibility, 5V voltage, robustness), new features have been added.
Thanks to its robust design and reliable performance, the UNO R4 is a valuable addition to the Arduino ecosystem. It is suitable for beginners and experienced electronics enthusiasts to use for deploying their own projects.
Features (UNO R4)
Hardware Backward Compatibility
The UNO R4 maintains the same pin layout and 5V operating voltage as the Arduino UNO R3. This means that existing expansion boards and projects can be easily ported to the new board.
New on-board peripherals
The UNO R4 board features several exciting new peripherals including a 12-bit DAC, CAN bus, operational amplifiers and SWD port. These newly added peripherals expand the possibilities for developers and make more advanced projects possible.
More memory and faster clocks
With the increased memory capacity (16x) and clock speed (3x), the UNO R4 Minima can perform more accurate calculations and handle more complex projects. This allows manufacturers to build more complex and advanced projects.
HCI device communication via USB-C
The UNO R4 can emulate a mouse or keyboard when connected to its USB-C port, a feature that makes it easy for makers to create fast and cool interfaces.
Large Voltage Range and Electrical Stability
The UNO R4 board can use power supplies up to 24V, thanks to its improved thermal design. Multiple protections have been incorporated into the circuit design to minimize the risk of damage to the board or computer from wiring errors by unfamiliar users. In addition, the RA4M1 microcontroller has pins with overcurrent protection to provide additional protection against errors.
Capacitive Touch Support
The RA4M1 microcontroller used on the UNO R4 board natively supports capacitive touch.
Features (UNO R4 WiFi)
WiFi and Bluetooth functionality
The UNO R4 WiFi features the ESP32-S3-MINI coprocessor to enhance the functionality of the RA4M1 microcontroller. Featuring WiFi and Bluetooth connectivity makes it easy for developers to connect to the Internet and create IoT projects.
On-board 12x8 LED matrix
The UNO R4 WiFi has a bright 12x8 red LED matrix on board (96 points in total). This feature is perfect for creative projects using animation or plotting sensor data without any additional hardware.
QwiicI2C Connector
The UNO R4 WiFi board is equipped with an industry-standard Qwiic I2C connector for quick and easy prototyping. The I2C connection allows for the connection of a variety of compatible modules, making it easy for creators to create customized projects and extend the functionality of the UNO R4 WiFi.
Runtime Error Diagnostics
The UNO R4 WiFi board has a built-in error trapping mechanism that detects operations that may cause the board to crash, such as dividing by zero. When an error is detected, the board prints a detailed description of the error and the cause on the serial monitor.
Battery-powered RTC support
The UNO R4 has additional pins to shut down the host microcontroller while keeping the internal RTC powered by an external battery Features (UNO R4 Minima)
Powerful and affordable
The UNO R4 Minima offers impressive performance at a competitive price. This board is an exceptionally affordable option that solidifies Arduino's commitment to making high-end technology accessible.
SWD pin for debugging
The on-board SWD port provides manufacturers with an easy and reliable way to connect third-party debug probes. This feature ensures project reliability and allows for efficient debugging of any potential issues.
Pin Definitions
Arduino UNO R3 and R4 Comparison
Both Arduino UNO R4 boards are powered by the Renesas Electronics RA4M1 processor, which utilizes the Arm Cortex-M4 architecture with an increased clock frequency of 48MHz, 32kB of internal RAM and 256kB of flash memory. The on-board peripherals are extensive, including a 12-bit DAC, CAN bus and operational amplifiers. The operating voltage remains at 5V, but the input voltage range has been extended to 24V to accommodate more external device connections such as multiple motors, LED strips and drivers.
In addition, a Qwiic connector has been added to facilitate the connection of appropriate sensors and accessories.The R4 also supports HID functionality to emulate mice, keyboards and even game controllers.The USB connectivity has been upgraded to the widely used USB-C connector.
The Arduino UNO R4 Minima improves clock speeds, increases memory and storage, and adds support for a variety of peripherals, and adds input voltage functionality to meet the needs of a wide range of peripherals.
The Arduino UNO R4 WiFi is powered by Lexin Technology's Lexin ESP32-S3 chip, which not only provides Wi-Fi and Bluetooth connectivity, but also features a powerful microprocessor with a clock speed of up to 240 MHz, 512kB of SRAM, and 384kB of ROM. in addition, it features an OFF pin for shutting down the development board, as well as a built-in real-time clock ( RTC) and a VRTC pin to power the RTC. In addition, the R4 WiFi board has a 12x8 red LED matrix that can be used to draw patterns or display messages.
To summarize, the Arduino UNO R4 WiFi version with Loxin S3 WiFi module provides creators, educators and enthusiasts the opportunity to expand their creativity. On the other hand, the Arduino UNO R4 Minima offers an affordable option for those looking for a new microcontroller without additional features.
Quick Usage Tutorial
To use the Arduino UNO R4 WiFi board, you need to install the UNO R4 WiFi development board, which is part of the Arduino UNO R4 Core.
To install it you need to first install the Arduino IDE which you can download from the Arduino website. In this tutorial we will use the latest version of IDE 2.
Software and hardware required
Arduino UNO R4 WiFi
Arduino IDE
Download and install the IDE
First, we need to download the Arduino IDE
Install the Arduino IDE on your local computer.
Open the Arduino IDE.
Installing Board Packages
To install the motherboard package, open the Board Manager from the left menu. Search for UNO R4 WiFi and install the latest version (or the version you want to use). Install the UNO R4 WiFi board package.
Select your board in the board selector. At this point, you will need to connect the board to your computer via the USB-C cable. Locate the Arduino UNO R4 WiFi board.
Compiling and Uploading Programs
To compile and upload a program, you can use:
- Click the check button to compile the code.
- Click the right arrow to upload the code.
The UNO R4 WiFi development board has several examples that can be accessed directly in the IDE via File > Examples. These examples can be used directly without the need for external libraries.
Tetris Animation Sketch The UNO R4 WiFi comes with Tetris Animation pre-installed. If you have overwritten this program but wish to restore the Tetris animation, then you can find the change program on the Arduino website:
Advanced Tutorials
Arduino UNO R4 WIFI ADC Routine
You will learn how to change the analog-to-digital converter (ADC) on the Arduino UNO R4 WiFi board. By default, the resolution is set to 10-bit and can be updated to 12-bit (0-4096) and 14-bit (0-16383) resolutions to improve the accuracy of analog readings.
Hardware and Software Required
- Arduino IDE
- Arduino R4 WiFi
- Arduino Renesas Core
Analog-to-digital converters (ADCs) convert analog signals to digital signals.The standard resolution on the Arduino board is set to 10-bit (0-1023).The UNO R4 WiFi supports resolutions up to 14-bit, which provides more accurate values from analog signals.
To update the resolution, you only need to use the analogReadResolution() command.
To use it, simply include it in and then use it to retrieve the value from the analog pins. setup()analogRead()
void setup(){
analogReadResolution(14); //change to 14-bit resolution
}
void loop(){
int reading = analogRead(A3); // returns a value between 0-16383
}
Onboard LED Matrix with Arduino UNO R4 WIFI
The Arduino UNO R4 WiFi comes with a built-in 12x8 LED matrix that can be programmed to display graphics, animations, act as an interface, and even play games.
The matrix and its API have been developed to be programmed in several different ways, each suitable for a different application. This routine will walk you through the basic concepts of programming LED matrices and help you get started with creating your own animations, focusing on two different ways of working with LEDs to create animations and images. This makes it easier for you to decide which method best suits your needs!
Hardware and software required
- Arduino UNO R4 WiFi
- UNO R4 Core (latest version)
- Arduino IDE
Initializing the Matrix
To use the LED Matrix Library, a few things need to be added to your program to get started.
First, include the library at the top of your program as follows:
#include "Arduino_LED_Matrix.h"
Then, you need to create an LED Matrix object in your program by adding the following line directly below the first object:
ArduinoLEDMatrix matrix.
Finally, start the LED matrix by adding this line at: void setup()
matrix.begin();
The whole thing should look something like this ;
#include "Arduino_LED_Matrix.h"
ArduinoLEDMatrix matrix.
void setup() {
Serial.begin(115200); matrix.begin(); void setup() {
matrix.begin(); }
}}
How to write the framework
The UNO R4 WiFi's LED Matrix Library works by creating a frame and then loading it into a buffer that displays the frame.
A frame is what we call an "image" that is displayed at any given moment on the matrix. If the animation is a series of images, the frame is one of those images in the series.
In order to control the 8x12 LED matrix on the UNO R4 WiFi, you need at least 96 bits of space in memory. The library provides two ways to perform this operation.
The first is to simply make a two-dimensional byte array as follows:
byte frame[8][12] = {
{ 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0 }, { 0, 1, 0, 0 }
{ 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0 }, { 0, 1, 0, 0, 0 }, { 0, 1, 0, 0, 0 }
{ 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 }, { 0, 0, 1, 0, 0 }, { 0, 0, 1, 0, 0 }
{ 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 }, { 0, 0, 1, 0, 1, 0, 0 }
{ 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }
{ 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0 }
{ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
This option is easy to understand because you can see the image in the pattern of the array and it is easy to edit at runtime. Those in the array above form a heart, which is the image you see on the screen.
To position an individual pixel, select its address and change the value, note that you need to start counting from 0. Thus, the following line will locate the third pixel from the left and the second pixel from the top, and then turn them on:
frame[2][1] = 1;
matrix.renderBitmap(frame, 8, 12);
However, this method takes up more memory than it needs. Even though each LED only needs one bit to store its state, you are using 32 bits (one byte). A more memory-efficient way to store frames is to use an array of <> bit integers.
unsigned long frame[] = {
0x3184a444,
0x42081100,
0xa0040000
};
Unsigned long variables hold 32 bits, and 96/32 is 3, so unsigned long arrays are an efficient way to hold all the bits needed for an LED matrix.
But how do these hexadecimal values relate to the position of the pixel? To find out, convert the hexadecimal values to binary. Here is a code snippet that performs this operation:
for (int b = 0; b < 3; b++) {
Serial.println(frame[b], BIN);
}
This will print out all the bit values of the array. The output will be as follows:
1100011000010010100100010001000100
1000010000010000001000100000000
10100000000001000000000000000000
However, this method will not display all the bits. Each array element should have 32 bits. If you add zeros to show all 32 bits of each element, you get:
001100011000010010100100010001000100
01000010000010000001000100000000
101000000000010000000000000000000000
Now divide it into groups of 12 bits and you get the heart pattern again:
001100011000
010010100100
010001000100
001000001000
000100010000
000010100000
000001000000
000000000000
Tip: You can see the hearts more easily if you highlight all the "1s" on the page by pressing CTRL/Command + F and searching for "1".
If you have several different frames, you can load and display them like this:
const uint32_t happy[] = {
0x19819,
0x80000001,
0x81f8000
};
const uint32_t heart[] = {
0x3184a444,
0x44042081,
0x100a0040
}; matrix.loadFrame(happy); }
matrix.loadFrame(happy);
matrix.loadFrame(happy); delay(500);
matrix.loadFrame(heart);
matrix.loadFrame(heart); delay(500); matrix.loadFrame(heart)
Test it out.
Let's apply these concepts and use two basic programs to display different frames on your board. First, let's create 3x32-bit integer frames and load them one by one.
Here is a program that will first load a smiley face on your matrix and then change it to a heart.
#include "Arduino_LED_Matrix.h"
ArduinoLEDMatrix matrix.
void setup() {
Serial.begin(115200);
matrix.begin(); void setup() { Serial.begin(115200); matrix.begin(); }
}
const uint32_t happy[] = {
0x19819,
0x80000001,
0x81f8000
}; }
const uint32_t heart[] = {
0x3184a444,
0x44042081,
0x100a0040
}; }
void loop(){
matrix.loadFrame(happy);
matrix.loadFrame(happy); delay(500); matrix.loadFrame(heart); void loop()
matrix.loadFrame(happy); delay(500); matrix.loadFrame(heart).
delay(500); matrix.loadFrame(heart); delay(500); matrix.loadFrame(heart)
}
The program is very simple, but the result is very expressive and helps you easily indicate the state of your project.
Now, let's change the method and create a bitmap that changes at runtime. This program includes several functions, each of which draws a part of the face and then blinks the left eye by turning off certain pixels.
#include "Arduino_LED_Matrix.h"
ArduinoLEDMatrix matrix;
void setup() {
Serial.begin(115200);
matrix.begin();
}
uint8_t frame[8][12] = {
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
void leftEye(){
//Left eye
frame[1][3] = 1;
frame[1][4] = 1;
frame[2][3] = 1;
frame[2][4] = 1;
}
void wink(){
//Wink with the left eye
frame[1][3] = 0;
frame[1][4] = 0;
frame[2][3] = 1;
frame[2][4] = 1;
}
void rightEye(){
//Right eye
frame[1][8] = 1;
frame[1][9] = 1;
frame[2][8] = 1;
frame[2][9] = 1;
}
void mouth(){
//Mouth
frame[5][3] = 1;
frame[5][9] = 1;
frame[6][3] = 1;
frame[6][4] = 1;
frame[6][5] = 1;
frame[6][6] = 1;
frame[6][7] = 1;
frame[6][8] = 1;
frame[6][9] = 1;
}
void loop(){
leftEye();
rightEye();
mouth();
matrix.renderBitmap(frame, 8, 12);
delay(1000);
wink();
matrix.renderBitmap(frame, 8, 12);
delay(1000);
}
Animation Generation
Arduino has developed an official tool for generating frames and animations to be rendered on the LED Matrix in the browser.
Click here to go to the LED Matrix tool.
After creating the animations, you can export them from the tool in the format discussed earlier.
You can find more tips on how to use this tool on its website.
Arduino UNO R4 WIFI RTC Use
In this routine, you will learn how to access the real-time clock (RTC) on the Arduino UNO R4 WiFi board.The RTC is embedded in the microcontroller (RA4M1) of the UNO R4 WiFi.
The goals of this routine are:
Set the start date of the RTC
Access the date/time from the RTC in calendar format.
Access the time in Unix format.
Hardware and software required
Arduino IDE
Arduino UNO R4 WiFi
Arduino Renesas Core
Real Time Clock
The RTC on the UNO R4 WiFi can be accessed using the RTC library included in the Renesas Core. This library allows you to set/get the time and use alarms to trigger interrupts.
The UNO R4 WiFi has a VRTC pin that is used to keep the on-board RTC running, even when power to the board is removed. To do this, apply a voltage in the range of 1.6 - 3.6 V to the VRTC pin.
Setup Time
RTCTime startTime(30, Month::JUNE, 2023, 13, 37, 00, DayOfWeek::WEDNESDAY, SaveLight::SAVING_TIME_ACTIVE)
RTC.setTime(startTime)
To set the start time of the RTC, you create an object. Here you can specify the day, month, year, hours, minutes, seconds, and specify the day of the week as well as the daylight saving mode. rtctime
Then, to set the time, use this method. setTime()
Example:
#include "RTC.h"
void setup() {
Serial.begin(9600);
RTC.begin();
RTCTime startTime(30, Month::JUNE, 2023, 13, 37, 00, DayOfWeek::WEDNESDAY, SaveLight::SAVING_TIME_ACTIVE);
RTC.setTime(startTime);
}
void loop(){
}
Get the time
RTC.getTime(currentTime)
To retrieve the time, we need to create an object and retrieve the current time using the method .RTCTimegetTime()
This example sets and gets the time and stores it in an object named .RTCTimecurrentTime
#include "RTC.h"
void setup() {
Serial.begin(9600);
RTC.begin();
RTCTime startTime(30, Month::JUNE, 2023, 13, 37, 00, DayOfWeek::WEDNESDAY, SaveLight::SAVING_TIME_ACTIVE);
RTC.setTime(startTime);
}
void loop(){
RTCTime currentTime; // Get current time from RTC.
// Get current time from RTC
RTC.getTime(currentTime); } void loop() { RTCTime currentTime; // Get current time from RTC.
}
Printing the date and time
The above example shows how to set and get the time and store it in an object. This data can be retrieved through a series of methods:
- getDayOfMonth()
- getMonth()
- getYear()
- getHour()
- getMinutes()
- getSeconds()
The following example prints the date and time from the object.
#include "RTC.h"
void setup() {
Serial.begin(9600);
RTC.begin();
RTCTime startTime(30, Month::JUNE, 2023, 13, 37, 00, DayOfWeek::WEDNESDAY, SaveLight::SAVING_TIME_ACTIVE);
RTC.setTime(startTime);
}
void loop() {
RTCTime currentTime;
// Get current time from RTC
RTC.getTime(currentTime);
// Print out date (DD/MM//YYYY)
Serial.print(currentTime.getDayOfMonth());
Serial.print("/");
Serial.print(Month2int(currentTime.getMonth()));
Serial.print("/");
Serial.print(currentTime.getYear());
Serial.print(" - ");
// Print time (HH/MM/SS)
Serial.print(currentTime.getHour());
Serial.print(":");
Serial.print(currentTime.getMinutes());
Serial.print(":");
Serial.println(currentTime.getSeconds());
delay(1000);
}
Unix
- currentTime.getUnixTime()
To retrieve the Unix timestamp, use this method.getUnixTime()
#include "RTC.h"
void setup() {
Serial.begin(9600);
RTC.begin();
RTCTime startTime(30, Month::JUNE, 2023, 13, 37, 00, DayOfWeek::WEDNESDAY, SaveLight::SAVING_TIME_ACTIVE);
RTC.setTime(startTime);
}
void loop() {
RTCTime currentTime;
// Get current time from RTC
RTC.getTime(currentTime);
//Unix timestamp
Serial.print("Unix timestamp: ");
Serial.println(currentTime.getUnixTime());
delay(1000);
}
Periodic Interrupts
Periodic interrupt allows you to set a repeating callback.
To use it, you need to initialize the periodic callback using the following method: setPeriodicCallback()
RTC.setPeriodicCallback(periodic_cbk, Period::ONCE_EVERY_2_SEC)
You also need to create a function that will be called:
void periodic_cbk() { code to be executed }
The following example flashes a light every 2 seconds:
#include "RTC.h"
const int LED_ON_INTERRUPT = 22;
void setup(){
RTC.begin();
if (!RTC.setPeriodicCallback(periodic_cbk, Period::ONCE_EVERY_2_SEC)) {
Serial.println("ERROR: periodic callback not set");
}
}
void loop() {
}
void periodic_cbk() {
static bool clb_st = false;
if(clb_st) {
digitalWrite(LED_ON_INTERRUPT,HIGH);
}
else {
digitalWrite(LED_ON_INTERRUPT,LOW);
}
clb_st = !clb_st;
Serial.println("PERIODIC INTERRUPT");
}
The period can be specified using the following enumeration:
- ONCE_EVERY_2_SEC
- ONCE_EVERY_1_SEC
- N2_TIMES_EVERY_SEC
- N4_TIMES_EVERY_SEC
- N8_TIMES_EVERY_SEC
- N16_TIMES_EVERY_SEC
- N32_TIMES_EVERY_SEC
- N64_TIMES_EVERY_SEC
- N128_TIMES_EVERY_SEC
- N256_TIMES_EVERY_SEC
alarm callback
- RTC.setAlarmCallback(alarm_cbk, alarmtime, am)
#include "RTC.h"
void setup() {
Serial.begin(9600);
RTC.begin();
RTCTime alarmtime;
alarmtime.setSecond(35);
AlarmMatch am;
am.addMatchSecond();
if (!RTC.setAlarmCallback(alarm_cbk, alarmtime, am)) {
Serial.println("ERROR: alarm callback not set");
}
}
void alarm_cbk() {
Serial.println("ALARM INTERRUPT");
}
Arduino UNO R4 WIFI USB HID Routine
In this routine, you will learn how to emulate a mouse/keyboard using the Arduino UNO R4 WiFi board with keyboard and mouse APIs. This can be used to create game controllers, keyboard extensions, or other HID devices.
Hardware and Software Required
Arduino IDE
Arduino UNO R4 WiFi
Arduino Renesas Core
Human Interface Devices (HID)
Human Interface Devices (HIDs) are devices designed for humans (keyboards, mice, game controllers, etc.) that often send data to a computer via USB. When you press a key on the keyboard, you send data to the computer, which reads the data and activates the corresponding key.
The UNO R4 WiFi has built-in support for HID, a feature found on most modern development boards, but not in previous UNO revisions.
To convert the board to HID, you can use the keyboard/mouse API built into the kernel.
Keyboard
To use the keyboard functionality, we need to include the library at the top of the program.The Keyboard class contains several methods that can be used to emulate a keyboard.
#include <Keyboard.h
Keyboard.method()
Keyboard Example
To simulate a keyboard, we can use the and methods. This will simulate keystrokes, as well as releasing them. The following example prints a "w" every second. press() releaseAll()
#include <Keyboard.h>
void setup() {
Keyboard.begin();
delay(1000);
}
void loop() {
Keyboard.press('w');
delay(100);
Keyboard.releaseAll();
delay(1000);
}
keyboard