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/02.hero/boards/uno-r4-wifi/tutorials/cheat-sheet/cheat-sheet.md
+274-2Lines changed: 274 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -33,11 +33,283 @@ The full datasheet is available as a downloadable PDF from the link below:
33
33
34
34
-[Download the UNO R4 WiFi datasheet](/resources/datasheets/ABX00087-datasheet.pdf)
35
35
36
+
## Power Supply
37
+
38
+
To power the UNO R4 WiFi you may either use a USB-C® cable, or the VIN pin.
39
+
40
+
If you’re using the USB-C® connector you must power it with 5V.
41
+
42
+
The board can be powered via the VIN pin, supporting a range between 6-24V.
43
+
44
+
## Installation
45
+
46
+
***For detailed instructions on how to install the UNO R4 WiFi core, please refer to the [Getting Started with the UNO R4 WiFi]() guide.***
47
+
48
+
The **UNO R4 WiFi** can be programmed through:
49
+
50
+
- the **IDE 1**,
51
+
- the **IDE 2**,
52
+
- and the **Web-Editor**.
53
+
54
+
## Core
55
+
56
+
The UNO R4 WiFi is based on the [Arduino Core for Renesas devices](https://github.com/arduino/ArduinoCore-renesas).
57
+
58
+
## Renesas RA4M1
59
+
60
+
The UNO R4 WiFi features the powerful and very robust renesas microcontroller also found on the UNO R4 Minima. Renesas microcontrollers are known for their high performance and robustness, including their built in peripheral set.
61
+
62
+
These peripherals include analog-to-digital converters, timers, pulse width modulation (PWM) units, communication interfaces (such as UART, SPI, and I2C) and more.
63
+
64
+

65
+
66
+
## Memory
67
+
68
+
### RAM
69
+
70
+
The **UNO R4 WiFi** comes equipped with 32 KB of RAM memory.
71
+
72
+
### Flash
73
+
74
+
The flash memory comes in 256 KB code and 8 KB data.
75
+
36
76
## Arduino IoT Cloud
37
77
The UNO R4 WiFi is compatible with the [Arduino IoT Cloud](https://create.arduino.cc/iot/things), a cloud service that allows you to create IoT applications in just minutes.
38
78
39
79
***Visit the [Getting Started with Arduino IoT Cloud](/arduino-cloud/getting-started/iot-cloud-getting-started) guide for more information.***
40
80
81
+
## SPI
82
+
83
+

84
+
85
+
The **UNO R4 WiFi** features a Serial Peripheral Interface (SPI) bus. The bus (connector), ‘SPI’ uses the following pins:
86
+
87
+
88
+
- (COPI) - D11
89
+
- (CIPO) - D12
90
+
- (SCK) - D13
91
+
- (CS) - D10
92
+
93
+
The following example shows how to use SPI:
94
+
95
+
96
+
```arduino
97
+
#include <SPI.h>
98
+
99
+
const int CS = 10;
100
+
101
+
102
+
void setup() {
103
+
pinMode(CS, OUTPUT);
104
+
105
+
SPI.begin();
106
+
107
+
digitalWrite(CS, LOW);
108
+
109
+
SPI.transfer(0x00);
110
+
111
+
digitalWrite(CS, HIGH);
112
+
}
113
+
114
+
void loop() {
115
+
}
116
+
```
117
+
118
+
## I2C
119
+
120
+
I2C lets you connect multiple I2C compatible devices in series using only two pins. The controller will send out information through the I2C bus to a 7 bit address, meaning that the technical limit of I2C devices on a single line is 128. Practically, you're never gonna reach 128 devices before other limitations kick in.
121
+
122
+
The **UNO R4 WiFi** has one I2C bus which is marked with SCL and SDA. They are shared with A4 (SDA) and A5 (SCL) which owners of previous UNO's are familiar with. The pullups are not mounted on the PCB but there are footprints to do so if needed.
123
+
124
+
The pins used for I2C on the **UNO R4 WiFi** are the following:
125
+
- SDA - D14
126
+
- SCL - D15
127
+
128
+

129
+
130
+
To connect I2C devices you will need to include the [Wire](https://www.arduino.cc/reference/en/language/functions/communication/wire/) library at the top of your sketch.
131
+
132
+
```arduino
133
+
#include <Wire.h>
134
+
```
135
+
136
+
Inside `void setup()` you need to initialize the library, and initialize the I2C port you want to use.
137
+
138
+
```arduino
139
+
Wire.begin() //SDA & SDL
140
+
Wire1.begin(); //SDA1 & SDL1
141
+
Wire2.begin(); //SDA2 & SDL2
142
+
```
143
+
144
+
And to write something to a device connected via I2C, we can use the following commands:
145
+
146
+
```arduino
147
+
Wire.beginTransmission(1); //begin transmit to device 1
148
+
Wire.write(byte(0x00)); //send instruction byte
149
+
Wire.write(val); //send a value
150
+
Wire.endTransmission(); //stop transmit
151
+
```
152
+
153
+
## Serial Ports
154
+
155
+
156
+
The **UNO R4 WiFi** supports, like every other Arduino board, serial communication with UART (Universal Asynchronous, Receiver-Transmitter). However, the **Uno R4 WiFi** board features 2 separate serial ports.
157
+
158
+
This not only means that you may print different values to different ports and monitor them separately, which is useful enough in and of itself, but that you may also communicate with **2 different serial enabled devices** simultaneously.
159
+
160
+
The pins used for UART on the **UNO R4 WiFi** are the following:
161
+
162
+
- RX0 - D0
163
+
- TX0 - D1
164
+
165
+
Each Serial port works in the same way as the one you're used to, but you use different functions to target them:
166
+
167
+
```arduino
168
+
Serial.begin(9600);
169
+
Serial1.begin(9600);
170
+
```
171
+
172
+
To send and receive data through UART, we will first need to set the baud rate inside `void setup()`.
173
+
174
+
```arduino
175
+
Serial1.begin(9600);
176
+
```
177
+
178
+
To read incoming data, we can use a while loop() to read each individual character and add it to a string.
179
+
180
+
```arduino
181
+
while(Serial1.available()){
182
+
delay(2);
183
+
char c = Serial1.read();
184
+
incoming += c;
185
+
}
186
+
```
187
+
188
+
And to write something, we can use the following command:
189
+
190
+
```arduino
191
+
Serial1.write("Hello world!");
192
+
```
193
+
194
+
## Pins
195
+
196
+
The **UNO R4 WiFi** gives you access to many different pins and many of them have special features that will be accounted for in the upcoming sections of this article. Keep reading to learn what you can do with them.
197
+
198
+
If you just need a quick overview of the pins functionality, this is a full table of all the IO pins on the **UNO R4 WiFi**
199
+
200
+
| Pin | Function | Notes |
201
+
| --- | --------- | -------------------- |
202
+
| 0 | RX | Serial communication |
203
+
| 1 | TX | Serial communication |
204
+
| 2 | GPIO | Digital IO pin |
205
+
| 3 | PWM | Digital IO pin, PWM |
206
+
| 4 | GPIO | Digital IO pin |
207
+
| 5 | PWM | Digital IO pin, PWM |
208
+
| 6 | PWM | Digital IO pin, PWM |
209
+
| 7 | GPIO | Digital IO pin |
210
+
| 8 | GPIO | Digital IO pin |
211
+
| 9 | PWM | Digital IO pin, PWM |
212
+
| 10 | PWM | Digital IO pin, PWM |
213
+
| 11 | PWM | Digital IO pin, PWM |
214
+
| 12 | GPIO | Digital IO pin |
215
+
| 13 | GPIO | Digital IO pin |
216
+
| 14 | SDA | Serial communication |
217
+
| 15 | SCL | Serial communication |
218
+
| 16 | DAC | Analog In, DAC |
219
+
| 17 | OPAMP+ | Analog In, OPAMP+ |
220
+
| 18 | OPAMP- | Analog In, OPAMP- |
221
+
| 19 | OPAMP OUT | Analog In, OPAMP OUT |
222
+
| 20 | GPIO | Analog in, Digital IO pin |
223
+
| 21 | GPIO | Analog in, Digital IO pin |
224
+
| A0 | DAC | Analog In, DAC |
225
+
| A1 | Analog in | Analog In |
226
+
| A2 | Analog in | Analog In |
227
+
| A3 | Analog in | Analog In |
228
+
| A4 | Analog in | Analog In |
229
+
| A5 | Analog in | Analog In |
230
+
231
+
### Analog Pins
232
+
233
+
The **UNO R4 WiFi** has 6 analog input pins (A0-A5) that can be read by using the `analogRead()` function.
234
+
235
+
```arduino
236
+
value = analogRead(pin, value);
237
+
```
238
+
239
+
The reference voltage of these pins is 3.3V.
240
+
241
+
242
+
### PWM
243
+
244
+
PWM (Pulse Width Modulation) capability allows a digital pin to emulate analog output by flickering on and off very fast letting you, among other things, dim LEDs connected to digital pins.
245
+
246
+
The **UNO R4 WiFi** has 6 PWM capable pins which are marked with ~ on the headers. The PWM capable pins are:
247
+
248
+
- D3~
249
+
- D5~
250
+
- D6~
251
+
- D9~
252
+
- D10~
253
+
- D11~
254
+
255
+
You may use them as analog output pins with the function:
256
+
257
+
```arduino
258
+
analogWrite(pin, value);
259
+
```
260
+
The **RA4M1** has an internal OPAMP that is exposed on the **UNO R4 WiFi** as follows:
261
+
262
+
| Pin | OPAMP |
263
+
| --- | ------------------|
264
+
| A1 | OPAMP + |
265
+
| A2 | OPAMP - |
266
+
| A3 | OPAMP OUT |
267
+
268
+
### Digital Pins
269
+
270
+
The **UNO R4 WiFi** features a total of digital 14 pins. Though some of them serve another purpose and shouldn't be used for GPIO if you have other pins available.
271
+
272
+
273
+
| Pin | Function | Notes |
274
+
| --- | --------- | -------------------- |
275
+
| 0 | RX | Serial communication |
276
+
| 1 | TX | Serial communication |
277
+
| 2 | GPIO | Digital IO pin |
278
+
| 3 | PWM | Digital IO pin, PWM |
279
+
| 4 | GPIO | Digital IO pin |
280
+
| 5 | PWM | Digital IO pin, PWM |
281
+
| 6 | PWM | Digital IO pin, PWM |
282
+
| 7 | GPIO | Digital IO pin |
283
+
| 8 | GPIO | Digital IO pin |
284
+
| 9 | PWM | Digital IO pin, PWM |
285
+
| 10 | PWM | Digital IO pin, PWM |
286
+
| 11 | PWM | Digital IO pin, PWM |
287
+
| 12 | GPIO | Digital IO pin |
288
+
| 13 | GPIO | Digital IO pin |
289
+
| 14 | SDA | Serial communication |
290
+
| 15 | SCL | Serial communication |
291
+
292
+
The reference voltage of all digital pins is 5V.
293
+
294
+
### DAC Pin
295
+
296
+
The **UNO R4 WiFi** also has a DAC pin (A0) that can act as genuine analog output pin which means it's even more capable than PWM pins.
297
+
298
+
```arduino
299
+
analogWrite(pin, value);
300
+
```
301
+
302
+

303
+
304
+
This DAC pin has a default write resolution of 8-bits. This means that values that are written to the pin should be between 0-255.
305
+
306
+
However you may change this write resolution if you need to, to up to 12-bits, and in this case the values you write to the pin should be between 0-4096.
307
+
308
+
```arduino
309
+
analogWriteResolution(12);
310
+
```
311
+
312
+
41
313
## QWIIC Connector
42
314
43
315
The UNO R4 WiFi features a QWIIC/STEMMA connector that you can use to connect modules, often allowing you to daisy chain several modules and control all of them through a single connector.
@@ -105,11 +377,11 @@ Overwriting the ESP32's firmware disrupts the communication between the two MCUs
105
377
106
378
To reprogram the ESP32 board you can either find UART-pads next to the ESP32 Module, that are laid out as shown in the image below:
107
379
108
-

380
+

109
381
110
382
or you can use the pins exposed directly on the ESP32 header, shown here:
111
383
112
-

384
+

113
385
114
386
## LED Matrix
115
387
The LED Matrix on the UNO R4 WiFi is available to use in your program, to display still graphics, animations, or even play games on. Bundled in the core for the UNO R4 is a library for displaying frames on the matrix.
0 commit comments