Reader small image

You're reading from  Arduino IoT Cloud for Developers

Product typeBook
Published inNov 2023
PublisherPackt
ISBN-139781837637171
Edition1st Edition
Right arrow
Author (1)
Muhammad Afzal
Muhammad Afzal
author image
Muhammad Afzal

Muhammad Afzal is a senior software engineer, with more than 14 years of experience working on web-based and IoT systems in multinational organizations. He always enjoys working and solving real-world business problems with technology. He provides freelance services to IoT-based product companies to write technical reviews and projects, and he also provides consultancy to organizations. In his free time, Muhammad creates videos and courses for YouTube and Udemy. He also runs a maker movement in his region for young students to boost their interest in adopting the latest technologies.
Read more about Muhammad Afzal

Right arrow

Implementing the Arduino IoT Cloud Scheduler and Over-the-Air Features

The world is full of different and interesting use cases that vary according to different circumstances. In the world of full automation, many use cases require applications to perform a specific operation at a certain time or frequency, defined by an end user. To handle this situation, the Arduino IoT Cloud has a Scheduler feature to let end users configure the execution time and frequency through a dashboard, without any modification to code on end devices. Initially, in this chapter, you will learn about the Arduino IoT Cloud Scheduler feature and its implementation.

Then, this chapter will cover the Over-the-Air (OTA) feature, which is becoming increasingly popular in remote devices such as mobile nodes, especially remote IoT nodes. The OTA feature allows you to broadcast the firmware update to IoT nodes, which will update wirelessly without any physical connection. This procedure enables the remote maintenance...

Technical requirements

Before we go any further, first of all, you need to have an Arduino IoT Cloud-compatible board. I recommend Arduino MKR Wi-Fi 1010 with a bunch of 5 mm LEDs, but here is the complete list of compatible boards: https://store-usa.arduino.cc/pages/cloud-compatible-boards. You can choose one according to your requirements.

Second, you need to have an Arduino IoT Cloud account. If you don’t already have one, you can sign up at https://cloud.arduino.cc/ and select a plan according to your requirements.

Third, we need to download and install the Arduino Create Agent. Arduino has created a very beautiful web-based guide for installation at https://create.arduino.cc/getting-started/plugin/welcome. The code for this chapter is available in the book’s official GitHub repository at https://github.com/PacktPublishing/Arduino-IoT-Cloud-for-Developers.

Important note

All the Arduino IoT Cloud plans were discussed in detail in Chapter 1. You can also...

The importance of the Scheduler in IoT

Within the realm of IoT and cloud computing, a scheduler refers to a component or system that is responsible for managing and controlling the timing and execution of tasks, processes, or events. Its primary function is to ensure the smooth and efficient operation of various activities within an IoT cloud setup. Here are some advantages of employing a scheduler in an IoT cloud environment:

  • Task coordination: The scheduler facilitates the orchestration of multiple tasks and processes in an IoT cloud by allowing users to define dependencies and priorities. This ensures that tasks are executed in the desired sequence, which is particularly crucial in complex IoT systems involving interconnected devices and services.
  • Resource optimization: With the limited computational resources typically found in an IoT cloud, a scheduler optimizes its utilization by intelligently assigning tasks based on requirements, available resources, and priorities...

Using the Arduino IoT Cloud Scheduler – an MKR Wi-Fi 1010 illustration

In this section, we will take a look at how the Arduino IoT Cloud Scheduler provides different benefits and when and where we require scheduler functionality. Later, we will implement a practical example of a Scheduler using MKR Wi-Fi 1010.

The Arduino IoT Cloud Scheduler

The Arduino IoT Cloud Scheduler is a feature integrated into the Arduino IoT Cloud platform that empowers users to schedule and automate actions and events for their connected Arduino devices. It provides a convenient way to define and manage the timing of various tasks and functions within IoT projects. Here are some key aspects and benefits of the Arduino IoT Cloud Scheduler:

  • Task scheduling: The Arduino IoT Cloud Scheduler allows users to schedule tasks and events on their Arduino devices. It enables the definition of specific timings, intervals, or triggers for actions such as data collection, device control, and sensor...

Initial configuration – Things, network credentials, cloud variables, and code

After setting up the hardware, it’s time to set up a Thing in the Arduino IoT Cloud. For this project, we need three cloud variables for the Scheduler, which will be linked with dashboard widgets and receive the values from users. Later, the device will perform an operation (in our example, it will turn the LEDs on and off according to a scheduler time) when the Scheduler is active. Figure 11.2 gives a complete overview of the Cloud Scheduler Thing.

Figure 11.2 – The Cloud Scheduler Thing setup

Figure 11.2 – The Cloud Scheduler Thing setup

Set up a new Thing with the name CloudScheduler. Take the following steps to create cloud variables, associate a device, set up network configuration, and finally, write the code. In Figure 11.2, all the steps are marked with a number above red boxes, which relate to the following steps:

  1. Firstly, we need to set up three cloud variables for CloudScheduler....

Dashboard creation and a deep dive into the Scheduler widget

After uploading the code to the device, it’s time to set up a dashboard for web and mobile to insert the multiple Scheduler widgets that will be linked to the Scheduler variables, for further controls and operations. The following figure shows the visualization Scheduler with different timer options:

Figure 11.8 – The Thing dashboard

Figure 11.8 – The Thing dashboard

We have three Scheduler variables. To visualize all of them, three Scheduler widgets will be linked to each cloud variable, respectively. The purpose of the three widgets and variables is to demonstrate how we can set different types of timers. The first widget demonstrates how to use a timer that will be executed every minute for 30 seconds, the second widget demonstrates how to use a timer that will be activated every hour for five minutes, and the third widget demonstrates that we can set the timer for a long period, such as specific days at a specific...

The task at hand – an assignment

Continuing from the previous project where you connected three LEDs to the MKR Wi-Fi 1010 and set up the Arduino IoT Cloud Scheduler, complete the following assignment tasks:

  • Attach three relays to control any electrical/electronic appliance, such as a fan, light, or heater, using the Scheduler.
  • Implement the Scheduler to turn your home’s outside/indoor lights on/off.
  • Attach a buzzer instead of LEDs, and create an alarm device for your room/classroom.
  • Turn on surprise lighting with the Scheduler for a birthday or anniversary. Use the same light strip with multiple Schedulers to turn the light strips on/off for different occasions.
  • Control the water solenoid valve for your garden/tunnel farm using the Scheduler (this is optional, and if you have a smart agriculture facility).

In this section, we outlined an assignment that will test your skills with different scenarios and help you explore the usage of the...

Exploring OTA updates in IoT

OTA is a term that refers to the wireless distribution of software or firmware updates, or other updates to devices. This technology allows updates to be delivered and installed on devices without the need for physical connections or manual intervention. OTA is widely utilized across various industries, including telecommunications, automotive, consumer electronics, and IoT. Here are a few examples of OTA usage:

  • Mobile devices: OTA updates are commonly employed to distribute operating system updates, security patches, and feature enhancements to smartphones and tablets. Users receive notifications, prompting them to download and install the updates wirelessly.
  • Automotive industry: Many modern vehicles are equipped with OTA capabilities, enabling manufacturers to remotely update the vehicle software, infotainment systems, navigation maps, and other features. OTA updates can improve vehicle performance, introduce new functionalities, and address...

Leveraging the Arduino IoT Cloud for OTA updates

Arduino IoT Cloud OTA is a feature available in the Arduino IoT Cloud platform, designed to facilitate the remote monitoring and control of Arduino-based IoT devices. This functionality allows users to wirelessly update the firmware of their deployed Arduino IoT devices.

The Arduino IoT Cloud pros

The Arduino IoT Cloud OTA feature offers the following capabilities:

  • Firmware updates: Users can remotely update the firmware of their Arduino IoT devices as well as ESP-series devices using Arduino IoT Cloud OTA. This enables the deployment of bug fixes, security patches, feature enhancements, and new versions of code without the need for physical access to the devices.
  • Code synchronization: The OTA feature ensures that the code running on Arduino/ESP-series IoT devices remains synchronized with the latest version stored on the cloud. It eliminates the necessity of manually updating each device individually, thereby maintaining...

Summary

In this chapter, we explored the Scheduler and how we can use the Arduino IoT Cloud to automate tasks that have different patterns or random patterns of operation. We used simple LEDs with the MKR Wi-Fi 1010 to demonstrate multiple Scheduler/timer operations, which helped you to understand how to use this function in real-world projects, such as in smart agriculture and smart industry.

In the second part of the chapter, we explored OTA. Firstly, we discussed the pros and cons of OTA and how we can save time and costs with it. Then, we used OTA-enabled development boards to demonstrate the use of the OTA feature, and finally, we explored how OTA works behind the scenes.

In the following chapter, we will implement a healthcare project. You will learn how to use a heartbeat sensor as well as the Arduino IoT Cloud webhooks feature, which will send data to a third-party service (Zapier). We will use Zapier to set up a Zap, which will receive the heartbeat readings and send...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Arduino IoT Cloud for Developers
Published in: Nov 2023Publisher: PacktISBN-13: 9781837637171
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Muhammad Afzal

Muhammad Afzal is a senior software engineer, with more than 14 years of experience working on web-based and IoT systems in multinational organizations. He always enjoys working and solving real-world business problems with technology. He provides freelance services to IoT-based product companies to write technical reviews and projects, and he also provides consultancy to organizations. In his free time, Muhammad creates videos and courses for YouTube and Udemy. He also runs a maker movement in his region for young students to boost their interest in adopting the latest technologies.
Read more about Muhammad Afzal