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

Project #1 – a Smarter Setup for Sensing the Environment

This chapter guides you through the reasons why a clean environment is necessary for human beings and how to implement air quality, temperature, and humidity monitoring by using low-cost ESP-series boards, with different open source sensors and the Arduino IoT Cloud. Moreover, you will learn how to visualize the relevant data and use the Arduino IoT Cloud features to expand the functionalities of your applications/projects.

In this chapter, you will gain confidence in how to build real-world solutions as we demonstrate Printed Circuit Board (PCB) design, its implementation, and its deployment in the real world. We will cover the following topics:

  • Why is air quality monitoring necessary?
  • Hardware components – sensors and development boards
  • Project architecture
  • Setting up the Thing, network credentials, cloud variables, and code
  • Setting up a dashboard for web and mobile
  • What’s...

Technical requirements

The following hardware components are required to understand this chapter:

  • WeMos D1 MINI ESP8266
  • A DHT11/DHT22 sensor/module
  • The MQ-135 air quality module
  • A PCB (a link is available in the PCB design and assembling hardware components section)
  • Female headers
  • Jumper cables

For coding, we will use the Arduino Web Editor, which includes a large collection of development boards and sensor libraries, and the Arduino IoT Cloud for Thing and dashboard setup. To develop hardware and sensor designs, we will need Fritzing desktop software.

The code for this chapter is available at the book’s official GitHub repository, or you can directly download the code by following this link: https://github.com/PacktPublishing/Arduino-IoT-Cloud-for-Developers/tree/main/Chapter%234%20Project%231%20Sensing%20and%20Monitoring%20the%20Air%20for%20Clean%20Environment.

Why is air quality monitoring necessary?

Air quality monitoring is necessary for human beings because air pollution can have significant negative effects on our health and well-being. Poor air quality can cause a variety of respiratory and cardiovascular problems, such as asthma, chronic bronchitis, lung cancer, and heart disease. It can also exacerbate existing health conditions and reduce our ability to fight off infections and illnesses.

Air pollution can also impact the environment, including ecosystems, wildlife, and plants. Polluted air can lead to acid rain, which can damage crops, forests, and bodies of water and harm wildlife. It can also lead to the depletion of the ozone layer, which protects us from harmful UV radiation.

By monitoring air quality, we can identify areas where pollution levels are high and take steps to reduce exposure. This can include reducing emissions from factories, power plants, and transportation, as well as encouraging the use of clean energy...

Exploring the hardware requirements

Before moving forward, we will first look at what types of development boards and sensors are required to accomplish the project. We aim to use a board that provides Wi-Fi connectivity, is small in size, and is low in cost. If we talk about Wi-Fi-enabled development boards, then there are a lot of organizations providing them, such as Arduino, the ESP32 series, and the ESP8266 series. Arduino development boards such as MKR Wi-Fi 1010 and MKR Wi-Fi 1000 are expensive compared to ESP32 and ESP8266. Now, we have two options: we either go with ESP32 or ESP8266 and leave the Arduino development boards. In this project, we will be using the WeMos D1 Mini, which is part of the ESP8266 series. Although the ESP32 series offers similar features, it is equipped with Bluetooth Low Energy (BLE) connectivity, which is not currently compatible with this project. Thus, we have opted for the ESP8266 series development boards, which are not only compact in size but...

Understanding the project architecture

In the preceding sections, we discussed the sensors and development board in detail. Now, it’s time to cook the recipe. In hardware development, before getting to work with sensors and development boards, we need to develop design concepts to get a better understanding of how things will be connected. There is a lot of software available to design and develop design concepts regarding electronics projects, but we will opt for Fritzing.

In the next subsection, we will talk about the schematics and the design of the project, which explains how to connect the pins to the development board. In the subsection after that, we will talk about the PCB design and its implementation to make a product ready for deployment in the field.

Schematics and design

The purpose of our design is to get a clear understanding of how sensors will connect with the development board. It helps engineers develop a prototype on a breadboard or Veroboard by...

Setting up the Thing, network credentials, cloud variables, and code

After setting up the hardware, it’s time to set up the Thing in the Arduino IoT Cloud. For this project, we need three cloud variables to fetch the monitoring parameters from the device, and the Wi-Fi network settings will be different as compared to Arduino development boards, due to the ESP series-based development board. The following figure provides an overview of the Thing, including Cloud Variables, Associating a device, and Network settings with numbers, which will be discussed next step by step:

Figure 4.7 – The air quality-monitoring system Thing setup

Figure 4.7 – The air quality-monitoring system Thing setup

Set up a new Thing with the name Sense the Environment. Follow the next steps to create variables, the associated device, the network configuration, and finally, the code:

  1. Firstly, we need to set up three cloud variables regarding air quality, humidity, and temperature. The complete details regarding cloud...

Setting up a dashboard for web and mobile

After uploading the code to the device, it’s time to set up a dashboard for web and mobile to visualize the data with different widgets. Complete details about widgets and their usage are available in Chapter 3. If you have directly skipped to this chapter, I recommend going back to Chapter 3 to get a detailed overview of widgets and their usage as this will help you to understand how widgets work and their usage for different use cases. The following figure demonstrates the visualization of readings with different widgets:

Figure 4.10 – The Thing dashboard

Figure 4.10 – The Thing dashboard

We have three different readings, Temperature, Humidity, and Air Quality. For each reading, we use different widget controls to demonstrate how they all work, but for historical data, graphs are the best widgets.

The Temperature reading is visualized by Gauge, the Humidity reading is connected to the Percentage widget, and the Air Quality reading...

What’s next?

We still have a lot of options available to explore, but now it’s your turn to use different sensors and development boards to do some more experiments and learn from them. In this chapter, we have only used two sensors, which only offer three parameters, but there are a lot of sensors on the market that provide a wide variety of functionalities, such as air pressure and measurements for different gases.

Try out the following sensors to enhance your practical knowledge and compare them with other sensors in terms of features, range, and cost:

  • The BMP280 (pressure and temperature) sensor
  • The MH-Z19C/D/E series sensors for carbon dioxide monitoring
  • The MQ series sensors, which are designed to sense different specific gases, including MQ-2, MQ-3, MQ-4, MQ-5, MQ-7, MQ-8, and MQ-9
  • Seeed Studio SCD30 (temperature, humidity, and CO2)
  • Gravity: Analog Electrochemical Carbon Dioxide Sensor (0–10,000 PPM)

Summary

In this chapter, we explored how to develop a low-cost air quality monitoring system using DHT11, MQ-135, and the WeMos D1 Mini development board. We set up the Thing, which involved creating cloud variables, associating the device, configuring the network, and coding the development board. Later, we created a dashboard to visualize the Thing’s sensor readings with different types of widgets, displaying the current readings as well as historical data with the help of graphs. Through this project, you will get the confidence to set up the Thing practically and deploy it in the field using a PCB. You have learned about new types of cloud variables for sensor readings and storage, as well as dealing with different types of dashboard widgets.

In the next chapter, we will study GSM technology for IoT. We will learn about different types of global IoT SIM cards and their usage. This project will also demonstrate a Smart Assets tracing example, where we will track the asset...

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