Reader small image

You're reading from  Hands-on ESP32 with Arduino IDE

Product typeBook
Published inJan 2024
PublisherPackt
ISBN-139781837638031
Edition1st Edition
Right arrow
Author (1)
Asim Zulfiqar
Asim Zulfiqar
author image
Asim Zulfiqar

Asim Zulfiqar is a blogger and tech content creator who has been writing tutorials on embedded systems and IoT on his blog and YouTube channel, High Voltages. Currently, he is working as a scientific programmer for IoT research projects. He completed his bachelor's degree in electronic engineering at Sir Syed University of Engineering and Technology, Pakistan. After that, he completed his Erasmus Mundus joint master's degree program in Photonics Integrated Circuits, Sensors, and Networks at Scuola Superiore Sant'Anna (Italy), Aston University (U.K), and Osaka University (Japan).
Read more about Asim Zulfiqar

Right arrow

Implementing Network-Based Protocols with ESP32

In this chapter, we will climb the first stairs toward internet of things (IoT) development and explore network-based protocols with the versatile ESP32 microcontroller. Throughout this journey, we will uncover the power of wireless communication and its potential to transform your IoT projects into dynamic connected systems.

Our exploration begins by diving into the ESP32’s built-in Wi-Fi capabilities. We’ll learn how to harness the potential of Wi-Fi by configuring the ESP32 as both a client and an access point. This will enable us to connect to existing networks and create personalized local networks for our IoT devices. But our exploration doesn’t stop there; we will also venture into more advanced features, such as Wi-Fi Direct and peer-to-peer communication, to make our devices communicate seamlessly.

Next, we’ll delve into Bluetooth Low Energy (BLE), a crucial technology for short-range communication...

Technical requirements

For this chapter, we will need the following components:

  • ESP32 x 2
  • A smartphone
  • A BG95 shield
  • A LoRaWAN module

The code files for this chapter are available at https://github.com/PacktPublishing/Programming-ESP32-with-Arduino-IDE/tree/main/Chapter4.

First, let’s explore the types of networks.

Types of networks

Networks can be categorized into various types based on their geographical coverage and communication characteristics. Local area networks (LANs) cover a small area, such as homes or offices, enabling devices within the network to communicate directly. Wide area networks (WANs) span across large geographical areas and connect distant locations, such as the via the internet. Personal area networks (PANs) are small, localized networks that typically span a person’s immediate surroundings. Metropolitan area networks (MANs) cover larger cities or metropolitan regions, and campus area networks (CANs) link multiple LANs within educational institutions or large organizations. Storage area networks (SANs) are specialized networks for data storage and retrieval.

In our book, we will be focusing on three main types of networks:

  • LAN: LANs are crucial for connecting devices within a limited geographic area, such as homes, offices, or schools. They allow for...

Exploring wireless capabilities with Wi-Fi

Wi-Fi, short for wireless fidelity, is a wireless communication technology that allows devices to connect to the internet and local networks without using physical cables. It operates on radio frequency signals, typically in 2.4 GHz and 5 GHz bands, and enables data transmission between devices such as smartphones, laptops, and IoT devices. Wi-Fi provides high-speed and reliable internet access, facilitating seamless connectivity and enabling users to access online resources, stream media, and communicate with other devices within the network range. In this section, we will explore how Wi-Fi protocols work, the capabilities of ESP32 Wi-Fi, and a few practical examples of using ESP32 as an access point and client. But first, let’s see how the Wi-Fi protocol works.

How the Wi-Fi protocol works

TheWi-Fi protocol, based on IEEE 802.11 standards, works by enabling devices to communicate wirelessly over radio frequencies. When a Wi...

Creating a personal area network with BLE

BLE stands for Bluetooth Low Energy, which is a wireless communication technology designed for low-power, short-range data exchange between devices. It is a subset of the classic Bluetooth technology, optimized for battery-powered devices and applications that require intermittent data transmission. BLE enables devices such as smartphones, smartwatches, and IoT sensors to establish connections and exchange data efficiently, making it ideal for applications such as fitness tracking, home automation, and proximity-based interactions. Its low energy consumption allows devices to operate for extended periods on small batteries, making BLE a popular choice for various wireless applications.

To get started with BLE, let’s see how the BLE protocol works on a fundamental basis.

How the BLE protocol works

This initial explanation gives you a general understanding of the concepts and mechanisms behind BLE. The actual implementation and...

Expanding ESP32 connectivity beyond Wi-Fi and BLE

We have already explored ESP32 Wi-Fi and BLE capabilities. While the built-in Wi-Fi and BLE capabilities of the ESP32 offer robust connectivity options, there are scenarios where these technologies alone may not suffice:

  • Remote and disconnected areas: In remote or rural areas with limited Wi-Fi infrastructure, establishing a reliable internet connection can be challenging. Here, cellular communication comes to the rescue.
  • Long-range communication: While Wi-Fi and BLE are suitable for short-range communication, they may not be ideal for applications requiring long-range connectivity.
  • Contactless and close proximity interaction: In scenarios where physical contact or proximity is not feasible, NFC presents an excellent option.

In each of these scenarios, the ESP32, when combined with additional communication modules, can overcome the limitations of Wi-Fi and BLE and enable connectivity in diverse and challenging...

Summary

In this chapter, we delved into various connectivity options that allow us to establish connections between the ESP32 and diverse networks. We delved deep into the Wi-Fi and BLE protocols, performing hands-on exercises to grasp their practical applications.

However, there are scenarios where these options might not suffice or are unavailable. To address such situations, we expanded our knowledge to encompass cellular communication and the LoRaWAN protocol. These additional protocols empower us to broaden the ESP32’s connectivity by leveraging external modules.

In the forthcoming chapter, we’ll take a closer look at data-based protocols. This exploration will shed light on how we can effectively exchange data across different devices using these network protocols.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Hands-on ESP32 with Arduino IDE
Published in: Jan 2024Publisher: PacktISBN-13: 9781837638031
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
Asim Zulfiqar

Asim Zulfiqar is a blogger and tech content creator who has been writing tutorials on embedded systems and IoT on his blog and YouTube channel, High Voltages. Currently, he is working as a scientific programmer for IoT research projects. He completed his bachelor's degree in electronic engineering at Sir Syed University of Engineering and Technology, Pakistan. After that, he completed his Erasmus Mundus joint master's degree program in Photonics Integrated Circuits, Sensors, and Networks at Scuola Superiore Sant'Anna (Italy), Aston University (U.K), and Osaka University (Japan).
Read more about Asim Zulfiqar