We’re now going to take a closer look at
the Arduino Nano 33 IoT board and we will
be going over some of the example sketches.
For the WiFi examples, we will scan nearby
access points, create a webserver control
an LED as well as another server that gives
us the ADC readings. For the Bluetooth section,
we will create a service that allows us to
control an LED as well as a service that reports
the battery status. If you’re just starting
out with the Arduino ecosystem then perhaps
the Arduino Nano Every would be a more suitable
board for you. We’ve covered that in the
previous video so don’t forget to check
that out. If you’re only interested in getting
up and running with the Arduino IDE, then
feel free to skip ahead to the time shown
on screen.
The Arduino MKR WiFi 1010 was launched a while
back and the new Nano 33 IoT appears to be
based on that. For 16 euros, it looks like
a pretty good deal as you get a Cortex-M0
that’s much more powerful than the Nano
Every along with built-in WiFi, Bluetooth
4.2, a crypto chip for secure connectivity
as well as a 6-axis inertial measurement unit
or IMU.
This is what the box contains, and it is very
similar to the Nano every. The board only
contains pin markings at the bottom so you
would have to use the website image for reference
when wiring your projects. Similar to the
nano every, it does not contain components
on the bottom, which means that you can solder
it directly onto PCBs and even stripboards.
Here’s a quick look at the specs. We have
a SAMD21 that runs at upto 48MHz, with 256KB
Flash and 32KB of SRAM. Keep in mind that
it only supports 3.3V I/O so you need to be
careful when interfacing external modules
and sensors. One more thing to keep in mind
is that the 5V output is disabled by default
and you would have to bridge the solder jumper
at the bottom to enable this. Once enabled,
it will directly pass through the USB 5V power
supply as there is no onboard 5V regulator.
The WiFi and BLE communication is made possible
by the ublox W102 module that is based on
the ESP32 chipset. The crypto chip is supplied
by Microchip and it is compatible with the
WiFi library for secure communication. The
IMU is manufactured by STM and communicates
to the main microcontroller through I2C. The
power supply section uses the MPM3610 DC-DC
converter and this is the same one contained
in the Nano every. It is designed
to output 3.3V in this board. This means that
you should be able to power the board with
an input up-to 21V and draw a max current
of close to 1A without having to worry about
excessive heat being generated. The board
also contains a user LED and reset switch.
The SAMD21 has a built-in USB port which means
that there’s no need for any external programmer
or chip for USB-to-serial conversion. The
schematic and design files are available for
download and this board is also a 4-layer
board.
The team have retained the same pin layout
as the Nano but since this uses a totally
new microcontroller and has a 3.3V logic level,
I wouldn’t call it a direct replacement
and hence I will be treating it as a separate
board that is useful when you need WiFi or
Bluetooth connectivity.
It’s now time to look at the software side
of things and I’ll be using the latest Arduino
IDE, that’s version 1.8.10. Firstly, we
need to install some software so that the
Arduino IDE has everything it needs to communicate
with the board. When you plug in the board
for the first time, you should see a prompt
like this and you can click it to install
the correct core or else, you can open up
the boards manager and type in Arduino SAMD
and install the core. Once this has completed, make sure you’ve selected the right COM port.
Let’s start with the blink sketch so open
it up and upload it. As expected, the sketch
uploads perfectly. You can even change the
delay and upload it again to make sure everything
is working as expected. At this point, you
can use the board like a regular Arduino and
do all sorts of thing with it but the uniqueness
of this board is the wireless connectivity
and that’s what we will be look at next.
To make use of the WiFi module you would need
to install the WiFiNiNa library using the
library manager. You can use the reference
page to get an overview of the example sketches.
Once the installation has completed, you can
open up the ScanNetworksAdvanced example sketch
which should scan and display all the nearby
WiFi networks including the encrypted ones.
You can open up the Serial monitor and the
board should output a list of available WiFi
networks along with some related information.
Keep in mind that it will only list the 2.4GHz
networks as the WiFi module does not support
5GHz.
Let’s learn how to control an LED using
the browser. To do this, open up the SimpleWebServerWiFi
example sketch. For this to work, the board
has to connect to your local WiFi network
and you will need to provide the login information.
To do this, simply enter the SSID or network
name along with the password.
The sketch controls pin 9 by default but nothing
is connected to this pin. You can go ahead
and connect an LED to this pin or you can
update the sketch to use pin 13 instead. The
board has a built-in LED that’s connected
to pin 13 and this way, we wouldn’t have
to connect an external LED. You will need
to make the change in a total of 5 places,
one for the pin setup, two for the text and
2 more for actually toggling the pin state.
Once this is done, you can upload the sketch.
Open up the serial port to check the status.
The board should automatically connect to
the WiFi network and it should also give you
an IP address that you can use to interact
with it. Open up a web-browser and type in
the IP address. You should see something like
this. You can click the relevant links to
control the LED. Notice that clicking the
links sends a character that’s either H
or L to the board and this is what is used
to determine the state. This is simply an
example sketch and you can obviously change
this to suit your needs.
Now that we know how to control a pin, let’s
try to read the pin status from the board.
Do to this, open up the WiFiWebServer example.
Once again, the board needs to connect to
your local network so you will have to provide
the login information like before. Once you’ve
entered the information, you can upload the
sketch. This sketch reads the analog inputs
and reports this over an IP address. Open
up the serial monitor to check the status.
The board should report a successful connection
and it should also give you an IP address like before.
If you use a web browser and type in the IP
address then you should see something like
this. We can view the analog value for the
signal corresponding to each of the analog
pins. Since we have not connected anything
to it, you will see random values. Let’s
connect a potentiometer to pin A0 and vary
it to watch the change in value. Please keep
in mind that you will have to use the 3.3V
power pin as the board can only accept 3.3V
signals. There is a slight delay in the reporting
so make a note of this. You can also update
the sketch to change this.
You can check out the other examples and test
them out depending on your needs. They are
a great starting point when working with WiFi
modules. Also, there’s this thing called
the Arduino IoT cloud which you can use to
log, graph and analyse data remotely. Its
primary goal is to help you automate your
home or business by taking care of the server
or cloud side of things. You can use the crypto
chip that’s present on the board to securely
connect to the cloud and exchange data. This
allows you to secure your projects as well
as network. You can read more about it on
the official Arduino page but I don’t plan
on creating a video about it at the moment.
It’s now time to use the Bluetooth module
and to do this, we would need to install the
ArduinoBLE library. The reference page gives
you a lot of useful information about Bluetooth
low energy, so make sure you read it to get
a better understanding. In summary, Bluetooth
low energy or BLE is optimized for low power
use at low data rates. It communicates differently
compared to the traditional or classic Bluetooth
that was more like a wireless serial port.
BLE devices are referred to as central and
peripheral devices and this might sound confusing
but just keep this in mind:
Peripheral devices are like servers that advertise
information which are also referred to as
services. Peripherals can have services which
allow the user to interact with them and control
things like LEDs, motors, light and so on.
Think of peripherals as smart devices that
contain all the logic.
Central devices are like clients. They simply
interact with peripherals to obtain data or
make changes. If we want to use Bluetooth
low energy to control an LED for instance
then our Arduino board would need to act like
a peripheral that broadcasts a service that
we can interact with.
We would then use another device, like say
for example our smartphone to interact with
the service and control the LED. There’s
already an example sketch that does this for
us so let’s take a look at that. Our board
will be acting as a peripheral so open up
the LED example sketch that’s under the
peripheral menu. It already uses the built-in
LED so all we need to do is hit upload. If
you open up the serial monitor then you will
see that the board is acting as a BLE peripheral.
In order to interact with the board, you would
need to download an APP and I will be using
LightBlue because it’s available for both
iOS and android. Once you open up the APP,
you should be able to view a new service called
Arduino or LED if you’re on Android. Tap
to connect to it. We need to open up the characteristic
to be able to control the LED. This is the
same value that is present in the sketch.
To switch ON the LED, you need to write any
non-zero value. The status will also be shown
in the serial monitor. To switch OFF the LED,
you need to write a value of 0, like so.
Now that we know how to interact with the
board over Bluetooth, let’s try to read
values from it. To do this, open up the BatteryMonitor
sketch and upload this to the board. The sketch
reads the analog value at pin A0 and maps
this between 0 to 100. This value is then
written to the serial port and is also reported
across the BLE service. Open up the LightBlue
app again and you will now see a BatteryMonitor
service. Tap to connect to it. Tap the battery
service and hit the Read button. This should
give you the hexadecimal equivalent of the
battery percentage. If you tap the listen
for notifications or subscribe button, then
you will automatically receive the next update
when it is available. If you connect a potentiometer
to pin A0 and adjust this, then you will be
able to see the change in the APP. The serial
monitor also shows you the connection status
as well as battery level.
And that’s how easy it is to use WiFi and
BLE on the Nano 33 IoT board. I hope this
video has given you a good introduction to
the board and I will try to use this board
to obtain and display weather information
from the internet so do subscribe to get notified.
Thanks for watching and I will see you in
the next one.
