Skip to main content
shopping_basket Basket 0
Log in

Hands-on with Microchip SAM-IoT WG

main debugging device

IoT development board combines low power 32-bit ARM Cortex M0+ with slick sensor to cloud out-of-the-box experience.

The Microchip SAMD21 (209-7648) is a popular 32-bit microcontroller which provides excellent performance with low power consumption. A great fit for IoT applications, it has also been integrated into numerous maker platforms, such as the Arduino Zero, for example. The SAM-IoT WG board combines this with an ATWINC1510 low power 802.11 b/g/n wireless module, plus numerous other features, including an in-board programmer and debugger, with fully featured IDE support.

Hardware

Atmel Chip

The key hardware features of the SAM-IoT WG are as follows:

  • ATSAMD21G18A Microcontroller
  • ATWINC1510 module
  • ATECC608A secure element
  • MCP9808 temperature sensor
  • Embedded Debugger (nEDBG)
  • MCP73871 LiPo Charger
  • TEMT6000 Light Sensor
  • mikroBUS connector for expansion via Click Boards
  • Status LEDs

One of the particularly nice features is the Nano Embedded Debugger (nEDBG), which provides access to a serial port interface, USB mass storage device for easy drag and drop programming, plus the microcontroller SWD interface for direct programming and debugging of the SAMD21 from within the provided IDE.

Out-of-the-box demo

curiosity software

On plugging the board into a USB port a storage drive will be mounted and within this there is a file named CLICK-ME.HTM.

microchip website

Upon clicking on the file a new web browser session will be started which takes us to a page on the Microchip website, where we are advised to update to the latest firmware. Once we have downloaded the HEX file, we can the drag and drop this onto the USB storage drive in order to update the board.

The web page also has a form where we are able to enter the WiFi network details.

wifi config

Following which a file named WIFI.CFG is downloaded and, once again, we need to save this onto the USB storage for the board.

At this stage the SAM-IoT board WiFi should be configured and it should connect to our local network. Unfortunately, in our case the Error LED remained illuminated. The process was repeated a few times just to be sure, but the problem persisted.

Terminal Serial setup

No fear, as all we needed to do next was to connect to the USB serial port provided by the board, which under Linux appeared as /dev/ttyACM0.

wifi logon

The SSID and password are blocked out in the above screenshot, but the command entered was:

wifi SSID, PASSWORD, 2

The option number 2 at the end instructs the board to use WPA/WPA2 security. For an open network we would use 1 and for WEP we’d use 3. For comprehensive command line interface details, see the SAM-IoT WG Development Board User Guide.trace plots

At this point the board connected to the WiFi network and upon checking the web page again, we could now see light and temperature sensor plots.

Despite the small initial hiccup, it took no time at all to get up and running and sensor data streaming off the board via WiFi and being displayed in a browser window.

Next let’s take a look at getting the firmware development tools set up.

MPLAB X IDE

setting up the IDE

The page we loaded earlier features a section entitled “What’s Next” further down and under this, a sub-section called “Build Your Sensor Code”. Here we are instructed to install:

  1. MPLAB X IDE 5.40 or later (download)
  2. MPLAB XC32 Compiler v2.41 or later (download)
  3. MPLAB Harmony v3 Configurator v3.41 or later (installed from within the IDE)

Having downloaded the IDE and C compiler, these were installed with the following commands:

$ tar xvf MPLABX-v5.40-linux-installer.tar

$ sudo ./MPLABX-v5.40-linux-installer.sh

$ chmod +x xc32-v2.50-full-install-linux-installer.run

$ sudo ./xc32-v2.50-full-install-linux-installer.run

The default options were selected when prompted.

As noted on the start page, for comprehensive details see the Installation Guide.

kit window view

If we have the board cabled via USB, upon starting MPLAB X IDE we are immediately greeted by the Kit Window and can see that our SAM-IoT WG has been detected. A balloon dialog also popped up to instruct us that two updates were available and so we selected to install these.

select harmony

To install the MPLAB Harmony Configurator we navigated to Tools > Plugins and then selected this in the Available Plugins list, followed by Install. Our developer tools setup is now complete.

load and open project

When we were earlier instructed to download the latest firmware, this ZIP file included not only the compiled binary HEX file, but the source code also. We can load the project into the IDE by selecting File > Open Project and the navigate to and selecting sam_d21_iot_wg.X.

example project

At this point we can inspect the source code and navigate included libraries etc. If we wish to, make changes, select to build the project and program the board etc. As the name suggests, this is making use of the Google Cloud IoT Core platform to stream data from the sensors.

We could use this example as a starting point and modify it to use different sensors which are attached via the headers, or perhaps to use a different cloud IoT service.

GCP and Firebase

Google cloud platform configuration

The reason that we were able to get up and running so quickly and streaming sensor data from the out-of-the-box demo, was thanks to the application firmware being integrated with Google Cloud IoT Core — a secure device connection and management service — and Firebase, which provides a real-time database combined with a user interface hosting platform.

The provide example makes use of a sandbox environment for the out-of-the-box demo experience and if we wanted to customise the user interface, to present data in a different way and to add new devices and sensors etc., we would need to create an account on GCP. The example project is hosted on GitHub and the documentation provided with this takes us through the process of setting it up, registering device keys and updating the firmware etc.

Wrapping up

The SAM-IoT WG is a neat board that provides everything you need — from hardware through software and to cloud services — to get up and running very quickly, prototyping IoT applications which are powered by a very capable low power ARM Cortex M0+ MCU.

Andrew Back

Open source (hardware and software!) advocate, Treasurer and Director of the Free and Open Source Silicon Foundation, organiser of Wuthering Bytes technology festival and founder of the Open Source Hardware User Group.
DesignSpark Electrical Logolinkedin