Electronics Software Development

Arduino Cloud: Connecting Your Arduino To The Outside World

Arduino Cloud Graphic
Written by John Woolsey

Last Updated: December 16, 2023
Originally Published: October 23, 2023

Skill Level: Intermediate

Table Of Contents

Introduction

This tutorial will teach you how to use the Arduino Cloud service to connect your Arduino UNO R4 WiFi to the outside world and interact with its connected electronics. We will control the built-in LED and read a connected potentiometer over the web.

A basic understanding of electronics and programming is expected along with some familiarity with the Arduino platform. If you are new to Arduino, or would just like to refresh your knowledge, please see our Blink: Making An LED Blink On An Arduino Uno tutorial before proceeding with this one. This tutorial uses a solderless breadboard to build a circuit from a schematic diagram. The All About Circuit’s Understanding Schematics, SparkFun’s How to Read a Schematic, Core Electronics’ How to Use Breadboards, and Science Buddies’ How to Use a Breadboard guides are good resources for learning how to translate a schematic to a breadboard.

The resources created for this tutorial are available on GitHub for your reference.

This tutorial is provided as a free service to our valued readers. Please help us continue this endeavor by considering a GitHub sponsorship or a PayPal donation.

What Is Needed

Background Information

In a previous article, Controlling An Arduino Uno WiFi Rev2 Or Arduino Uno With WiFi Shield From A Web Browser, I described how to create and run a web server on your Arduino UNO. This worked well for accessing your Arduino over a local network, but it was not visible over the internet. In order to extend this approach and allow your Arduino based server to be accessed over the internet, techniques such as port forwarding, external hosting, static IP addressing, or the use of a Dynamic DNS service are required. Although doable, these techniques can be complicated, costly, or not very secure. For these reasons, they are not usually the best fit for hobbyists to access their Arduino boards over the internet.

This tutorial will instead utilize the Arduino Cloud service to connect an Arduino to the outside world. Arduino Cloud is free, secure, compatible across many development boards, and allows your device to be accessed privately or shared with others if you so choose. Plan upgrades are available, but the free tier gives us a lot to work with and may be all you will ever need. Please see the How It Works guide and the general Arduino Cloud documentation for additional information on using the Arduino Cloud service.

I am using the Arduino Uno R4 WiFi development board connected to a macOS based computer running the desktop Arduino IDE for this tutorial. If you are using a different Arduino board or computer setup, the vast majority of this tutorial should still apply, however, some minor changes may be necessary.

If you need assistance with your particular setup, post a question in the comments section below and I, or someone else, can try to help you.

Building The Circuit

Before connecting any power or circuitry to your Arduino board, connect your board to your computer, open the Arduino desktop IDE, upload the BareMinimum (Main Menu > File > Examples > 01.Basics > BareMinimum) sketch to the board, and then disconnect your board from your computer. This resets all of the board’s GPIO pins back to their default states and ensures no outputs are being driven that may damage your board or connected electronics during wiring and power-up operations.

Construct the potentiometer circuit on a breadboard and connect it to your Arduino board’s GPIO pins according to the schematic shown below.

Schematic Diagram Of A Potentiometer Circuit Connected To An Arduino UNO Board
Schematic Diagram Of A Potentiometer Circuit Connected To An Arduino UNO Board

The two outer terminals of the potentiometer are connected to 5V and GND on the Arduino board. The center wiper terminal is connected to pin A1 of the board. I suggest using a multimeter to verify which terminals are which on your potentiometer as you do not want to accidentally connect power and ground together through the entire travel of the potentiometer, as you could damage the board.

The circuit should look similar to the one shown below once completed.

Completed Potentiometer Circuit Connected To An Arduino UNO Board
Completed Potentiometer Circuit Connected To An Arduino UNO Board

We will also be utilizing the Arduino board’s built-in LED, but there is nothing we need to do for that here.

Once the circuit is built, connect your Arduino to your computer with the USB cable and power it up.

Creating An Arduino Account

To use the Arduino Cloud, you will need an Arduino account. The same Arduino account is used for the online store, forums, and cloud services. Go to the Arduino website and sign in, or create a new account if you don’t already have one, by clicking the SIGN IN button in the top right corner of the home page.

Connecting Your Board

For the Arduino Cloud service to work with your board, the service initially needs to be able to physically connect to and communicate with your board. This is accomplished via an application (sometimes referred to as a plugin), named the Arduino Create Agent, that runs in the background on your computer. The Create Agent connects the online experience of the Arduino Cloud to your connected physical device (board).

Connect your Arduino board to your computer via a USB cable and then go to the Create Agent installation page to initiate the installation process. Follow the instructions to download and install the application and then open it. Once the running application and your board are detected, the installation page will change to reflect that the application was successfully installed.

If you get the “We are not able to detect the installed agent” error, the application may not be able to discover or securely connect to your board. Try generating and installing the HTTPS certificates (Create Agent Icon> Generate and install HTTPS certificates) from the Create Agent icon within the menubar for Linux and macOS or the system tray for Windows to allow a connected board to become discoverable. I had to do this for my Arduino UNO R4 WiFi board.

Click the NEXT button to see the Congratulations page.

Once installed, you should see the Create Agent icon within the menubar for Linux and macOS or the system tray for Windows. Optionally, click the GO TO CLOUD EDITOR button to open the online Cloud Editor IDE to verify that your Arduino board is being detected properly. This can be accomplished by selecting the BareMinimum (Examples > 01.Basics > BareMinimum) sketch from the left panel of the Cloud Editor and uploading it to the board. If you can not upload the sketch, verify that your board and serial port are selected within the device field of the toolbar.

Creating A Thing

In Arduino Cloud nomenclature, Things are the logical representations of physical devices. A Thing is comprised of the associated physical device (such as an Arduino board or a smart lamp), network credentials, and one or more cloud variables. For supported boards, it also contains an associated sketch that is generated and updated automatically based on your configuration. A Thing uses a friendly name, e.g. Arduino Board or Living Room Lamp, for your actual physical device.

To create a Thing, we first need to go to the Arduino Cloud website. You can also access the Arduino Cloud site by clicking the cloud icon in the top right corner of most Arduino website pages. The home page should look like the following.

Arduino Cloud Home Page
Arduino Cloud Home Page

From there, select Things from the navigation panel on the left side of the page. If you have not created any Things yet, click the CREATE THING button at the bottom of the page. Otherwise, click the CREATE THING button in the top right corner of the page if a Thing already exists. If you are on the free Arduino Cloud plan, keep in mind that you are limited to two Things, so if you already have two, you will need to delete one first.

Rename the Untitled Thing (by clicking on the name and selecting the Rename option) to something that makes sense for your device. I chose Arduino Thing for the name of my Thing.

Associating A Device

Now we will associate a physical device, our Arduino board, with the logical Thing.

Select the Thing’s Setup tab, if it is not already selected, and then click the Select Device button within the Associated Device area.

If we had an existing device, we could select it here within the Associate device pop-up window that appears. Since we don’t, click the SET UP NEW DEVICE button to open the Setup Device pop-up window instead.

Next, choose the board type for your board. Since we are using an Arduino UNO R4 WiFi board in this tutorial, choose the Arduino board device type under the recommended AUTOMATIC section. This will allow the Arduino Cloud service to automatically generate our base sketch for us.

Once the device type is selected, the Create Agent application will automatically search for your board and let you know when it was found. If your board was not automatically detected, make sure that your board is connected to your computer and the Create Agent application is running. If you are using a different Arduino board other than the UNO R4 WiFi, make sure that your board is compatible with the Arduino Cloud by viewing the Arduino Cloud Compatible Boards page. Note that not all compatible boards are listed here. For a more complete list, go back to the original screen of the Setup Device pop-up window and hover over the info (i) icon within the Automatic Arduino board selection box.

Once the board is found, click the CONFIGURE button to begin configuring your board. On the next page, name your device. I chose Arduino UNO R4 WiFi for the name of my device. Click the NEXT button when you are done.

For devices that do not have a hardware secure element (crypto chip), like the UNO R4 WiFi, you will be presented with a secret key for your particular device that you need to save for later use. Save the generated PDF file and copy the Device ID and Secret Key values to a safe location. Click the I saved my device ID and Secret Key option and then click the CONTINUE button. The Arduino Cloud service will then configure and verify that your device can securely connect to the service. When requested, disconnect your board from power and your computer and then reconnect it to finish the configuration process.

Once the configuration is complete, click the CONFIRM button on the next page and then click the DONE button to close the window.

Details for the new device will be shown in the Associated Device area of the new Thing. The new device will also be listed on the Arduino Cloud’s Devices page.

Setting Up Network Access

While our Thing (board) is now configured to connect to the Arduino Cloud service via our computer, we still need to set up the wireless network credentials so that our Thing can connect to the service wirelessly.

Click the Configure button located within the Network area of your Thing. Enter the credentials (SSID and password) for your local WiFi network along with your secret key (generated in the last section), if needed, in the Configure network pop-up window that appears. Click the SAVE button to save the credentials and close the window when done.

Details for the network credentials will be shown in the Network area of your Thing.

Creating Cloud Variables

Cloud variables provide the communication links between your Thing and the Arduino Cloud service. They are synced using the MQTT protocol over a network connection. If a cloud variable is updated on your board (like reading a sensor), the service will also receive this value. We can then view this value from within an Arduino Cloud dashboard. Similarly, if you update a cloud variable from a dashboard, it also updates on your board. Cloud variables are attached to a specific Thing and a Thing can have one or more variables.

For our Thing, we will need cloud variables for the built-in LED and the connected potentiometer.

To create a new cloud variable for the LED, click the ADD button within the Cloud Variables area of your Thing. A new Add variable pop-up window will appear.

Enter the friendly cloud variable name of LEDState in the Name field.

We will ignore the Sync with other Things button at this time as it is used to sync a variable of one Thing with the variable of another Thing.

Select Boolean in the Select variable type field. This is the variable’s datatype that will be used within the associated sketch. Disable the Basic types button if you want to see all the datatypes available.

Change the name of the variable in the Declaration field to ledState. This is the name of the variable that will be used within the associated sketch.

Leave the Variable Permission field as Read & Write since we want to be able to control the LED from a dashboard. A Read & Write variable can work both as an input and an output; the data can be sent from the device to the cloud and vice versa. A Read Only variable can work only as an output; the data can be sent only from the device to the cloud.

Leave the Variable Update Policy as On change since we want to immediately update the board’s physical LED after turning on the logical LED in a dashboard. An On Change variable will be updated whenever the variable’s change in value is greater than or equal to a set threshold, if applicable. A Periodically variable will be updated each time a certain number of seconds has elapsed.

Your cloud variable’s configuration for the LED should look like that shown below.

Arduino Thing LEDState Cloud Variable Details
Arduino Thing LEDState Cloud Variable Details

Click the ADD VARIABLE button to add this cloud variable to your Thing.

The new variable will now be shown within the Cloud Variables section of your Thing.

Now let’s create a cloud variable for the potentiometer. Click the ADD button above the new Cloud Variables list to add the new variable. Use a friendly name of PotentiometerValue, a datatype of Integer Number, a declaration name of potValue, a permission of Read Only, and an update policy of On change with a threshold of 1.

Arduino Thing PotentiometerValue Cloud Variable Details
Arduino Thing PotentiometerValue Cloud Variable Details

Click the ADD VARIABLE button to add this variable.

If you tend to read my tutorials, you know I like to create a DEBUG flag within my sketches that will display debugging messages in the Serial Monitor when enabled. Although not required, let’s create a new cloud variable that will display those debugging messages within the dashboard as well. Create a new cloud variable with the following attributes: DebugMessage friendly name, Character String datatype, debugMessage declaration name, Read Only permissions, and On change update policy.

Arduino Thing DebugMessage Cloud Variable Details
Arduino Thing DebugMessage Cloud Variable Details

Now that your Thing is created and configured, the completed Arduino Thing should look like the following.

Completed Arduino Thing
Completed Arduino Thing

Reviewing The Generated Sketch

Now that our Thing is configured, let’s view the sketch that it automatically generated for us.

Click the Arduino Thing‘s Sketch tab to view the generated sketch.

The sketch begins with comments provided by Arduino with details about your Thing, including the sketch specific variable names of the associated cloud variables.

Next, the sketch includes the thingProperties.h header file. This file holds the Arduino Cloud configuration and connection details for your Thing. More on this later.

The setup() function initializes the serial port for use with the Serial Monitor, configures the cloud variables and connection via the initProperties() function, initiates the connection to the Arduino Cloud service, and then prints relevant debugging status as appropriate. The call to the setDebugMessageLevel() function can be set with a debug message level between 0 (errors only) and 4 (verbose messages).

The loop() function only contains a call to the update() method of the ArduinoCloud instance. This method must be invoked regularly to keep the sketch and the Arduino Cloud service in sync.

The last function, onLedStateChange(), is a callback function that gets called each time the LEDState cloud variable is updated in the dashboard. This is where we place the functionality we want to run when the variable is updated. For instance, if the logical LED is turned on in a dashboard, we will turn on the board’s physical LED here. We will do this a little later.

Viewing The Full Sketch In The Cloud Editor

The sketch we viewed in the previous section only contained the sketch’s primary implementation (ino) file. Other details such as the thingProperties.h header file and the WiFi credentials are not shown. The Thing’s Sketch tab is a mirrored minimal version of the full featured Cloud Editor.

Let’s open the Cloud Editor to view those extra sketch details. Click the Open full editor button within the toolbar above the sketch contents to open the sketch in the Cloud Editor. Once there, you will see the primary sketch file (ino) tab, named with a prefix of our Thing, i.e. Arduino_Thing in this case, and ending with the creation datestamp. You will also see the extra tabs of ReadMe.adoc, thingProperties.h, and Secret.

ReadMe.adoc is an AsciiDoc file containing project related information. A template is provided and is expected to be completed by the end user. I will not be updating this file in this tutorial, but feel free to update it for your project if interested.

As mentioned earlier, the thingProperties.h header file contains the Arduino Cloud configuration and connection details for your Thing. It includes the libraries needed to communicate with the Arduino Cloud service, the cloud variable declarations and associated callback routines, the initProperties() function that configures your Arduino Cloud interaction, and defines the WiFi connection. It also defines the “secrets” used within the sketch. The thingProperties.h file is automatically updated by the service whenever you create or make a change to an underlying cloud variable and is not intended to be edited by the user.

The Secret tab contains the literal strings for your secret values. If you look at its contents, you will see the secrets we provided for the WiFi SSID and password along with the secret device key that was generated for us. These are editable fields if you need to change them. The underlying file associated with this Secret tab is named arduino_secrets.h and will be included if you download the sketch. Note that Arduino strips out the literal string values when you share or download the sketch in order to protect your secrets.

Updating The Sketch

Now that we are finished reviewing the automatically generated sketch, let’s go ahead and update it to include the missing functionality. You can update the sketch in either the minimal editor (Sketch tab of the Arduino Thing) or the full Cloud Editor; the choice is yours.

Add the following define statements just above the setup() function within the primary sketch (ino) file.

#define DEBUG 1
#define POT_SAMPLE_PERIOD 1000

These define our debugging flag (use 1 to print debug statements and 0 for normal mode) and the sample period to use for reading the potentiometer. I am using a period of 1 second so as not to flood the Arduino Cloud service with variable synchronization requests.

Just after the above statements, specify the Arduino pin used for the wiper terminal of the connected potentiometer.

const uint8_t Pot = A1;

Now, let’s update the setup() function. Between the Serial Monitor configuration and the call to the initProperties() function, set the pin mode for the built-in LED to be an output.

pinMode(LED_BUILTIN, OUTPUT);

At the end of the setup() function, add the following to display our sketch’s debug status.

if (DEBUG) {
   printDebugMessage("DEBUG mode is enabled.");
} else {
   printDebugMessage("DEBUG mode is disabled.");
}

As you can see, I am using a separate function, named printDebugMessage(), to print debug messages within the sketch. Add this function to the end of the sketch.

void printDebugMessage(String message) {
   Serial.println(message);
   debugMessage = message;
   ArduinoCloud.update();
}

The above function prints the provided debug message to the Serial Monitor and then sets and synchronizes the debugMessage cloud variable with the Arduino Cloud service. This last part enables us to send and view the debug messages from within a dashboard.

Next, replace the onLedStateChange() callback function with the following.

void onLedStateChange() {
   if (ledState) {
      digitalWrite(LED_BUILTIN, HIGH);
      if (DEBUG) {
         printDebugMessage("Turned on LED.");
      }
   } else {
      digitalWrite(LED_BUILTIN, LOW);
      if (DEBUG) {
         printDebugMessage("Turned off LED.");
      }
   }
}

Here, we either turn on or off the built-in LED depending on the state of the ledState cloud variable and then print the appropriate debug message, if debugging is enabled. Reminder, this function will be called whenever the LEDState cloud variable is changed on the dashboard.

Finally, let’s update the loop() function. Replace it with the code shown below.

void loop() {
   ArduinoCloud.update();
   static unsigned long previousPotReadTime = 0;
   unsigned long currentTime = millis();
   if (currentTime - previousPotReadTime >= POT_SAMPLE_PERIOD) {
      potValue = map(analogRead(Pot), 0, 1023, 0, 100);
      if (DEBUG) {
         printDebugMessage("Read potentiometer value of " + String(potValue) + ".");
      }
      previousPotReadTime = currentTime;
   }
}

We retain the call to the ArduinoCloud‘s update() method and then add the code to read the potentiometer once every second. The actual value retrieved by the Arduino’s analog input pin is a 10-bit value with a range of 01023. That value is mapped to a percentage value (0100) before assigning it to the potValue cloud variable.

Now that we are done updating the sketch, click the Verify button to compile and check your sketch for errors. Fix any errors that are reported. We will run it later once we are done building the dashboard.

Our Thing (Arduino Thing) is now complete.

Creating The Dashboard

To interact with our new Thing, we need to create a dashboard.

Go to the Dashboards page within the Arduino Cloud by clicking the navigation icon in the top left corner of the page and selecting Dashboards. Then click the CREATE DASHBOARD button to create a new dashboard. Click the Untitled dashboard name and select Rename to rename your dashboard to something that makes sense for your project. I chose Arduino Dashboard for mine.

Click the ADD button within the toolbar and select Switch from the pop-up menu to add a Switch widget that we will use to control our LED. Change the name of the switch within the Name field to LED Switch to reflect the purpose of the switch. Click the Link Variable button, select the LEDState cloud variable (associated with the Arduino Thing), and then click the LINK VARIABLE button to link the LEDState variable to this widget. The widget’s details should look like the following.

Arduino Dashboard LED Switch Widget Details
Arduino Dashboard LED Switch Widget Details

Click the DONE button to finish creating your LED Switch widget and add it to the dashboard.

Next, click the ADD button again to add the Gauge widget for use with the potentiometer. This time, name the gauge as Potentiometer Gauge and link the PotentiometerValue cloud variable. The value range can be left as 0 and 100 as we want it to reflect a percentage.

Arduino Dashboard Potentiometer Gauge Widget Details
Arduino Dashboard Potentiometer Gauge Widget Details

Click the DONE button to finish creating your gauge widget.

Finally, let’s add a way to view the debug messages. Click the ADD button once more and select the Messenger widget this time. Name it Debug Messages and link the DebugMessage cloud variable.

Arduino Dashboard Debug Messages Widget Details
Arduino Dashboard Debug Messages Widget Details

Click the DONE button to add the widget.

All the widgets are now added to the dashboard. If you need to modify a widget, hover over the widget and select the vertical ellipsis menu that appears at the top right corner of the widget. From there you can edit, remove, or duplicate the widget.

If you want to modify the layout of the widgets, click the Arrange widgets (directional arrows) button in the toolbar next to the ADD button and then drag around and resize the widgets as desired. Click the DONE button when finished.

When you are happy with your dashboard, select the view mode (eyeball in the toolbar selector switch).

My Arduino Dashboard looks like the following.

Completed Arduino Dashboard
Completed Arduino Dashboard

Running The Sketch

So now we have a Thing, including the sketch, and a Dashboard to communicate with the Thing. Let’s run the sketch and see how this all works.

As was the case with editing the sketch, you can upload the sketch and view the Serial Monitor output from either the minimal editor (Sketch tab of the Arduino Thing) or the full Cloud Editor. With the Create Agent application running and your Arduino board connected to your computer, open the Serial Monitor and then upload the sketch.

Once the sketch is running, the Serial Monitor will show status and debugging messages such as device information, connection status for WiFi and the Arduino Cloud service, and our own debugging messages that were added to the sketch.

I found during testing that the Create Agent to online editor connection for my computer and board setup was not always stable and would often disconnect and connect inconsistently. In addition, sometimes the sketch would upload and run properly, but the Serial Monitor would not always show all of the expected output. If you find yourself having the same difficulty, you can download the sketch from the Cloud Editor (from the contextual menu in the toolbar) and run it locally from the standard desktop IDE. If you go this route, you should pause or quit the Create Agent app so that the two applications don’t conflict with each other when trying to communicate with the connected board. You will also need to install the required libraries (ArduinoIoTCloud, Arduino_ConnectionHandler, Arduino_DebugUtils, and ArduinoMqttClient) and reenter your secret credentials directly into the arduino_secrets.h header file. This process worked very well for me.

Interacting With Your Thing

Go to the Arduino Cloud’s Dashboards page and select your dashboard. Hopefully, you should see messages already being printed to the Debug Messages widget, such as Turned off LED. (the initial cloud variable sync) and Read potentiometer value of with some value shown, from your Arduino. When debugging is disabled, DEBUG is defined as 0 in the sketch, the DEBUG mode is disabled. message will be the only message that appears in the dashboard. Interestingly, the DEBUG mode is enabled. message is never shown on the dashboard even though it appears in the Serial Monitor. I believe it is a timing conflict with the initial synchronization of the cloud variables. I could not find an acceptable solution, but thought I should at least mention it in case you notice it as well.

Toggle ON and OFF the switch within the LED Switch widget and watch the built-in LED on the Arduino board turn on and off. You should also see the appropriate LED based debugging messages being printed to the Debug Messages widget within the dashboard along with the IDE’s Serial Monitor each time you do so.

Adjust the potentiometer connected to the Arduino board and watch the Potentiometer Gauge widget on the dashboard adjust to match. As with the LED, debug messages will be shown in both places. Keep in mind that the potentiometer is read every second according to the value set in the POT_SAMPLE_PERIOD constant within the sketch and that a debug message is printed every time the potentiometer is read. You can either adjust the constant’s value or disable the debugging mode (set DEBUG to 0) to limit the number of debugging messages shown. Adjust the potentiometer to its lowest and highest settings. While the values shown in the gauge should get very close, they may not actually reach their absolute minimum (0) and maximum (100) percentage limits.

The Arduino IoT Cloud Remote App

The web based dashboard is not the only place where we can interact with our Thing.

The Arduino IoT Cloud Remote app is the official companion app for the Arduino Cloud. It provides the ability to view your dashboards and interact with your Things via an app on your mobile phone.

Download and install the app from either the Apple App Store or the Google Play Store. Once installed, open the app, complete the onboarding process (if presented), and then log into your Arduino account. When finished, you should land on the Dashboards screen and see a list of your available dashboards. Click on your dashboard and then interact with your Thing just like you did from the webpage.

A very cool feature of the Arduino IoT Cloud Remote app is the ability to provide access to your phone’s internal sensors, e.g. GPS, IMU, etc., as cloud variables. These variables can then be used to view the sensor data within your dashboards. You can also synchronize the variables with the cloud variables of other Things so that they have access to the data provided by your phone’s sensors.

To access your phone’s sensors, click Devices in the tab bar at the bottom of the app, tap TRY PHONE AS DEVICE located at the top of the screen, and then follow the configuration process. If this option is not available, you can also click on your profile icon in the top right corner of the app, and then select Phone as device under Settings. Note that only a select group of sensors are available (and automatically selected) with the free Arduino Cloud plan; more sensors are available with a paid plan. Your phone will ask if the app can have access to your phone’s sensor data. Once complete, the configuration process will automatically create a new Thing (named iPhone Thing for my phone) and a new dashboard (named iPhone Dashboard for my phone) with default widgets to view your phone’s sensors’ real time data, and then open the new dashboard. The new dashboard will even be available on your Dashboards page on the web.

On my phone, the dashboard shows values for the Accelerometer X, Accelerometer Y, and Accelerometer Z values, a Linear accelerometer graph, and a GPS map showing the location of my phone. Move your phone around to different orientations and watch the accelerometer data change in the dashboard. For the adventurous, move around your yard or neighborhood and watch as your location changes on the map; it is good exercise for us nerds anyway.

By default, your phone’s sensor data will only be available while the app is open. If you want to enable access to the sensors in the background, click on your profile icon in the top right corner of the app, select the Phone as Device menu option under Settings, and then enable the Background data stream option. Note that this feature is only available with paid plans. Exit out of your profile and select the Dashboards tab to get back to your list of dashboards.

Close the Arduino IoT Cloud Remote app when you are done.

Wrapping Up

Before we end, now would be a good time to upload the BareMinimum sketch again in order to reset all of the board’s GPIO pins back to their default states. This ensures that no outputs are being driven that may damage your board or connected electronics when plugging in your board for your next project. This can be accomplished from either the desktop IDE (Main Menu > File > Examples > 01.Basics > BareMinimum) or the full Cloud Editor (Left Panel > Examples > 01.Basics > BareMinimum). You can also close the IDE and disconnect your board when you are done.

I only covered a subset of the Arduino Cloud features available to get you started. To learn more, check out the Arduino Cloud documentation and tutorials pages.

Additional Resources

The following is a list of additional resources you may find helpful.

Summary

In this tutorial, we learned how to use the Arduino Cloud service to connect your Arduino UNO R4 WiFi to the outside world.

Specifically, we

  • connected a potentiometer to our Arduino UNO R4 WiFi board.
  • created a new Arduino account, or signed in to an existing one, to access the Arduino Cloud service.
  • connected an Arduino UNO R4 WiFi board to the computer and the service using the Arduino Create Agent application.
  • created and configured a logical Arduino Cloud Thing consisting of
    • an Arduino UNO R4 WiFi board as the physical device,
    • the LEDState (built-in LED), PotentiometerValue (connected potentiometer), and DebugMessage cloud variables,
    • WiFi and Arduino Cloud credentials, and
    • an automatically generated sketch.
  • updated the generated sketch to add missing functionality.
  • created a dashboard using the Switch (LED Switch), Gauge (Potentiometer Gauge), and Messenger (Debug Messages) widgets.
  • uploaded and ran the updated sketch on the physical board.
  • interacted with the logical Thing from the dashboard, both from the Arduino Cloud website and the Arduino IoT Cloud Remote app.
  • used the Arduino IoT Cloud Remote app to access and view data from our mobile phone’s internal sensors.

Hopefully, this tutorial taught and inspired you how to use the Arduino Cloud service to connect and control your own devices. By attaching external sensors, actuators, etc. to your board, you can use the service to control elements in your smart home, monitor environmental conditions from far away locations, or a myriad of other uses.

The final source code and schematic used for this tutorial are available on GitHub. The GitHub version of the code is fully commented to include additional information, such as the program’s description, circuit connections, code clarifications, and other details. The comments are also Doxygen compatible in case you want to generate the code documentation yourself.

As a reminder, this tutorial was provided as a free service to our valued readers. Please help us continue this endeavor by considering a GitHub sponsorship or a PayPal donation.

Thank you for joining me on this journey and I hope you enjoyed the experience. Please feel free to share your thoughts or questions in the comments section below.

About the author

John Woolsey

John is an electrical engineer who loves science, math, and technology and teaching it to others even more.
 
He knew he wanted to work with electronics from an early age, building his first robot when he was in 8th grade. His first computer was a Timex/Sinclair 2068 followed by the Tandy 1000 TL (aka really old stuff).
 
He put himself through college (The University of Texas at Austin) by working at Motorola where he worked for many years afterward in the Semiconductor Products Sector in Research and Development.
 
John started developing mobile app software in 2010 for himself and for other companies. He has also taught programming to kids for summer school and enjoyed years of judging kids science projects at the Austin Energy Regional Science Festival.
 
Electronics, software, and teaching all culminate in his new venture to learn, make, and teach others via the Woolsey Workshop website.

2 Comments

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.