1. Learning Centre
  2. Get Started
  3. 2️⃣ Connect any device and collect data

Get Started with the Arduino MKR WiFi 1010

Control your Arduino MKR WiFi 1010’s built-in RGB LED from your AllThingsTalk Maker using a color picker wheel.


What you’ll need

Installing Arduino IDE

The Arduino Integrated Development Environment (IDE) is an open source, cross-platform application that’s used for programming Arduino boards! It runs on Windows, Mac OS X, and Linux.

Download Arduino IDE

Installing SAMD Arduino Core

Some boards (such as MKR1010) require board “cores” to be installed inside the Arduino IDE. This enables Arduino IDE to program the board. It’s a simple step, so let’s get on with it!

  • Open the Board Manager in Arduino IDE by going to Tools > Board > Board Manager
  • Search for, select and install the “Arduino SAMD Boards”  by Arduino.
  • Once done, click Close

Installing Libraries

You’ll need a few libraries that the example sketch relies on, so let’s install them:
  • In Arduino IDE, go to Tools > Manage Libraries
  • Search for and install “AllThingsTalk WiFi SDK” (by AllThingsTalk)
  • Search for and install “ArduinoJson” (by Benoit Blanchon)
  • Search for and install “WiFiNINA” (by Arduino)
  • Search for and install "Scheduler" (by Arduino)
  • Click Close. Done!

AllThingsTalk Maker

Create Device and Asset


  • Sign in/up to AllThingsTalk Maker
  • Select your Ground (every new account has an automatically created “Playground” ground)
  • Create a new device by clicking + New Device
  • Select the Arduino MKR 1010 tile (or “Your own device” - it’s just cosmetic and name your device
  • Click to open your newly created device
  • Click + New Asset and choose the following properties:
    • Kind: Actuator
    • Name: rgbActuator
    • In the Profile section, go straight to Advanced, remove everything from the text box and copy/paste the following:
      {"type": "string", "pattern": "^#([a-fA-F0-9]{6})$"}
  • Once done, check if your configuration is the same as shown in the picture on the right and then click CREATE ASSET
  • You should now see an asset “rgbActuator” in your device screen

Create Pinboard

Now you’ll need to create a pinboard, which will enable you to use a color picker to control your Arduino MKR WiFi’s RGB LED!
  • Go to your Pinboards
  • Click +NEW PINBOARD and name it however you like
  • In the upper right corner, click New pin
    • Choose Control: Color Picker and click NEXT
    • Choose your newly created device
    • Choose an asset: rgbActuator
    • Click PIN
  • You should now see a color actuator pin added to your pinboardpinboard-color-picker
  • Click Save in the upper right corner

Done! You’ll use this color picker to control the Arduino MKR WiFi 1010’s RGB LED once you’re done with the steps below.

Configuring the Example Sketch

You can now program your Arduino MKR WiFi 1010 board using the sketch (program) below.
To do this, just copy/paste the following code into your Arduino IDE:

#include <AllThingsTalk_WiFi.h> // Where the magic happens
#include <WiFiNINA.h> // This is required only for the purpose of loading the library below.
#include <utility/wifi_drv.h> // Exposes MKR1010's underlying functions to control the RGB LED

auto wifiCreds = WifiCredentials("WiFiSSID", "WiFiPassword"); // Your WiFi Network Name and Password
auto deviceCreds = DeviceConfig("DeviceID", "DeviceToken"); // Go to AllThingsTalk Maker > Devices > Your Device > Settings > Authentication to get your Device ID and Token
auto device = Device(wifiCreds, deviceCreds); // Create "device" object
char* actuator = "rgbActuator"; // Name of the asset on AllThingsTalk
int r,g,b; // RGB values will be held in these variables

void setup() {
Serial.begin(115200); // Baud rate for Serial output (debug), but you can define any baud rate you want
WiFiDrv::pinMode(25, OUTPUT); // Initialize the Green LED pin on the MKR1010 board
WiFiDrv::pinMode(26, OUTPUT); // Initialize the Red LED pin on the MKR1010 board
WiFiDrv::pinMode(27, OUTPUT); // Initialize the Blue LED pin on the MKR1010 board
device.debugPort(Serial); // Set AllThingsTalk library to output its debug to "Serial"
device.wifiSignalReporting(true); // Enable AllThingsTalk WiFi SDK's feature that sends NodeMCU's WiFi Signal Strength to your AllThingsTalk Maker
device.setActuationCallback(actuator, rgb); // Add an actuation callback for asset defined above and run function "rgb" once command is received
device.init(); // Initialize WiFi and AllThingsTalk

void rgb(String value) { // Function that will be called when you pick a color on AllThingsTalk
Serial.println("RGB Color Changed!"); // Outputs to Serial
// Parses the received RGB information into three separate variables (R, G, B)
long hexColor = (long) strtol(&value[1], NULL, 16);
r = hexColor >> 16;
g = hexColor >> 8 & 0xFF;
b = hexColor & 0xFF;
WiFiDrv::analogWrite(25, g); // Set the Green LED to received value
WiFiDrv::analogWrite(26, r); // Set the Red LED to received value
WiFiDrv::analogWrite(27, b); // Set the Blue LED to received value

void loop() { // Runs as long as the device in on
device.loop(); // Keep AllThingsTalk & WiFi connection alive
Configure your WiFi and AllThingsTalk credentials by changing these few things in the code:
  • Change Your_WiFi to your WiFi Network’s name
  • Change Your_WiFi_Password to your WiFi Network’s Password
  • Change the Your_Device_ID to your Device ID.
    To get this value, go to your AllThingsTalk devices, select the device you created, click “Settings”, then choose “Authentication” and copy the Device ID value.
  • Change Your_Device_Token to your device’s token on AllThingsTalk.
    To get this value, go to your device on AllThingsTalk, click “Settings”, then click “Authentication” and copy the device token from “Device Tokens”
  • Done! Feel free to save the changes in your Arduino sketch

Uploading the Example Sketch

Now you’re going to upload the sketch you just configured onto your Arduino board:

  • Plug your Arduino MKR WiFi 1010 to your computer via USB
  • Go to Tools > Board > Arduino MKR WiFi 1010
  • In Arduino IDE, go to Tools > Ports and choose the port that the device is on (should be the only one you can see)
  • Click Sketch > Upload (or just click CTRL+U)

In the bottom part of the Arduino IDE, you should see a message “Compiling sketch” and it should start uploading it to your MKR WiFi 1010 right after that.
Once you see “Done Uploading.”, the code has been uploaded to your MKR WiFi 1010 and you’re all set!
You can now go to Tools > Serial Monitor to actually see what’s happening on your board. Make sure to set the baud rate of your Serial Monitor to 115200.
Now give your MKR WiFi 1010 a reset (by pressing the RST button in the middle of the board) after you open Serial Monitor so you could see what’s going on from the beginning:


If your Arduino MKR WiFi 1010 has connected to the internet and if you see the “Connected to AllThingsTalk!” in your Serial Monitor, you’re good to go!

You should see the small orange LED on your Arduino MKR WiFi 1010 start fading in/out (it’s a feature of our new SDK), which means it’s connecting to WiFi and AllThingsTalk.
Once it blinks quickly and goes off, it means you’re connected!

Testing it

  • Go back to your AllThingsTalk Pinboard where the color picker is located
  • Click on it and choose a color from the color wheel
  • Observe as the RGB LED on your Arduino MKR WiFi 1010 lights up in your chosen color!


You’ve just successfully integrated your Arduino MKR WiFi 1010 board with the platform. And yes, it’s that easy!
Now, this is barely scratching the surface of what’s possible with our platform and the device in front of you.

So, if you’re curious, check our Arduino WiFi SDK and the examples that come with it!

Fun idea: You could use rules to set the RGB LED to turn red when you leave your door open for longer than 5 minutes!