• Home
  • Tutorials
  • What is IoT? Getting Started with IoT using Adafruit IO and PictoBlox

What is IoT? Getting Started with IoT using Adafruit IO and PictoBlox

What is IoT
About This Tutorial
Learn what is IoT, how does IoT works, how to get started with IoT using Adafruit IO and PictoBlox.
Tutorial Info

Components Required

Image Component Quantity Available in Kit
evive 1
ESP8266 Module (ESP-12) 1
5V Relay module 1
Bulb 1
  • None
Bulb Holder 1
  • None
Male to Female Jumper Cable 20cm 3
PictoBlox To be Downloaded

Introduction

IoT is something that we, if not hear then at least see quite often in our daily lives nowadays. We can integrate it with almost every field from home automation to manufacturing, from medical care to environment and energy management. In this tutorial on getting started with IoT, learn what is IoT, how IoT works, what is the IoT lifecycle, what is a cloud, how to work with IoT using Adafruit IO and PictoBlox – our Scratch blocks-based graphical programming platform with advanced hardware interaction abilities, and finally how to make a project on home automation based on IoT using the evive IoT Kit.

To work in PictoBlox, you’ll first need to download it from HERE.

Ready? Set. Go!

What is IoT?

The Internet of Things is the network of physical objects or “things” embedded with sensors, actuators, and internet connectivity, which enables these objects to collect and exchange data.

A “Thing” in the context of the IoT, is an entity or physical object that has a Unique identifier, which is a unique sequence of characters used to identify or refer to it, combined with an embedded system and has the ability to transfer data over the internet.

These devices collect useful data and then autonomously flow share it between other devices.What is IoT

What is IoT Lifecycle?

Now we know in brief, what is IoT, let’s understand how the IoT ecosystem works in the real world using what is known as an IoT lifecycle.

The IoT life cycle comprises systems for

  1. Collection
  2. Communication
  3. Analyzing
  4. ActingWhat is IoT Lifecycle

Collection

Let’s start with the first phase i.e. the collection. For any device or any system to perform any action, first, it needs some data to act on. This data can either be generated from any sensors or any IoT devices about the thing. 

The data generated can be from any sensor be it temperature sensors, motion sensors, moisture sensors, air quality sensors, light sensors, you name it.IoT Lifecycle

Communication

Next, onto the Communication phase. The data collected from the sensors is then sent to the Internet to some destination with security and reliability. The devices like routers, switches, etc. are used to sent data across the destination devices. The destination devices could be

  1. A cloud platform like Google or Alexa 
  2. Private data center like Indian Defence Data Centers
  3. Home networks like Smart-home networks.IoT Lifecycle

Analysis

In the next phase, that is the Analysis phase, the data which we collected needs to be analyzed to create a meaningful format. It could be 

  1. Visualizing the data like temperature variation during the day
  2. Building reports to analyze the manufacturing system cause
  3. Setting up events like should you the Air Conditioner ON or OFF depending on the temperature.IoT Lifecycle

Acting

Now that we have the final form of data we need to perform an action according to it. The actions based on the information and data could be

  1. Communicating with another machine- like turning the AC ON or OFF
  2. Sending a notification (SMS, E-mail, or Text)- like notifying that the plants have been watered.
  3. And much more.IoT Lifecycle

Application of IoT

We use IoT in normally all the fields of life.

  1. Building and Home Automation
  2. Manufacturing
  3. Medical and Healthcare systems
  4. Environmental monitoring
  5. Energy management
  6. Transportation
  7. Better quality of life for the elderly and what not!

What is the Cloud?

In an IoT system, the most important component is the cloud service on which we can store or retrieve data as per the applications. A cloud service is any service made available to users on demand through the internet. Cloud services are designed to provide easy & scalable access to applications, resources, and services. Cloud is the collection of data servers used to provide services like computing, analyzing, networking, etc.

There are a number of cloud service providers out there, like Amazon, Microsoft, Salesforce, Apple, etc. One such cloud service is Adafruit.io which we are going to use. What is Cloud

Getting Started with Adafruit.io

Adafruit.io is one of the websites that provide the cloud service to us. It can

  1. Collect data
  2. Display the data in real-time, online
  3. You can get access to any data that has been stored anywhere across the globe
  4. Make your project internet-connected
  5. Connect your project to other internet-enabled devices

Go to https://io.adafruit.com to get access to this cloud service. Once you are there you need to create an account to use it. If you already have an account on it you are good to go else you need to create one. You can create the account by clicking on the Get Started for Free tab.  Fill up your details and voila!

Understanding the Feed of Adafruit.io

Now that you have signed into Adafruit.io, click on the IO button above to get to the Adafruit Dashboard. Your dashboard will look something like the image below:

Adafruit Dashboard

Let’s get started by understanding what feed in Adafruit means.

Feeds are the core of the Adafruit IO system. A feed contains information about the data you push to Adafruit IO and also the sensor data values that get pushed to Adafruit IO from your device. It allows you to visualize the data you send from the source. You will need to create one feed for each unique source of data you send to the system. Follow the steps below to make a feed for your self.

  1. First, click the Feeds tab.
  2. Then, select view all feeds.
  3. Now click the Actions menu.
  4. From its drop-down menu, select Create a New Feed from it.
  5. Give the feed a name and description and then click Create.Adafruit Feed Dashboard
  6. Double click the feed to see it.Adafruit Feed

Understanding the Dashboard of Adafruit.io

Now that we have created our Adafruit Feed, it’s time to look into the Adafruit Dashboard. It is the place where you will interact with the system and the information from the dashboard can be visualize in the Feed section. Let’s create the Dashboard. Follow the steps to create the Dashboard.

  1. Click the Dashboards tab.
  2. Then, select view all dashboards.
  3. Now click the Actions menu.
  4. From its drop-down menu, select Create a New Dashboard from it.
  5. Enter the name and the description of the dashboard and click Create.Adafruit Dashboard
  6. Double click the dashboard to see it.Adafruit Dashboard

Adding the Widgets on the Dashboard

Now that we have created the Dashboard and Feed in Adafruit, let’s add a block in the Dashboard. Blocks are nothing but widgets that you can add in your Dashboard. Follow the steps below to add a switch on the Dashboard.

  1. To add blocks, click on the plus symbol.
  2. You can see a variety of blocks.Adafruit Widgets
  3. From them, select toggle.
  4. Next, select the feed that we created.
  5. Add the title Switch, click Create block.Selecting the feed for WidgetAdafruit Toggle Button

Now Let’s test this button first by toggling the switch. Next, let’s visualize the data by opening the feed. When you open the feed, you can observe the data obtained from the switch with the given timestamp on the Adafruit Feed.Adafruit Feed

Controlling the Light Bulb Using Adafruit Dashboard

Now that we saw how Adafruit IO works, let’s see it in action. Let’s begin by connecting the light bulb to evive.

  1. Connect VCC of Relay to +5v on evive
  2. Connect GND of Relay to GND on evive
  3. Connect Signal pin of Relay to evive’s digital pin 13
  4. Connect the Esp8266 module to its headers on eviveConnecting Light Bulb with evive

Programming the Lighting System Using PictoBlox

Now that we have connected the relay with evive, let’s program it in PictoBlox- it is a graphical programming software based on Scratch blocks. Follow the steps below to program is.

  1. Before doing anything else, connect evive to your computer using a USB cable. Next, open PictoBlox.
  2. Then, click the board button and select evive from the drop-down. Now, from the dialogue box that appears, choose the appropriate serial port.
  3. We will write our code in upload mode, thus click the Stage and Upload Toggle button.
  4. First, add the Internet of Things extension in PictoBlox by clicking the Add extension button in the bottom left corner.Internet of Things Extension in PictoBlox
  5. The block connect to Wi-Fi () with password () connects the ESP8266 module connected to evive to the Wi-Fi. Enter the Wi-Fi name and password in their respective spaces into the blocks.Connect to WiFi with Password block
  6. The connect to Adafruit IO username () & AIO key () block connects to the Adafruit Feed using Username and AIO Key. You need to enter the Username and AIO Key in the block. Connect to Adafruit IO blockYou can get it from your Adafruit dashboard.
    1. To find the AIO key click on the AIO key button on the Adafruit IO website.Adafruit IO button
    2. Find your Active key and copy-paste it to your block in PictoBlox.Adafruit Active Key
  7. Use the forever block to run the script continuously.
  8. Now, to store the data from the Adafruit block, we will make a variable that will store the string. Name the variable LED State and set it as a string type.Variable As String
  9. Now we will set the value of the variable as data coming from the feed. For that, drag and drop the get last data from the feed () as a () block. Write the name of the Feed from which you want to get the data from and select string as the variable type.get last data from feed block
  10. Now, using an if block, we will check if the value we got is ON or OFF. If the value is ON, set the relay on pin 13 as ON. And if the value of the LED state is OFF, set the relay as OFF.Turning the bulb ON and OFF
  11. Let’s fill the display with black color. Add this block above the entire script.
  12. Set the cursor location as 10, 10  by adding its block inside the forever block and display the value of LED state on the screen using a join block.Dsplaying LED status on Screen
  13. Drop a when evive starts up hat block above the entire script to execute the program.
  14. Now that our script is ready, upload it to evive by clicking on the Upload Code Button.
    evive Alert
    Alert: Make sure that you disconnect the wire from Pin13 before uploading the code.
  15. Here is the entire script. Also, you can download it from here.Controlling Light Bulb using Adafruit IO

Identifying whether the Wi-Fi and the Adafruit IO is connected or not?

Once you have uploaded your code in evive. Switch evive ON. You will notice two things happening.

  1. The LED color of M1.
    1. If the LED color is Yellow it means that evive is connected to Wi-Fi.
    2. If the LED color is Red, it means that evive is not connected to Wi-Fi. Thus, you need to check if your Wi-Fi name and password into the PictoBlox’s block.
  2. The LED color of M2.
    1. If the LED color is Yellow it means that evive is connected to Adafruit IO or cloud.
    2. If the LED color is Red, it means that evive is not connected to the cloud. Thus, you need to check if your Adafruit username and AIO Active key into the PictoBlox’s block.

Once when both the Wi-Fi and the Cloud are connected, toggle the switch on the Adafruit dashboard, the bulb will turn on and off respectively.

Conclusion

Now that you are familiar with the basics of IoT and know how IoT works, you’re ready to try out the numerous exciting projects that we have in store for you.

Happy tinkering!

[tutorialRelatedProjects]
Share this Tutorial
Share on facebook
Facebook
Share on twitter
Twitter
Share on google
Google+
Share on pinterest
Pinterest
Share on reddit
Reddit
Share on print
Print
Featured Projects
All articles loaded
No more articles to load

Leave a Reply