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 SSD1306 display 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 SSD1306 display. This generally involves connecting the SDA (data) and SCL (clock) pins of the LCD to the corresponding 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 SSD1306 display.
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 SSD1306 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.
SSD1306 display:
The SSD1306 display is a type of OLED (Organic Light-Emitting Diode) display that uses the SSD1306 driver chip.
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 SSD1306 Display to your ESP32 as follows:
1- Connect the SDA (data line) of the SSD1306 display to GPIO 21 of the ESP32 board.
2- Connect the SCL (clock line) of the SSD1306 display to GPIO 22 of the ESP32 board.
3- Connect the VCC pin of the SSD1306 display to the 3.3V pin of the ESP32 board.
4- Connect the GND pin of the SSD1306 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 ssd1306.py Library for SSD1306 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 40 |
########## 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, I2C import ssd1306 # ESP32 Pin assignment i2c = I2C(-1, scl=Pin(22), sda=Pin(21)) oled_width = 128 oled_height = 64 oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c) # 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 # Receive the message from the smartphone uart_in = uart.read() message=uart_in.decode() # clear the SSD1306 display oled.fill(0) oled.show() # Display the message in the SSD1306 display oled.text('Message received', 0, 0) oled.text(message[:-1], 0, 20) oled.show() # 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 SSD1306 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