Transmit message from Micro:bit to Smartphone

Bluetooth 14-11-24
163 0

Tutorial plan

1- How to transmit a message from Micro:bit to Smartphone via Bluetooth ?

2- Program the Micro:bit to send message to Smartphone

3- Develop a mobile application to receive a message from Micro:bit board

 

 

How to transmit a message from Micro:bit to Smartphone via Bluetooth ?

To transmit a message from a BBC Micro:bit to a smartphone via Bluetooth using MIT App Inventor, you need to program both the Micro:bit
and the App Inventor app to communicate over Bluetooth. Here’s a step-by-step guide to set up this connection:

1- Set Up the Micro:bit with Bluetooth Code

You’ll need to use the Micro:bit editor (MakeCode or MicroPython) to write code that sends a Bluetooth message.

2- Step 2: Build the App in MIT App Inventor

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

b- Design the user interface

c- Set up the blocks for Bluetooth connection and message receiving

3- Test the App:

1- Connect your smartphone to MIT App Inventor using the companion app.

2- Start the app, select the Micro:bit from the ListPicker, and press Connect.

3- Press button A on the Micro:bit to send the message, which should then display in the app’s label.

 

Program the Micro:bit to send message to Smartphone

o program the Micro:bit to send a message to Smartphone via Bluetooth using MakeCode, follow these steps:

1-Go to the MakeCode website (makecode.microbit.org).

2- Click on "New Project" to start.

3- Add Bluetooth Extension:

Click on the "Extensions" option in the bottom left corner.

Search and add the "Bluetooth" extension by clicking on it.

4- Add code to send a message:

- Use the bluetooth.uartWriteString() block under Bluetooth to send a string message via Bluetooth.

- Place this block inside on button A pressed event to send the message when a button is pressed.

Download program

 

5- Export the Code:

Connect your Micro:bit to your computer using a USB cable.

Once you have programmed the transmission message , click on "Download" to transfert .hex file to Micro:bit.

Develop a mobile application to receive a message from Micro:bit board

To develop a mobile application to receive a message from the Micro:bit using MIT App Inventor, follow these steps:

1- Go to the MIT App Inventor website (ai2.appinventor.mit.edu).

2- Click on "Start new project" to create a new project.

Design the User Interface (UI):

1- Use the components from the Palette to design the user interface of your application. For example, you can add a TextBox for entering the message and a Button for sending the message.

2- Add Bluetooth Functionality:

From the Palette, click on "Connectivity" and then drag the "BluetoothClient" component onto the design screen.

Design the user interface of your app. You might have two buttons to turn on and turn off the two lamps

3- Add the components to your app.

- The "BluetoothLE1" extension indeed refers to a specific extension for MIT App Inventor which allows you to manage Bluetooth Low Energy (BLE) communication in your mobile applications. This extension facilitates the interaction between your App Inventor application and BLE devices, such as sensors, trackers, wearables, etc.

- The "BluetoothClient1" extension in MIT App Inventor allows you to create mobile applications that can connect to Bluetooth devices, such as serial Bluetooth modules (eg HC-06) connected to microcontrollers, Bluetooth audio devices, etc. . This extension facilitates communication with these devices using serial Bluetooth connections.

- The "Microbit_UART1" extension allows you to use UART (Universal Asynchronous Receiver-Transmitter) communication with the Micro:bit card in the MakeCode programming environment.

- The "Notifier1" extension in MIT App Inventor is a component for displaying notifications or messages to the user of an application. It can be used to send pop-up messages, alerts or important information to the user while the application is running. It is a useful component to improve user experience by providing contextual information.

Here is an example of our mobile application interface:

- Add a ListPicker component to select the Bluetooth device.

- Add a Button  "Connect" for connecting to the micro

- Add a Label to display the received message.

- Add the BluetoothClient component from the Connectivity palette.

Program the Message Sending Functionality:

1- Click on the "Blocks" tab to switch to the Blocks Editor.

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

2- Use these programming blocks to connect the smartphone to the Micro:bit board via Bluetooth:

3- Set up the blocks for message receiving :

Download project Download application

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