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 #3 – a Remote Asset Tracking Application with LoRaWAN

This chapter is dedicated to smart transportation and smart remote monitoring using low-power and long-range communication technology. The project in this chapter will take you through the implementation and deployment of a remote alarming application based on Long Range Wide Area Network (LoRaWAN), connected to the public, global, and decentralized The Things Network. The project in this chapter provides localization features by using a GPS module. The Arduino IoT Cloud will be used for data visualization and remote configuration of the device. The application will be used in real use cases, showing the benefits offered by LoRaWAN technologies compared to other wireless technologies.

Here, we will practically explore LoRaWAN technologies, which are very useful in remote monitoring and control, whether it’s asset tracking or remote operation monitoring. This project uses the Arduino MKR WAN 1300 development...

Technical requirements

The following hardware components are required to complete the exercise in this chapter:

  • MKR WAN 1300 or MKR WAN 1310
  • The Things Indoor Gateway
  • The NEO-6M u-blox GPS module
  • A breadboard
  • Jumper cables

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

In this chapter, we will use the The Things Indoor Gateway for LoRaWAN communication. The code used in the chapter is available in the book’s official GitHub repository by following this link: https://github.com/PacktPublishing/Arduino-IoT-Cloud-for-Developers.

Understanding LoRaWAN and its IoT applications

LoRaWAN is a wireless communication protocol and network architecture specifically designed for Low-Power Wide Area Networks (LPWANs), enabling long-range communication between devices in the context of the IoT. LoRaWAN technology is optimized for applications that require low data rates, long battery life, and long communication ranges, making it well-suited for various IoT use cases.

Usage in IoT

LoRaWAN has been widely adopted in various IoT applications due to its unique features. Some common use cases include the following:

  • Smart agriculture: LoRaWAN can be used for soil moisture monitoring, crop health monitoring, livestock tracking, and precision farming, allowing farmers to optimize their operations and increase yield
  • Smart cities: LoRaWAN can enable smart street lighting, waste management, parking management, and environmental monitoring, helping cities become more efficient and sustainable
  • Industrial monitoring...

LoRaWAN versus other communication technologies

LoRaWAN offers several advantages over other communication technologies, making it a preferred choice for certain IoT applications. Here are some reasons why LoRaWAN might be chosen over other alternatives:

  • Long range: LoRaWAN provides exceptional long-range communication capabilities, enabling devices to communicate over several kilometers in open areas. This is particularly useful for applications that require connectivity over large distances, such as agriculture, environmental monitoring, and asset tracking.
  • Low power consumption: Devices using LoRaWAN can operate on very low power, extending battery life for years. This is crucial for remote or hard-to-reach locations where changing or recharging batteries is impractical or costly.
  • Deep indoor penetration: LoRaWAN can penetrate buildings and other obstacles effectively, ensuring connectivity even in challenging environments. This makes it suitable for applications...

Components of a LoRaWAN IoT application

LoRaWAN is a wireless communication protocol and network architecture designed to enable long-range, low-power communication between IoT devices. It’s specifically tailored to connect devices that require extended battery life, reliable long-distance communication, and efficient use of the wireless spectrum. LoRaWAN is one of the key technologies in the realm of LPWANs. Figure 6.1 illustrates the whole architecture of the LoRaWAN solution, including the end nodes, gateway, network server, and application server.

Figure 6.1 – The components of a LoRaWAN network

Figure 6.1 – The components of a LoRaWAN network

The LoRaWAN architecture consists of four main components:

  • End nodes/devices: These are the IoT devices that gather data from sensors or perform specific tasks. They communicate with gateways using the LoRa modulation technique, sending data packets at low data rates.
  • Gateways: Gateways serve as intermediate points that receive data...

Essential hardware – sensors and development boards

The Arduino series has a wide collection of development boards that vary in size, pins, and communication technologies. In this chapter, we will use the Arduino MKR WAN 1300 development board, as it’s compact, battery-enabled, and provides support for different frequencies from different regions around the world, including 433/868/915 MHz. Figure 6.2 shows a pinout diagram of the MKR WAN 1300.

Figure 6.2 – Arduino MKR WAN 1300

Figure 6.2 – Arduino MKR WAN 1300

The Arduino MKR WAN 1300 provides seven analog pins, which start with A (A0, A1, and so on), and eight digital input/output pins, which start with D (D0, D1, and so on), with built-in battery charging and a lithium polymer (LiPo) battery connector for standby power, which helps developers build prototypes and solutions for remote monitoring/operations without worrying about power backups. For further updates and the latest product development news, please visit...

Designing the project architecture

In the preceding sections, we discussed the module 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 the design concepts to get a better understanding of how things will connect. There is a lot of software that is available to design and develop design concepts for an electronics project, but in this case, we will use Fritzing.

In the following two subsections, we will talk about schematics and designing a project, while explaining how to connect pins with a development board and soldering. Then, we will do some tests to fetch GPS coordinates, which is very important before sending data to the Arduino IoT Cloud.

Schematics design and assembly

The purpose of your schematic design is to get a clear understanding of how sensors will connect with a development board. This helps engineers develop a prototype on a breadboard...

Setting up the Thing, device association, 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 four cloud variables to fetch different properties from the device. The device association settings will be different due to the LoRa series board. Also, network configuration will happen automatically when we upload the code/sketch to the MKR WAN 1300. Figure 6.8 shows a complete overview of the Thing:

Figure 6.8 – Remote asset tracking using the LoRaWAN Thing setup

Figure 6.8 – Remote asset tracking using the LoRaWAN Thing setup

Set up a new Thing with the name A remote asset tracking using LoRaWAN, and then follow the next steps, which will take you to the next subsections to create variables, an associate device network configuration, and finally, code. We have marked the preceding figure with red boxes and numbers according to the following steps.

Firstly, we need to set up four cloud variables – Location, AltitudeFeet...

Configuring the The Things Indoor Gateway

In this section, we will set up the The Things Indoor Gateway. It is available in different frequencies but I have a gateway with the EU868 MHz frequency. If you already have the LoRaWAN gateway in your area and want to skip this section, you’re good to go, but if you don’t have the gateway in your area, then this section is mandatory for MKR WAN 1300 communication. Without the gateway, your module will not communicate with the Arduino IoT Cloud. To set up the gateway, please follow these steps:

  1. Open your gateway box, set it up with a power cable, and turn on the gateway. If you are using a brand-new gateway, then it will be in setup mode; otherwise, you can put the gateway into setup mode by pressing the SETUP button for a few seconds when the orange and green lights start blinking. This means the gateway has entered setup mode.
  2. Select the Wi-Fi network of your the The Things Indoor Gateway, and connect to it. The...

Creating web and mobile dashboards

After uploading the code to the device, it’s time to set up a dashboard for web and mobile to visualize data with different widgets. Figure 6.24 demonstrates the visualization of readings with different widgets.

Figure 6.24 – The Thing dashboard

Figure 6.24 – The Thing dashboard

We have four readings from the GPS module to visualize. Here, I have used four widgets: one gauge, two values, and one map. The gauge widget shows Speed Per Mile, while the two value widgets have been used to display Altitude Feet and Satellite Count. The map widget was used to display Location based on the latitude and longitude coordinates, which are stored in a cloud-based location variable. Currently, the map widget is only capable of displaying the location of the asset device based on coordinates; if you have multiple assets to track, then you need to set up multiple map widgets according to the number of tracking devices.

Well, this is the last section...

What 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 only used one GPS module, which gave us only four parameters, but there are a lot of GPS modules on the market that provide a wide variety of functionalities, such as working under a roof and accuracy features.

While monitoring the location of assets, some other parameters are very important to monitor in different industries, such as temperature and humidity, which are very important in food and medical products. CO2 and liquefied petroleum gas (LPG) gases are very important to monitor during fuel transportation. Try using different sensors with a GPS module to set up different tracking prototypes for different industries.

Summary

In this chapter, we explored how to develop an asset-tracking system using LoRaWAN and a GPS module. We set up the Thing, which included cloud variable creation, device association, the The Things Indoor Gateway, and coding a development board. Then, we created a dashboard to visualize the Thing readings with different types of widgets to display current readings. The most important widget of the chapter is the map widget, which is very interesting and important for plotting the current location of the device.

GPS tracking is a very important topic that helps us to develop a device for our assets, assisting us in asset tracking and monitoring. We can use LoRaWAN for a specific region, as it has a longer range, but that range only operates in a specific area, unlike other wireless technologies. This chapter demonstrated how we can display the location of a device on a dashboard, giving you more confidence to build more asset-tracking solutions.

In the next chapter, Enabling...

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