Device Engineering

Accelerating your product design & development

Embedded Software

Exploring ESP32 BLE Connectivity

September 2, 2024

In the world of Internet of Things (IoT), Bluetooth Low Energy (BLE) has become an essential communication protocol for connecting devices. One of the most popular platforms for IoT development is ESP32, known for its powerful features and versatility. In this blog post, we will delve into the world of ESP32 BLE connectivity and explore how to establish a seamless connection between ESP32 devices and other BLE-enabled devices. 

Understanding ESP32 BLE 

Before we dive into the technical aspects, let's have a brief overview of ESP32 BLE. The ESP32 microcontroller is equipped with a built-in BLE module, making it an ideal choice for developing BLE-enabled IoT devices. It supports both the central and peripheral roles, allowing it to connect to other BLE devices or act as a peripheral device for connections. 

Setting up the ESP32 Environment 

To get started with ESP32 BLE connectivity, you need to set up your development environment. Install the required software, such as the Arduino IDE or ESP-IDF, and configure it to work with ESP32. Make sure you have the necessary libraries and board definitions installed for BLE development. 

Creating a BLE Peripheral Device 

To establish a BLE connection, you can configure the ESP32 as a peripheral device. This allows other central devices (like smartphones, laptops, or other ESP32 boards) to discover and connect to it. Explore the various BLE services and characteristics you can define on the ESP32 and learn how to advertise and manage connections with central devices. 

Implementing a BLE Central Device 

ESP32 can function as a central device in Bluetooth Low Energy (BLE) communications. This role allows it to scan for, connect to, and interact with other BLE peripheral devices. Here's how to implement key features: 

1. Scanning for BLE Devices:  

  • Use the BLEDevice::getScan() method to initialize scanning. 
  • Set scan parameters like duration and active/passive mode. 
  • Implement a callback function to handle discovered devices. 

2. Filtering Discovered Devices:  

  • Apply filters based on device name, MAC address, or advertised services. 
  • Use BLEAdvertisedDevice class to access device information. 

3. Establishing Connections:  

  • Create a BLEClient object for the target device. 
  • Use connectToServer() method to initiate the connection. 
  • Implement error handling for connection failures. 

4. Handling Disconnections:  

  • Implement a callback function for disconnection events. 
  • Attempt automatic reconnection if desired. 
  • Clean up resources associated with disconnected devices. 

5. Interacting with Connected Devices:  

  • Discover services and characteristics of connected peripherals. 
  • Read from and write to characteristics as needed. 
  • Set up notifications for real-time data updates. 

By mastering these techniques, you can create sophisticated ESP32-based central devices capable of interacting with multiple BLE peripherals in complex IoT ecosystems. 

Data Exchange and Communication 

Once the BLE connection is established, it's crucial to exchange data between the ESP32 and other devices. Dive into the specifics of how to send and receive data over BLE using characteristic notifications, indications, and read/write operations. Understand the limitations and considerations when transmitting data and optimize the communication process for efficiency. 

Security and Authentication 

Ensure your BLE connections are secure, especially when dealing with sensitive data. Explore the available security features on ESP32 BLE, such as encryption, authentication, and key exchange protocols. Understand how to implement secure connections and protect your data from unauthorized access. 

Advanced BLE Features and Use Cases 

ESP32 BLE offers a wide range of advanced features that can enhance your IoT projects. Delve into topics such as Bluetooth Mesh networking, using GATT profiles for custom services, OTA (Over-The-Air) updates, and sensor data integration. Explore real-world use cases where ESP32 BLE connectivity is beneficial, such as smart home automation, healthcare monitoring, and industrial IoT applications. 

Conclusion 

ESP32 BLE connectivity opens endless possibilities for building powerful IoT devices that can seamlessly communicate with other BLE-enabled devices. With a solid understanding of the ESP32 BLE framework and its capabilities, you can unleash your creativity and develop innovative solutions. Stay curious, experiment, and explore the vast world of ESP32 BLE to take your IoT projects to the next level. 

Sleep Mode on MCU

August 19, 2024

There are typically several sleep modes available in microcontrollers to optimize power consumption. The exact sleep modes available depend on the specific microcontroller and manufacturer.  

Below mentioned parameter which affects the average power consumption of the microcontroller device which should be as low as possible to reduce the consumption. 

  1. Operating frequency  
  2. Active Peripheral  
  3. Peripheral mode wrt frequency  
  4. Average active time 
  5. Radio power configuration 

However here we understand some common sleep mode with example of ESP32 microcontrollers: 

Sleep Modes in ESP32 

Power efficiency is an important factor in the success of any embedded project, especially when it comes to microcontrollers. The ESP32 microcontroller is a most popular choice regarding low cost and powerful capabilities that offers a wide range of functionalities for IoT projects. Power efficiency is one of the best areas of this. By leveraging the sleep modes provided by the ESP32, developers can significantly reduce power consumption and extend the battery life of their projects.  

Before discussing the power mode, we talked about configuration for power saving for the project. 

Power Management Unit (PMU) on ESP32 can manage power wrt to switch between different power modes. Five types of power modes designed for typical scenarios: Wake-up, Modem /Radio-sleep mode, light sleep mode, Deep-sleep mode, Hibernation mode. 

Exploring the Power modes in ESP32 

–Wake-up or Active mode: The chip radio (Wi-Fi, BLE) is powered up. The chip can receive, transmit, or listen.  

–Modem/ Radio -sleep mode: The CPU is operational, high frequency clock and other peripheral clock is configurable. The RF peripherals e.g. Wi-Fi and Bluetooth are disabled.  

– Light-sleep mode: The CPU is paused. The RTC memory and RTC peripherals, as well as the ULP coprocessor are running. Any wake-up events (internal or external) will wake up the chip.  

– Deep-sleep mode: Only the RTC memory and RTC peripherals are wake-up. RF modules like Wi-Fi and BLE connection data are stored in the RTC memory. The ULP (Ultra Low Powered) coprocessor is functional.  

– Hibernation mode: The internal 8 MHz oscillator and ULP coprocessor are disabled. The RTC recovery memory is powered down. Only one RTC timer (Sleep timer) with slow clock and certain real time clock (RTC) general purpose IO (GPIO) are active. That will help to wake up the chip from the Hibernation mode. 

As shown on table, behavior of different functionality as per sleep mode to save the power. 

SN  Functionality  Active Mode  Modem sleep mode  Light sleep Mode  Deep sleep Mode  Hibernation mode 
1  Peripheral (GPIO, UART, I2C, SPI etc)  Active  Active  Sleep  Sleep  Sleep 
2  BLE  Active  Disabled  Sleep  Sleep  Sleep 
3  Wi-Fi  Active  Disabled  Sleep  Sleep  Sleep 
4  Radio  Active  Disabled  Sleep  Sleep  Sleep 
5  Core  Active  Active  Active  Sleep  Sleep 
6  ULP Co-processor  Active  Active  Active  Partial sleep  Sleep 
7  RTC  Active  Active  Active  Active  Active 

 

Below table shows the power consumption wrt different power modes.   

 

 

 ESP32 API to configure mode and wakeup example: 

Example of light sleep mode: 

/*configure timer to generate interrupt after 1 seconds for wakeup*/ 

esp_sleep_enable_timer_wakeup(1000000); 

 

/*start light sleep */ 

esp_light_sleep_start(); 

/*wakeup after timer expired */ 

 

Example of deep sleep mode. 

/*configure timer to generate interrupt after 2 seconds for wakeup*/ 

esp_sleep_enable_timer_wakeup(2000000);  

 

/*start deep sleep */ 

esp_deep_sleep_start(); 

/*wakeup after timer expired */ 

 

Example of Hibernation mode: 

/* disable RTC memory */ 

  esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_OFF); 

  esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_SLOW_MEM, ESP_PD_OPTION_OFF); 

  esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_FAST_MEM, ESP_PD_OPTION_OFF); 

 

/*configure timer to generate interrupt after 5 seconds for wakeup*/

  esp_sleep_enable_timer_wakeup(5 * 1000000);   

 

/*start deep sleep */ 

  esp_deep_sleep_start(); 

/*wakeup after timer expired */ 

Conclusion: 

The ESP32 sleep mode is a powerful feature that allows the microcontroller to conserve energy and extend battery life at low power consumption. By placing the ESP32 in sleep mode, redundant features and functions can be prevented or reduced, significantly reducing power consumption. Sleep mode can be triggered by programming or external events, and the ESP32 can quickly wake up from sleep to resume normal operation. This useful feature of ESP32 makes it ideal MCU for low powered IoT devices. Overall, the sleep mode of the ESP32 maximizes its power reserve and makes it a versatile platform. 

Reference: 

https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf 

Implementing Firmware Update Request in Charging Station Management Systems (CSMS) Using OCPP 1.6

August 5, 2024

As more people start using electric cars (EVs) and more places have charging stations for these cars, it’s important to keep the software in these charging stations updated. This software, called firmware, is like the brains of the charging station. Updating it regularly helps the charging station work better, be more reliable, and stay compatible with new technologies. In this article, we’ll explore the process of implementing firmware update requests in Charge Station Management Systems (CSMS) using OCPP 1.6, a standard protocol for managing electric vehicle (EV) charging infrastructure.

An Overview of UVC and UAC class and USB Video Conferencing Device with Aikri-QCS610 Platform

May 6, 2024

Universal Serial Bus popularly known as USB is a Plug and Play interface used for computers to communicate with diverse types of USB peripherals. Keyboards, Mouses, Joysticks, Speakers, Webcams, External Drives are common USB devices. The underlying mechanisms for each of these devices are different. Some of them are mass storage devices, video devices, audio devices while others are human interface devices. UVC stands for USB Video Class and can transmit video over USB, similarly UAC stands for USB Audio Class and can transmit audio over USB. When user plugs a UVC/UAC device to the host, configuration, and enumeration of UVC/UAC device at host will be completed and its capabilities advertised to the host. USB Camera and USB Headset is an example of UVC and UAC Device, respectively.

Cache coherency- Risks and Resolution in case of Direct Memory Access (DMA)

February 12, 2024

Cache coherence maintains consistency between cached data copies when multiple devices access shared memory. This blog explores the need for cache coherency, coherence protocols like snooping, and fixing incoherence issues in multicore systems like ensuring descriptor writebacks for proper DMA transfers with EMAC.

Digitizing Supply Chains: How Mobile Solutions Drive Efficiency and Revenue

March 20, 2023

The logistics and supply chain industries are increasingly using digital mobility solutions to streamline operations, gain real-time data insights, and reduce environmental impact. By optimizing inventory management systems, businesses can achieve faster delivery times, reach customers more efficiently, reduce lead times, minimize errors, and better manage inventory.

Start a conversation today

Schedule a 30-minute consultation with our experts

Please Fill Below Details and Get Sample Report

Reference Designs

Our Work

Innovate

Transform.

Scale

Partnerships

Device Partnerships
Digital Partnerships
Quality Partnerships
Silicon Partnerships

Company

Products & IPs