0% found this document useful (0 votes)
6 views

Notes

The document outlines the setup and functionalities of an ESP32-based system that includes an INMP441 microphone and an SD card module for audio recording. It details methods for assigning unique IDs to devices, time synchronization options, firmware updates, and communication protocols using mDNS for device discovery. Additionally, it provides guidance on organizing code for multiple files in the ESP32 environment, emphasizing ease of network management and device interaction.

Uploaded by

Ankit Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Notes

The document outlines the setup and functionalities of an ESP32-based system that includes an INMP441 microphone and an SD card module for audio recording. It details methods for assigning unique IDs to devices, time synchronization options, firmware updates, and communication protocols using mDNS for device discovery. Additionally, it provides guidance on organizing code for multiple files in the ESP32 environment, emphasizing ease of network management and device interaction.

Uploaded by

Ankit Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Circuit Diagram

Components :

ESP32: Microcontroller with built-in Wi-Fi


INMP441: I2S MEMS microphone for audio recording
SD Card Module: For local storage of recorded audio

- HTTP requests to send commands to the ESP32 (one way communication)

Unique id for each device

Method 1
Assign unique id to each device before hand. Embed this ID in the firmware of each ESP32
during programming.

Method2
Registration Process
Method: When a device first connects to the local network, it can register itself with a central
server that assigns it an ID.
Implementation: Implement a simple registration protocol where each new device sends a
request to a server, and the server responds with a unique ID.
To keep up with time, two ways ;

a. Real-Time Clock (RTC) Module: Integrate an RTC module with your ESP32.
b. Network Time Protocol (NTP): If the ESP32 is connected to the internet, you can query a
network time server to get the current time. This can be done using an NTP client library.

How to push a new code?

Develop your firmware using the Arduino IDE or PlatformIO. Compile the code to produce a
binary file.

1. Open the Arduino IDE.


2. Write your firmware code.
3. Compile the code by clicking the checkmark icon.

Locate the binary file: After compiling, the Arduino IDE generates a .bin file

Upload the firmware binary to a web server.

1. Upload the .bin file to the web server.


2. Obtain the URL where the file is accessible

When the ESP32 downloads the new firmware from the URL, it needs to write the
new firmware to its flash memory and then reboot to run the updated firmware.
This process is handled by the Update class in the Arduino core for ESP32.

Admin interface functionalities

1. classroom/{class_id}/control/reset: Specific command to reset the


device.
2. classroom/{class_id}/control/start: Command to start an operation.
3. classroom/{class_id}/control/stop: Command to stop an operation.

Basic code

Recognition of devices on admin side

Multicast DNS (mDNS) protocol

1. ESP32 Devices Setup with mDNS:


○ Initialization: Each ESP32 device is configured to connect to a Wi-Fi
network.
○ mDNS Service Registration: Each ESP32 device runs an mDNS
responder that broadcasts its presence on the network. This includes its
hostname (e.g., esp32-xyz) and the services it offers (e.g., HTTP on port
80).
○ Continuous Broadcasting: The mDNS service on each ESP32 continually
announces its availability on the local network.
2. Client Application Using mDNS:
○ Service Discovery: The client application (e.g., a Python script) uses
mDNS to listen for the broadcasted services from the ESP32 devices. This
is typically done using a service browser that looks for specific service
types (e.g., _http._tcp.local.).
○ Retrieving Service Information: When the client detects an ESP32 device,
it retrieves information such as the IP address and port number where the
device can be accessed.
○ Establishing Connection: Using the retrieved IP address and port, the
client can then establish a connection to the ESP32 device, such as
sending HTTP requests to interact with the device’s functionality.

Step-by-Step Communication Flow

1. ESP32 Device Start:


○ Connects to the Wi-Fi network.
○ Initializes mDNS and starts broadcasting its service details.
2. Client Device Start:
○ Connects to the same Wi-Fi network as the ESP32 devices.
○ Uses mDNS to search for services of interest (e.g., HTTP services).
3. Discovery Phase:
○ The client device receives broadcast messages from the ESP32 devices,
identifying them by their service type and hostnames.
○ The client device collects the IP addresses and ports of the ESP32
devices.
4. Interaction Phase:
○ The client device uses the collected IP addresses and ports to send
requests to the ESP32 devices.
○ The ESP32 devices respond to the client requests, enabling functionality
such as data collection, control commands, or status monitoring.

Benefits of Using mDNS


● Zero Configuration: Devices can be added to the network without manual
configuration of IP addresses.
● Dynamic Discovery: New devices are automatically discovered as they join the
network.
● Simplified Network Setup: Reduces the complexity of network management,
particularly in environments with many devices.

How to run multiples files stored in ESP32?

1. Organize Code into Modules


2. Create Header Files (for ex, for .cpp file, create a corresponding .h (header) file)
3. Include Headers in Main File. This allows the main file to call the functions
defined in the other files.
4. Setup and Loop Functions: In the main file, use the setup() function to initialize
components and the loop() function to run the main program. Call the functions
from the other files within these functions.
5. Compile and Upload: When we compile and upload the code, the Arduino IDE
will automatically compile all the files together, allowing the program to run as a
cohesive unit on the ESP32. (The order in which the other modules are called in
the main will decide the flow/order in which they will start working)

You might also like