Introduction: Connect to Arduino IoT Cloud - Arduino Nano 33 IoT

About: Head of Digital Jersey Academy but still teaching Computing to all ages. Passionate about EdTech. Apple Distinguished Educator, Google Certified Innovator & Microsoft Innovative Educator Expert.

A simple blink program to connect to Arduino IoT Cloud using the Arduino Nano 33 IoT 

Supplies

  • Arduino Nano 33 IoT 
  • Micro USB cable
  • Blue LED
  • Breadboard (optional)
  • Arduino IoT Cloud account

Step 1: Arduino IoT Cloud

  • Connect to the Arduino IoT Cloud service by creating a free (or more) account.
  • Connect the Arduino to the computer using a USB cable


Step 2: Connect Device

  • Click on the Devices tab and connect your device to the IoT cloud

Step 3: Make a Thing

  • In the Things tab add a variable "blueLED" as a boolean type
  • Configure the Network after that
  • Write the Sketch below. Bold underline text is to be added

/* 

 Sketch generated by the Arduino IoT Cloud Thing "Untitled"

 https://create.arduino.cc/cloud/things/a145757b-061a-48c9-a7af-b9225bbe1b44 


 Arduino IoT Cloud Variables description


 The following variables are automatically generated and updated when changes are made to the Thing


 bool blueLED;


 Variables which are marked as READ/WRITE in the Cloud Thing will also have functions

 which are called when their values are changed from the Dashboard.

 These functions are generated with the Thing and added at the end of this sketch.

*/


#include "thingProperties.h"


int myLED = 2;


void setup() {

 // Initialize serial and wait for port to open:

 Serial.begin(9600);

 // This delay gives the chance to wait for a Serial Monitor without blocking if none is found

 delay(1500); 


 // Defined in thingProperties.h

 initProperties();

  

 pinMode(myLED,OUTPUT);


 // Connect to Arduino IoT Cloud

 ArduinoCloud.begin(ArduinoIoTPreferredConnection);

  

 /*

   The following function allows you to obtain more information

   related to the state of network and IoT Cloud connection and errors

   the higher number the more granular information you’ll get.

   The default is 0 (only errors).

   Maximum is 4

 */

 setDebugMessageLevel(2);

 ArduinoCloud.printDebugInfo();

}


void loop() {

 ArduinoCloud.update();

 // Your code here 

  

  

}


/*

 Since BlueLED is READ_WRITE variable, onBlueLEDChange() is

 executed every time a new value is received from IoT Cloud.

*/

void onBlueLEDChange() {

 // Add your code here to act upon BlueLED change

 Serial.println(blueLED);

 if(blueLED){

  digitalWrite(myLED,HIGH);

 } else{

  digitalWrite(myLED,LOW);

 }

}

Step 4: Make the Circuit

  • add the blue LED to digital pin 2
  • short leg on Ground and the long leg on pin 2

Step 5: Make a Dashbord

  • On the Dashboard tab add a switch
  • Link the switch to the blueLED variable
  • TEST
  • Click the switch
  • You can download the Arduino Dashboard app from the Android or iPhone stores to control remotely