Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon

Introduction to IOT

Save for later
  • 11 min read
  • 17 Jul 2017

article-image

In this article by Kallol Bosu Roy Choudhuri, the author of the book Learn Arduino Prototyping in 10 days, we will learn about IoT.

(For more resources related to this topic, see here.)

As per Gartner, the number of connected devices around the world is going to reach 50 billion by the year 2020. Just imagine the magnitude and scale of the hyper-connectedness that is being forged every moment, as we read through this exciting article.

introduction-iot-img-0

Figure 1: A typical IoT scenario (automobile example)

As we can see in the preceding figure, a typical IoT-based scenario is composed of the following fundamental building blocks:

  • IoT edge device
  • IoT cloud platform

An IoT device is used to serve as a bridge between existing machines on the ground and an IoT cloud platform.

The IoT cloud platform provides a cloud-based infrastructure backbone for data acquisition, data storage, and computing power for data analytics and reporting.

The Arduino platform can be effectively used for prototyping IoT devices for almost any IoT solution very rapidly.

Building the edge device

In this section, we will learn how to use the ESP8266 Wi-Fi chip with the Arduino Uno for connecting to the Internet and posting data to an IoT cloud. There are numerous IoT cloud players in the market today, including Microsoft Azure and Amazon IoT. In this article, we will use the ThingSpeak IoT platform that is very simple to use with the Arduino platform.

The following parts will be required for this prototype:

  • 1 Arduino Uno R3
  • 1 USB Cable
  • 1 ESP8266-01 Wi-Fi Transceiver module
  • 1 Breadboard
  • 1 pc. 1K Ohms resistor
  • 1 pc. 2k ohms resistor
  • Some jumper wires

Once all the parts have been assembled, follow the breadboard circuit shown in the following figure and build the edge device:

introduction-iot-img-1

Figure 2: ESP8266 with Arduino Uno Wiring

The important facts to remember in the preceding setup are:

  • The RXD pin of the ESP8266 chip should receive a 3.3V input signal. We have ensured this by employing the voltage division method.
  • For test purposes, the preceding setup should work fine. However, the ESP8266 chip is demanding when it comes to power (read current) consumption, especially during transmission cycles.

Just in case the ESP8266 chip does not respond to the Arduino sketch or AT commands properly, then the power supply may not be enough. Try using a separate battery for the setup. When using a separate battery, remember to use a voltage regulator that steps down the voltage to 3.3 volts before supplying the ESP8266 chip. For prolonged usage, a separate battery based power supply is recommended.

Smart retail project inspiration

In the previous sections, we looked at the basics of achieving IoT prototyping with the Arduino platform and an IoT cloud platform. With this basic knowledge, you are encouraged to start exploring more advanced IoT scenarios. As a future inspiration, the following smart retail project idea is being provided for you to try by applying the basic principles that you have learned in this article. After all, the goal of this article has been to show you the light and make you self-reliant with the Arduino platform.

Imagine a large retail store where products are displayed in hundreds of aisles and thousands of racks. Such large warehouse-type retail layouts are common in some countries, usually with furniture sellers. One of the time-consuming tasks that these retail shops face is to keep the price of their displayed inventory matched with the ever changing competitive market rates. For example, the price of a sofa set could be marked at 350 dollars on aisle number 47 rack number 1.

Now let's think from a customer’s perspective. Imagine being a potential customer, standing in front of the sofa set we would naturally search for the prices of that sofa set on the Internet. It would not be very surprising to find a similar sofa set that is priced a little lower, maybe at 325 dollars at another store. That is exactly how and when a potential customer would change her mind. The story after this is simple. The customer leaves store A, goes to store B and purchases the sofa set at 325 dollars.

In order to address these types of lost sale opportunities, the furniture company management decides to lower the prices of the sofa set to 325 dollars, in order to match the competition. Thereafter, all that needs to be done is for someone to change the price label for the sofa set in aisle number 47 rack number 1, which is a 5–10 minute walk (considering the size of the shop floor) from the shop back office. In a localized store, it is still achievable without further loss of customers.

Now, let's appreciate the problem by thinking hyperscale. The furniture seller’s management is located centrally, say in Sweden and they want to dynamically change the product prices for specific price-sensitive products that are displayed across more than 350 stores, in more than 40 countries. The price change should be automatic, near real time, and simultaneous across all company stores.

Given the preceding problem statement, it seems a daunting task that could leave hundreds for shop floor staff scampering all day long, just to keep changing price tags for hundreds of products. An elegant solution to this problem lies in the Internet-of-Things.

introduction-iot-img-2

Figure 3: Smart retail with IoT

Referring to the preceding figure, it depicts a basic IoT solution for addressing the furniture seller’s problem to matching product prices dynamically on the fly. Remember, since this is an Arduino prototyping article, the stress is on edge device prototyping. However, IoT as a whole; encompasses many areas that include edge devices and cloud platform capabilities. Our focus in this section is to be able to comprehend and build the edge device prototype that supports this smart retail IoT solution.

In the preceding solution, the cloud platform takes care of running intelligent program batches to continuously analyze market rates for price-sensitive products. Once a new price has been determined by the cloud job/program, the new product prices are updated in the cloud-hosted database. Immediately after a new price change, all the IoT edge devices attached to the price tag of specific products in the company stores are notified of the new price.

We can build a smart LCD panel for displaying product prices. For Internet connectivity, we can reuse the ESP8266 Wi-Fi chip that we learned in this article.

Standalone Devices

We are already familiar with the basic parts required for building a prototype. The two new aspects to consider when building a standalone project are an independent power source and a project container.

introduction-iot-img-3

Figure 4 - Typical parts of a Standalone Prototype

As shown above, typically a standalone device prototype will contain the following parts:

Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at ₹800/month. Cancel anytime
  • The device prototype (Arduino board + Peripherals + all the required Connections)
  • An independent power source
  • A project container/box

After the basic prototype has been built the next consideration is to make it operable on its own, like an island. This is because in real world situations, you will often have to make a device that is not directly be connected to and powered from a computer. Therefore we will need to understand the various options that are available for powering our device prototypes and also understand when to choose which option.

The second aspect to consider is an appropriate physical container to house the various parts of a project. A container is a physical device container will ensure that all parts of a project are nicely packaged in a safe and aesthetic manner.

A distance measurement device

Let's build an exciting project by combining an Ultrasonic Sensor with a 16x2 LCD character display to build an electronic distance measurement device. We will use one of the most easily available 9-volt batteries for powering this standalone device prototype.

For building the distance measurement device, the following parts will be required.

  • Arduino Uno R3
  • USB connector
  • 1 pc. 9 volt battery
  • 1 full sized bread board
  • 1 HC-SR04 ultrasonic sensor
  • 1 pc. 16x2 LCD character display
  • 1 pc. 10K potentiometer
  • 2 pcs. 220 ohms resistor
  • 1 pc. 150 ohms resistor
  • Some jumper wires

Before we start building the device, let's understand what the device will do and the various parts involved in the device. The purpose of the device will be to be able to measure the distance of an object from the device. The following diagram depicts the overview of the device:

introduction-iot-img-4

Figure 5 - A standalone distance measurement device overview

First, let's quickly understand each of the components involved in the preceding setup. Then, we will jump into hands-on prototyping and coding. The ultrasonic sensor model used in this example is known as HC-SR04. HC-SR04 is a standard commercially available ultrasonic transceiver.

A transceiver is a device that is capable of transmitting as well as receiving signals. The HC-SR04 transceiver transmits ultrasonic signals. Once the signals hit an object/obstacle, the signals echo back to the HC-SR04 transceiver. The HC-SR04 ultrasonic module is shown below for reference.

introduction-iot-img-5

Figure 6 - The HC-SR04 Ultrasonic module

The HC-SR-04 has four pins. The usage of the pins is explained below for easy understanding:

  • Vcc: This pin is connected to a 5 volt power supply.
  • Trig: This pin receives digital signals from the attached microcontroller unit in order to send out an ultrasonic burst.
  • Echo: This pin sends the measured time duration proportional to the distance travelled by the ultrasonic burst.
  • Gnd: This pin is connected to the ground terminal.

The total time taken for the ultrasonic signals to echo back from an obstacle can be divided by 2 and then based on the speed of sound in air, the distance between the object and the HC-SR04 can be calculated.

We will see how to calculate the distance in the sketch for this device prototype. As per the HC-SR04 data sheet, it is a 5-volt tolerant device, operating at 15 mA, and has a measurement range starting from 2 centimeters to a maximum of 4 meters. The HC-SR04 can be directly connected to the Arduino board pins.

The 16x2 LCD character display is also a standard commercially available device, it has 16 columns and 2 rows. The LCD is controlled by its 4 data pins/lines. We will also see how to send string outputs to the LCD from the Arduino sketch.

The power supply being used in today's example is a standard 9-volt battery plugged in Arduino's DC IN Jack. Alternatively, another option is to use 6 pieces of either AA-sized or AAA-sized batteries in series and plug them into the VIN pin of the Arduino board.

Distance measurement device circuit

Follow the bread board diagram shown next to build the distance measurement device. The diagram shown on the next page is quite complex. Take your time as you unravel through it. All the components (including the Arduino board) in this prototype are powered from the 9 volt battery.

Sometimes the LCD procured online might not ship with soldered header pins. In such a case, you will have to solder 16 header pins.

It is very important to note that unless the header pins are soldered properly into the LCD board, the LCD screen will not work correctly.

This is a very challenging prototype to get it working at one go. Make sure there are no loose jumper wires.

Notice how the positive and negative terminals of the power source are plugged into the VIN and GND pins of the Arduino board respectively.

The 10K potentiometer has three legs. If you look straight at the breadboard diagram, the left hand side leg of the potentiometer is connected to the 5V power supply rail of the breadboard.

introduction-iot-img-6

Figure 7 - Typical potentiometersr

The right hand-side leg is connected to the common ground rail of the breadboard. The leg in the middle is the regulated (via the potentiometer's 10K resistance dial) output that controls the LCD's V0/VEE pin. Basically, this pin controls the contrast of the display. You will also have to adjust (a simple screw driver may be used) the 10K potentiometer dial (to around halfway at 5K) to make the characters visible on the LCD screen. Initially, you may not see anything on the LCD, until the potentiometer is adjusted properly.

introduction-iot-img-7

Figure 8 - Distance measurement device prototype

When the 'Trig' pin receives a signal (via pin D8 in this example) and results in sending out ultrasonic waves to the surroundings. As soon as the ultrasonic waves collide with an obstacle, they get reflected. The reflected ultrasonic waves are received by the HC-SR04 sensor. The Echo pin is used to read the output of the ultrasonic sensor (via pin D7 in this example). The output read from the 'Echo' pin is processed by the Arduino sketch to calculate the distance.

Summary

Thus an IoT device is used to serve as a bridge between existing machines on the ground and an IoT cloud platform.

Resources for Article:


Further resources on this subject: