Using the Arduino MKR1000 with ThingSpeak

Meet the Arduino MKR1000

The Arduino MKR1000 is a powerful board that combines the functionality of the Arduino Zero and the Wi-Fi Shield. If you are interested in getting started with the Internet of Things, then the MKR1000 is an ideal starting place. Use the MKR1000 to prototype IoT projects by taking advantage of the built-in Wi-Fi to connect with ThingSpeak data channels and MATLAB analysis apps.

Arduino MKR1000

Features

  • Onboard Wi-Fi – WINC1500 low power 2.4GHz IEEE® 802.11 b/g/n Wi-Fi
  • Secure communications with the ECC508 CryptoAuthentication and up to SHA-256 certificate support
  • Battery support – on board Li-Po charging circuit and battery connector
  • 32bit processor – SAMD21 Cortex-M0+ 32bit low power ARM MCU
  • Fully compatible with the ThingSpeak IoT platform

Arduino MKR1000 PinoutArduino MKR1000 Pinout

Notes

  • Li-Po battery minimum capacity is 700 mAh. Smaller cells will be damaged by this current and may overheat. It is strongly recommended that you select a Li-Po battery of at least 700mAh capacity. A bigger cell will take more time to charge, but won’t be harmed or overheated. The charging circuit is programmed with 4 hours of charging time with a max of 1400 mAh per charging round.
  • The onboard LED is connected to D6 and not D13 as it is on other boards.

Warning

The MKR1000 runs at 3.3V. The maximum voltage that the I/O pins can tolerate is 3.3V. Applying voltages higher than 3.3V to any I/O pin could damage the board. This means that not every sensor or add-on that you have used before will work with the MKR1000.

Arduino IDE Setup

Arduino IDE Version

The Arduino MKR1000 board requires the Arduino IDE version 1.6.5 or above.

Arduino SAMD Boards Package

Before connecting the Arduino MKR1000 to your computer, make sure you have the latest version of the Arduino IDE and have the Arduino SAMD Boards package installed under Boards Manager.

Arduino SAMD Package for Arduino MKR1000

Arduino WiFi101 Library

Install the WiFi101 library in order to use the MKR1000 with your Wi-Fi network. Select Sketch, Include Library,  and Manage Libraries… Search for “WiFi101” and install the latest version. Once this is installed, you will have access to many example sketches that use the MKR1000 board and its Wi-Fi module.

Arduino MKR1000 Connection

Connect the Arduino MKR1000 to your computer using a micro USB cable and wait for it to connect successfully. In the Arduino IDE, select the “Arduino/Genuino MKR1000” board and the correct COM port.

Arduino Blink Example

Let’s make sure everything is setup before we try connecting the MKR1000 to Wi-Fi and ThingSpeak. We will upload a modified blink example that will blink the onboard LED on pin 6.

  • In the Arduino IDE, select File, Examples, 01.Basics, and Blink.
    • Change Pin 13 to 6
    • Change delay to 300

MKR1000-Blink-Sketch

  • Upload “Blink.ino” to the Arduino/Genuino MKR1000 board on the correct port

Arduino MKR1000 Blinking

ThingSpeak Setup

ThingSpeak requires a user account and a channel. A channel is where you send data and where ThingSpeak stores data. Each channel has up to 8 data fields, location fields, and a status field. You can send data every 15 seconds to ThingSpeak, but most applications work well every minute.

  • Sign up for new User Accounthttps://thingspeak.com/users/sign_up
  • Create a new Channel by selecting Channels, My Channels, and then New Channel
  • Enable Field 1 and Field 2
  • Enter “A0” as the Field 1 name
  • Enter “RSSI” as the Field 2 name

ThingSpeak Channel Settings

  • Click Save Channel
  • Note the Write API Key and Channel ID on the API Keys tab

Send Data to ThingSpeak Example

This example will allow you to write data to a ThingSpeak channel from the Arduino MKR1000 using the ThingSpeak API. The example sends the value of the analog pin 0 and the signal strength of the Wi-Fi module (RSSI). You now have your own portable Wi-Fi signal strength meter.

  • Upload the “RSSI_to_ThingSpeak.ino” sketch to your MKR1000 board
  • Unplug the MKR 1000 from computer
  • Connect a charged battery to the MKR1000

MKR1000-with-battery

  • Walk around your Wi-Fi access point for a few minutes
  • Check out your results on your ThingSpeak channel

ThingSpeak Channel Data

MATLAB Visualization

Now that your data is on ThingSpeak you can see this data on ThingSpeak using the MATLAB Visualizations app. On ThingSpeak, select Apps and then MATLAB Visualizations. Click “New”, select “Custom (no starter code), and click “Create”.

Enter the following MATLAB code and click Run and Save:

readChannelID = 93156;
fieldID1 = 1;

readAPIKey = 'MCI6XM81ZFOY8UCE';

%% Read Data %%
[data, time] = thingSpeakRead(readChannelID, 'Field', fieldID1, 'NumPoints', 10, 'ReadKey', readAPIKey);

%% Visualize Data %%
thingSpeakPlot(time, data);

Resources