Use a 4×4 matrix keyboard with ESP32 and Smartphone

ESP32 15-01-25
37 0

Tutorial plan

1- What is a 4x4 matrix keyboard ?

2- How ESP32 board send data from matrix keypad to Smartphone ?

3- Components Needed

4- Wiring the Components

5- Programming ESP32 with Micropython

6- Develop  mobile application using MIT App Inventor

 

 

What is a 4x4 matrix keyboard ?

A 4x4 matrix keyboard (or keypad) is an input device consisting of 16 buttons arranged in a 4-row by 4-column grid. It is commonly used in applications such as calculators, security keypads, and embedded systems for user input.

How It Works

In a 4x4 matrix keypad:

Each button is connected at the intersection of a row and a column.

Rows and columns are connected to the microcontroller through wires or pins.

Pressing a button completes a circuit between a specific row and column, allowing the microcontroller to detect which button was pressed.

 

How ESP32 board send data from matrix keypad to Smartphone ?

To send data from a matrix keypad connected to an ESP32 board to a smartphone using MicroPython and App Inventor, the process involves three main components:

1. Hardware setup: Connecting the 4x4 matrix keypad to the ESP32.

2. Programming the ESP32 in MicroPython: Scanning the keypad and sending data to the smartphone.

3. Building a smartphone app in MIT App Inventor: Receiving and displaying the data sent by the ESP32.

 

Components Needed

ESP32 Board

The ESP32 is the microcontroller that handles all the logic and control of the system. It reads input from the 4x4 matrix keyboard, processes the input, and sends the relevant output to Smartphone via Bluetooth.

4x4 Matrix Keyboard

The 4x4 matrix keyboard acts as the input device. It allows the user to press keys to send commands or data to the ESP32. This is typically used for entering PINs, controlling devices, or interacting with the system.

Jumper Wires

Jumper wires

Jumper wires are used to physically connect the ESP32 board and the 4x4 matrix keyboard. These wires transfer electrical signals between the components, allowing them to communicate.

Breadboard:

Breadboard

A breadboard can be used to create a temporary circuit for testing and prototyping.

 

Wiring the Components

4x4 Matrix Keypad to ESP32:

We connect the 8 outputs of the keypad to the 8 pins of the ESP32 card following this order: D2, D4, D5, D18, D19, D16, D15 and D23.

 

Programming ESP32 with Micropython

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

2- import this three libraries : ble_uart_peripheral.pyble_advertising.py

3- Code to scan the Keypad and send data to Smartphone :

 

Develop  mobile application using MIT App Inventor

1- Go to MIT App Inventor and create a new project.

2- Add components:

BluetoothClient: For communication with the ESP32.

ListPicker: To list available Bluetooth devices.

Label: To display received data.

Buttons: For connection and control.

3- Blocks Design:

- 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:

- Use the blocks to capture data sent by the ESP32 and display the data in the Label component.

Download project Download application

 

Testing the Setup

1- Upload the MicroPython script to the ESP32 using a tool like Thonny.

2- Pair your smartphone with the ESP32 via Bluetooth.

3- Open the app and connect to the ESP32.

4- Press keys on the keypad and see the data displayed on the smartphone app.

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