Transmit a message to the ESP32 board via Bluetooth

Bluetooth 03-03-24
113 0

Tutorial plan

1- How to transmit a message from the Smartphone to the ESP32 board via Bluetooth ?

2- Program the ESP32 card to receive a message from the Smartphone

3- Develop a mobile application to send a message to the ESP32 board

 

 

How to transmit a message from the Smartphone to the ESP32 board via Bluetooth ?

The ESP32 board is a versatile microcontroller with built-in Wi-Fi and Bluetooth capabilities, while Bluetooth is a wireless communication standard that facilitates short-range communication between electronic devices.

To transmit a message from a smartphone to an ESP32 board via Bluetooth using MicroPython and App Inventor, you’ll need to follow a few steps. Here’s a basic guide to get you started:

1. Hardware Setup: Make sure your ESP32 board has Bluetooth capability (most ESP32 boards do). Connect the ESP32 to your computer or power source.

2. Install MicroPython on the ESP32: Flash the MicroPython firmware onto your ESP32. You can use tools like esptool or a graphical tool like Thonny for this. Follow the instructions provided by the MicroPython documentation for your specific ESP32 board.

3. Install necessary libraries: You’ll need the bluetooth module in MicroPython to work with Bluetooth. Ensure it is available on your MicroPython firmware.

4. Write MicroPython Code: Write a MicroPython script to configure Bluetooth and handle incoming messages.

5. App Inventor Setup: Create a simple App Inventor app to send messages to the ESP32 via Bluetooth. Use the BluetoothClient component to connect to the ESP32 device and send messages.

7. Pair Devices: Pair your smartphone with the ESP32 through the Bluetooth settings on your smartphone.

8. Test: Deploy your MicroPython script to the ESP32 and install your App Inventor app on your smartphone. Test the communication by pressing the button on the app and observing the ESP32’s response.

Program the ESP32 card to receive a message from the Smartphone

1- Flash your ESP32 with MicroPython using this file esp32-20210902-v1.17.bin.

2- import this two libraries : ble_uart_peripheral.py and ble_advertising.py

Here’s an example of MicroPython code to receive a message from the Smartphone via Bluetooth:

This Micropython program allows the ESP32 card to :

– connect to Smartphone

– receive the message from the Smartphone

– display the message in the Thonny console or another programming tool

Develop a mobile application to send a message to the ESP32 board

1- Create the designer of mobile app with App Inventor.

– Use the available Bluetooth components to establish a connection with the ESP32.

– Add text fields to write a message.

– Add button to sen the message to ESP32 board

Here is the Designer part of the application with App Inventor :

2. Programming the application with App Inventor:

a- Use the available blocks in App Inventor to establish a Bluetooth connection with the ESP32.

– Starting with Android 12, Bluetooth permissions have been enhanced to improve security and user data protection. This is why we must declare the authorizations that your application needs in the AndroidManifest.xml file. For Bluetooth, you’ll need to include ACCESS_FINE_LOCATION, BLUETOOTH_SCAN, and possibly BLUETOOTH_CONNECT permissions, depending on the features you’re using.

– Use these programming blocks to connect the smartphone to the ESP32 board via Bluetooth:

b- Use these programming blocks to send message from Smartphone to ESP32 board via Bluetooth

Download project Download application

 

Testing :

1- Upload the MicroPython code to your ESP32.

2- Install and launch the app created with App Inventor on your smartphone.

3- Connect to the ESP32 from the app.

4- Check that the message is sent to the ESP32 card

0 comment

Leave a comment

Veuillez noter s'il vous plaît*

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Purpose of this website

Educational robotics refers to the use of robots and robotics technology to promote learning in educational settings. It involves the integration of technology, engineering, and computer science into the classroom, allowing students to engage in hands-on, project-based learning experiences.
In this context, our website represents an excellent resource for parents, teachers and children who wish to discover robotics.

Contact details

Zaouiet Kontech-Jemmel-Monastir-Tunisia

+216 92 886 231

medaliprof@gmail.com

Pictures of the articles

Robotic site created by MedAli-Teacher info