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 display a message on an I2C LCD screen connected to an ESP32, which receives the message via Bluetooth from an App Inventor app
1. Hardware Setup:
Make sure your ESP32 board has Bluetooth capability (most ESP32 boards do). Connect the ESP32 to your computer or power source.
Connect the ESP32 to the LCD I2C 1602 display. This generally involves connecting the SDA (data) and SCL (clock) pins of the LCD to the corresponding I2C pins on the ESP32.
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 library in MicroPython to work with Bluetooth.
Utilize a library that manages the communication between the ESP32 and the LCD.
4. Write MicroPython Code:
Write a MicroPython script to configure Bluetooth, handle incoming messages and display it on the I2C screen.
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.
6. Pair Devices: Pair your smartphone with the ESP32 through the Bluetooth settings on your smartphone.
7. 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.
To use a LCD I2C 1602 display with the ESP32 board, you'll need the following components:
ESP32 Board:
The ESP32 is a powerful microcontroller developed by Espressif Systems. It's renowned for its integrated Wi-Fi and Bluetooth capabilities, making it a popular choice for various IoT (Internet of Things) applications.
LCD I2C 1602 Display:
The LCD I2C 1602 display is a type of liquid crystal display (LCD) that utilizes the I2C (Inter-Integrated Circuit) communication protocol to interface with microcontrollers or other devices.
Jumper Wires:
To make the physical connections between the components.
Breadboard:
A breadboard is a useful tool for creating temporary electronic circuits. It allows you to connect components without soldering .
Connect the LCD I2C 1602 Display to your ESP32 as follows:
1- Connect the SDA (data line) of the LCD I2C 1602 display to GPIO 21 of the ESP32 board.
2- Connect the SCL (clock line) of the LCD I2C 1602 display to GPIO 22 of the ESP32 board.
3- Connect the VCC pin of the LCD I2C 1602 display to the 5V pin of the ESP32 board.
4- Connect the GND pin of the LCD I2C 1602 display to GND pin of the ESP32 board.
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
3- Use the i2c_lcd and lcd_api Libraries for I2C LCD screen
Here's an example of MicroPython code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
########## DIGITAL MANUFACTURING ########## # PIKACHU Project # Authors: Miguel Angel Guzman # Kadriye Nur Bakirci ########################################### ########## IMPORT REQUIRED LIBRARIES ########## import bluetooth from ble_uart_peripheral import BLEUART import machine from machine import Pin, SoftI2C from lcd_api import LcdApi from i2c_lcd import I2cLcd I2C_ADDR = 0x27 totalRows = 2 totalColumns = 16 #initializing the I2C method for ESP32 i2c = SoftI2C(scl=Pin(22), sda=Pin(21), freq=10000) lcd = I2cLcd(i2c, I2C_ADDR, totalRows, totalColumns) # Create BLE object ble = bluetooth.BLE() # Open UART session for BLE uart = BLEUART(ble) # Define ISR for an UART input on BLE connection def on_rx(): # Read UART string, AppInventor sends raw bytes # read the message received from the Smartphone via Bluetooth uart_in = uart.read() message=uart_in.decode() lcd.clear() # display the message received from the Smartphone in the LCD screen lcd.putstr(message[:-1]) # Map ISR to UART read interrupt uart.irq(handler=on_rx) uart.close() |
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 mobile application.
4- Verify that the message is sent to the ESP32 board and displayed in the LCD screen.
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.
Zaouiet Kontech-Jemmel-Monastir-Tunisia
+216 92 886 231
medaliprof@gmail.com
Robotic site created by MedAli-Teacher info