Arduino WiFi101 – A WiFi system for Arduino and Genuino

Introduction

Perhaps one of the most important steps forward for all owners of an Arduino board is to use the WiFi. Wireless communication greatly extends the capabilities and applicability of these boards. In this regard Arduino produced MKR1000, the last of the Arduino-Genuino boards that in addition to its smaller size has already the WiFi built-in. While if you possess a kind Arduino UNO, Arduino LeonardoArduino ZERO, or Arduino Mega a powerful WiFi101 Shield has been produced in order to enhance them with a WiFi communication.

Arduino WiFi Shield 101

Arduino WiFi Shield 101 is a very useful accessory for the IoT. Unfortunately in Italy it is not very commercialized and is difficult to be able to find. Here are the specifications of the shield

  • Operating voltage both 3.3V and 5V (supplied from the host board)
  • Connection via: IEEE 802.11 b/g/n for up to 72 Mbps networks
  • Encryption types: WEP and WPA2 Personal
  • Support TLS 1.1 (SHA256)
  • Connection with Arduino or Genuino on SPI port
  • Onboard CryptoAuthentication by ATMEL

WiFi shield 101 communicates with the Arduino board using the SPI bus. This is equivalent to the pins 11, 12 and 13 on the Arduino UNO and the pins 50,51 and 52 of the Arduino Mega. On both boards pin 10 is used as SS.

Arduino – Genuino MKR1000

The Arduino board MKR1000 or Genuino MKR1000 and its high potential has been already discussed in a previous article.

This board is mainly created to integrate your projects in the world of the Internet of Things (IoT). It already includes a WiFi system inside. As far as costs are mostly cheaper than the Board + Shield system. Also you have to consider the small size compared to the sandwich configuration of the previous solution. This greatly facilitates the integration of such a board in mechanical devices or sensors without taking up considerable space.

The WiFi101 library

The real core of the whole article is just the WiFi101 library. This library is already included in the Arduino IDE and it is universal. In fact it works for both the new MKR1000 and for the Shield WiFi101.

Also it has been developed to be able to work with the old WiFi projects that worked with the previous libraries. This way you can use the same code on different models of Arduino without having to worry too much then. In fact, the WiFi101 library is very similar to Ethernet and WiFi libraries, and many functions are called by the same name, so if you are already familiar with these libraries, you will find yourself comfortable with the new library without having to start studying all over again .

If you are interested in further information, please visit the official Arduino page where there is a section completely dedicated to this library (see here).

One of the features that have been introduced in these two new WiFi101 systems is the crypto-authentication. Developed by ATMEL, this technology allows you to adjust to the new standards of the IoT, but at the same time to remain transparent. So you will not get lost in the too high technicalities and leaving you to think of your project exclusively. In fact, the connection to a WiFi network is fairly simple, no additional configuration is required in addition to the usual SSID and password.

The library WiFi101 contains functions that allow you to set your Arduino (or Genuino) as a server or as a client, and it also supports WEP and WPA2 data encryption, in order you can make more secure data transfer.

Firmware WiFi Installation

The WiFi101 library requires that your board or your shield have a corresponding firmware installed in order to function correctly. The firmware versions and the library versions are related, therefore if you update the library, you will need to upgrade the firmware, or vice versa.

To check if your WiFI library is installed and which version is, you can consult the Library Manager within dell’Arduino IDE.

Once you have opened the Library Manager, you’ll see a huge list of available libraries (either installed or not). Filter the results by WiFi

If the library WiFi is not installed or a newer library is available on the network, select the latest version from the dropdown menu and install it by clicking the Install button.

Once you have installed the library, you will therefore also check the firmware version of the board or the shield. There is a special sketch that checks the firmware version and alerts you if you need an update.

/*
 * This example check if the firmware loaded on the Wifi101
 * shield is updated.
 *
 * Circuit:
 * - WiFi101 Shield attached
 *
 * Created 29 July 2015 by Cristian Maglie
 * This code is in the public domain.
 */
 #include <SPI.h>
 #include <WiFi101.h>

void setup() {
     // Initialize serial
     Serial.begin(9600);
     while (!Serial) {
     ; // wait for serial port to connect. Needed for native USB port only
     }

     // Print a welcome message
     Serial.println("WiFi101 firmware check.");
     Serial.println();

     // Check for the presence of the shield
     Serial.print("WiFi101 shield: ");
     if (WiFi.status() == WL_NO_SHIELD) {
         Serial.println("NOT PRESENT");
         return; // don't continue
     }
     Serial.println("DETECTED");

     // Print firmware version on the shield
     String fv = WiFi.firmwareVersion();
     Serial.print("Firmware version installed: ");
     Serial.println(fv);

     // Print required firmware version
     Serial.print("Firmware version required : ");
     Serial.println(WIFI_FIRMWARE_REQUIRED);

     // Check if the required version is installed
     Serial.println();
     if (fv == WIFI_FIRMWARE_REQUIRED) {
         Serial.println("Check result: PASSED");
     } else {
         Serial.println("Check result: NOT PASSED");
         Serial.println(" - The firmware version on the shield do not match the");
         Serial.println(" version required by the library, you may experience");
         Serial.println(" issues or failures.");
     }
 }

void loop() {
      // do nothing
 }

In my case, running the sketch, I found that my MKR1000 board has the latest version of firmware (19.4.4) and then I do not need the update.

If you found out that you have to install a new version of firmware, you will need to first load the FirmwareUpdate.h. To do so, select the item Examples> WiFi101> FirmwareUpdater the menu. It will load a sketch. Run it.

Now you can go ahead selecting the menu item Tools > WiFi101 Firmware Updater.

You will see a window where you can update either firmware or certifications.

First, select the serial port you are using, and then run the connection test. If it is OK, you have to select the type of WiFi model.

To check which model you have to choose, look at the WiFi chip on you board or on your shield. In the first line of the white sticker the microcontroller model is reported. It could be either MR210PA (then choose the firmware Model A) or MR510PB (then choose the firmware Model B).

Finally, you can install the firmware

Uploading certificates

With the same tool you can load the Root Certificates on the WiFi module, this way you will have access to certain web sites securely.

The root certificates consist of a limited number of Certification Authorities. It is not a very simple thing knowing which certificate is used by the site to which you want to access. But this tool makes it easy things, asking us to just enter the website URL. It will cover the tool to search the type of Certification Authorities needed, download it from the internet and then upload it to the WiFi module.

The WiFi101 module can contain up to 10 certificates simultaneously, but the number of authorities has very limited and therefore this space should be more than enough for any project you’re working.

So go in the last part of the tool and enter the URL of the site you want to access.

At the end of the procedure, a confirmation message will notify you of the successful installation of the certificate.

Conclusions

In this article you’ve seen how to integrate your projects on the Arduino with a WiFi system. Have you seen all the necessary tools to do so, as WiFi101 shield for Arduino boards, and the model Arduino MKR1000 (Genuino MKR1000) where WiFi is already integrated. Also you saw how to install and properly configure the firmware and WiFi101 library. In future articles you will see some useful examples on how to use it.[:]

Leave a Reply