IoT Cloud – Getting Started




Get familiar with the Arduino IoT Cloud and take your first steps into the world of connected objects.

Things used in this project

Hardware components

Arduino MKR1000
Arduino MKR1000
A MKR1010 is also a perfect option, or you could use a MKR IOT Bundle (see below)
× 1
Arduino MKR IoT Bundle
Arduino MKR IoT Bundle
× 1
Breadboard (generic)
Breadboard (generic)
× 1
LED (generic)
LED (generic)
A generic 20mA LED
× 1
Resistor 221 ohm
Resistor 221 ohm
In our example we used a 150Ω resistor to limit the current flowing through the LED which will be powered by 3.3 Volts HIGH signal from the pin
× 1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
× 1
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
× 1
Resistor 10k ohm
Resistor 10k ohm
This will act as a Pull-Down resistor on the button pin
× 1

Software apps and online services

Arduino Web Editor
Arduino Web Editor
Arduino IoT Cloud

Story

From the editor, GO TO IOT CLOUD and create a new property named toggle, with Type ON/OFF (Boolean), Permission Read only and Update When the value changes.

Once again EDIT CODE and we’ll be back to the editor. A quick glance at thingProperties.h will show that a new variable Toggle has been defined and associated to its property via ArduinoCloud.addProperty(...).

In our .ino file we’ll define the new pin and two variables related to the button state (more on this later)

#define BUTTON_PIN 5
int btnState;
int btnPrevState = ;

btnPrevState is needed because we want the property to be updated only once when the button is pressed and not when it is released.

Then, in the setup() we set the pinMode for this pin to INPUT

pinMode(BUTTON_PIN, INPUT);

And finally we add these lines towards the end of the loop()

btnState = digitalRead(BUTTON_PIN);
if (btnPrevState ==  && btnState == 1) {
 toggle = !toggle;
}
btnPrevState = btnState;

In this way the button acts as a toggle and when pressing it we should see the switch on the cloud changing accordingly and flipping between ON and OFF.

Amazing, right? How about uploading the new code and testing out how our circuit interacts with the Dashboard? Let’s do that.

Once again EDIT CODE and we’ll be back to the editor. A quick glance at thingProperties.h will show that a new variable Toggle has been defined and associated to its property via ArduinoCloud.addProperty(...).

In our .ino file we’ll define the new pin and two variables related to the button state (more on this later)

#define BUTTON_PIN 5
int btnState;
int btnPrevState = ;

btnPrevState is needed because we want the property to be updated only once when the button is pressed and not when it is released.

Then, in the setup() we set the pinMode for this pin to INPUT

pinMode(BUTTON_PIN, INPUT);

And finally we add these lines towards the end of the loop()

btnState = digitalRead(BUTTON_PIN);
if (btnPrevState ==  && btnState == 1) {
 toggle = !toggle;
}
btnPrevState = btnState;

In this way the button acts as a toggle and when pressing it we should see the switch on the cloud changing accordingly and flipping between ON and OFF.

Amazing, right? How about uploading the new code and testing out how our circuit interacts with the Dashboard? Let’s do that.

Once again EDIT CODE and we’ll be back to the editor. A quick glance at thingProperties.h will show that a new variable Toggle has been defined and associated to its property via ArduinoCloud.addProperty(...).

In our .ino file we’ll define the new pin and two variables related to the button state (more on this later)

#define BUTTON_PIN 5
int btnState;
int btnPrevState = ;

btnPrevState is needed because we want the property to be updated only once when the button is pressed and not when it is released.

Then, in the setup() we set the pinMode for this pin to INPUT

pinMode(BUTTON_PIN, INPUT);

And finally we add these lines towards the end of the loop()

btnState = digitalRead(BUTTON_PIN);
if (btnPrevState ==  && btnState == 1) {
 toggle = !toggle;
}
btnPrevState = btnState;

In this way the button acts as a toggle and when pressing it we should see the switch on the cloud changing accordingly and flipping between ON and OFF.

Amazing, right? How about uploading the new code and testing out how our circuit interacts with the Dashboard? Let’s do that.

Schematics

Schematic

Schematic for the circuit

Code

This library makes it easier to implement push and release actions for physical buttons, without the burden to track time, buttons states and change of state between LOW and HIGH. Create a Debounce Manager, add a pin to keep track of and let the library call two functions for when the button is pressed or released. More info on the GitHub repository, as well as in the video.

Debounce Library for Arduino — Read More

Source : IoT Cloud – Getting Started




This Post / Project can also be found using search terms:

  • mkr wifi 1010 projects

Leave a Comment

*
= 5 + 2

(Spamcheck Enabled)

Read previous post:
Technological Innovations
How Technological Innovations Will Transform The Future Of Your Business

It should come as no surprise that the modern businesses heavily rely on technology for much of their daily endeavors....

Close
Scroll to top