Board Features
While the Arduino UNO/Ek R4 is similar to its predecessor the Arduino UNO R3, and other boards from the Arduino family, it has some differences as listed below.
Board Setup
To use the Arduino Ek R4 WiFi board, you will need to install the UNO R4 WiFi board package.
Once this is installed you can connect your board to your computer via the USB-C connector and select it (and the connected port) from the board selector dropdown in the IDE. Note that if it already shows up in the board selector you can select it and it will prompt you to install the board package.
Now you can write and upload sketches to the Arduino Ek R4 board as with any other Arduino board. The next few lessons will show you how to use some new functions of the Ek R4, such as the in-built LED Matrix and WiFi and BLE communication.
LED Matrix
The Arduino Ek R4 WiFi comes with a built-in LED Matrix with 8 rows and 12 columns, that can be programmed to display text, images, and animations.
- Images and Animation
To use the display you need the LED Matrix library for the Ek R4 WiFi. This works by creating a frame and loading it into a buffer which displays the frame. A frame can be considered to be the image that is displayed at any given moment on the matrix. An animation is a series of frames shown in sequence.
The 8x12 LED matrix is controlled simply by setting the bit value to 0 or 1 to turn the pixel at that position off or on. The simplest approach is to make a two-dimensional array with 8 rows and 12 columns of 0s and 1s as shown below. If you look for the 1s you can see they are laid out to display a plus sign. You can then change any individual value to change the image or create an animation.
byte frame[8][12] = {
{ 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
{ 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0 }
};
While this is simple to understand it is not very practical to create meaningful images or animation with this approach. This also takes up more memory than required since each pixel needs a bit (0 or 1) whereas we are using an integer (8 bits). Arduino provides tools to help create images and optimize memory usage which you can look into. We will be only displaying text so we will not get into those details in our code.
- Displaying Text
The LED Matrix supports printing characters via the additional ArduinoGraphics library.
Real-Time Clock
The Real-Time Clock (RTC) on the UNO Ek WiFi can be accessed using the RTC library that is included in the UNO Ek Board Package. This library allows you to set and get the time as well as use alarms to trigger interrupts.
If the board is not connected to the Internet, the limitation with the RTC on an Arduino board is that it will reset to a base time every time the board is powered off and on again. You need to manually change the program ro set the time every time the board powers on but that is not a practical approach.
The UNO Ek WiFi features a VRTC pin, that is used to keep the onboard RTC running, even when the board is powered off. With this you will have to set the time only once and the RTC will maintain the time as long as it has power (a voltage in the range of 1.6V to 3.6V) through the VRTC pin.
If the board is connected to the Internet over a WiFi network, you can fetch the time from a global Network Time Protocol (NTP) server. This will set the time accurately each time the board is powered on, without requiring any manual code changes.
WiFi
The ESP32 onboard the UNO R4 WiFi is used to give the board Wi-Fi capabilities. The Wi-Fi module has a bitrate of up to 150 Mbps. The ESP32 module has a built in trace-antenna, meaning you do not need an external one to use the connectivity features of the board. However, this trace antenna is shared with the Bluetooth module, which means you cannot use Bluetooth and Wi-Fi at the same time.
To use the Wi-Fi features of the UNO R4 WiFi, use the WiFiS3 library that is installed along with the UNO R4 Board Package.
Bluetooth Low Energy (BLE)
The ESP32 onboard the UNO R4 WiFi has Bluetooth LE and Bluetooth 5 capabilities, at a speed of up to 2 Mbps. The ESP32 module has a built in trace-antenna, meaning you do not need an external one to use the connectivity features of the board. However, this trace antenna is shared with the WiFi® module, which means that you cannot use Bluetooth and Wi-Fi at the same time.