Radio communication between micro:bit devices
The micro:bit can communicate with other micro:bits over a radio connection, using the built-in antenna on the back of the device. This feature is useful in projects that need wireless data exchange, such as multiplayer games, sending messages or transferring sensor data.
Examples of using the radio
- Exchanging messages between devices – sending and receiving short text or number messages.
- Synchronizing devices – ideal for creating simple networks or groups of micro:bits that work in sync.
Commands in the Radio palette

- radio set group – sets the group the micro:bit belongs to. Only devices in the same group can communicate with each other.
- radio send number – sends a number to other devices in the same group.
- radio send string – sends a text string over the radio.
- radio on received – runs when the micro:bit receives a number or text from another micro:bit in the group.
- radio send value – sends a value in the format "key: value", which is useful for transferring more complex data.
- on radio received[receivedNumber] – registers code that runs when a number is received.
- on radio received[name] [value] – runs part of the program when the micro:bit receives a name-value pair over the radio.
- on radio received[receivedString] – registers code that runs when a string is received.
- received packet [signal strength] – reads one of the properties of the last received radio packet.
Advanced commands (click "more"):
- radio set transmit power – sets the transmission power (from 0 to 7), which affects the communication range.
- radio set transmit serial number – sends the micro:bit's serial number together with the messages, which is useful for identifying individual devices in a network.
- radio set frequency band – changes the radio's transmit and receive band to the given channel. The default is 7.
- radio raise event from source with value – sends an event over the radio to be raised on the event bus of another device.
These commands can be used to create creative projects that need wireless exchange of information, and their use can easily be extended to different tasks, such as remote control of devices or exchanging data between sensors.
How two micro:bits exchange messages over the radio
Communication between two micro:bit devices over the radio lets the devices exchange data wirelessly in a simple way. This is especially useful for projects that include remote control, sharing data or synchronizing events. Here are the details of how it works and how it can be used. The key steps for radio communication:
- Enabling the radio:
- On each micro:bit you call the function radio.setGroup(groupNumber) so that the devices communicate within the same group. The group number must be the same for all devices that want to communicate.
- Group numbers are used as "channels" for communication and help keep different conversations apart.
- Sending data:
- The command radio.sendString("message") is used to send text messages.
- Alternatively, numbers can be sent with radio.sendNumber(number), or custom data with radio.sendValue("name", value).
- Receiving data:
- The micro:bit uses events to receive data:
- radio.onReceivedString(function (receivedString) {...}) to receive text messages.
- radio.onReceivedNumber(function (receivedNumber) {...}) to receive numbers.
- radio.onReceivedValue(function (name, value) {...}) to receive named values.
- The micro:bit uses events to receive data:
- Range:
- The micro:bit radio has a range of about 10–20 metres indoors and up to 50 metres outdoors, depending on obstacles.
- Setting the signal power (optional):
- The command radio.setTransmitPower(powerLevel) (power level from 0 to 7) is used to set the signal power.
Examples of practical use
- Remote control of a vehicle:
- One micro:bit serves as the controller, while another micro:bit on the vehicle receives movement commands (e.g. "forward", "back", "left", "right").
- Exchanging messages:
- Two micro:bits are used to exchange text messages: the user presses a button to send a message that is shown on the screen of the other micro:bit.
- Measuring distance and an alarm:
- One micro:bit collects data from a sensor (e.g. an ultrasonic sensor) and sends it to another micro:bit that displays or reacts to the data.
- Multiplayer games:
- For example, the game "Battleship", where each player uses a micro:bit to mark their ships and receive data about attacks.
- Synchronizing devices:
- One micro:bit sends a signal to several devices to synchronize an activity, such as turning on lights or starting motors.
Project 1: Measuring temperature remotely with micro:bit devices
Description of the problem:
Make a system that uses two micro:bit devices to measure the outside temperature at a distance. One device measures the temperature with its built-in sensor and sends the data over the radio, while the other device receives the data and shows it on its LED screen. This principle can also be extended to create a complete weather station.
Description of the project:
- Goal:
- Demonstrating the use of the radio on micro:bit devices to exchange data.
- Creating a simple system for measuring and displaying temperature remotely.
- Hardware needed:
- Two micro:bit devices (one for measuring the temperature, the other for displaying the data).
Steps
Code for the temperature-measuring device ("Sender")
- Set the radio group (e.g. group 1) with the command radio.setGroup(1).
- Read the temperature with the command input.temperature().
- Use radio.sendNumber() to send the measured value to the other device at regular intervals (e.g. every second).

The same program in JavaScript (MakeCode):
let t = input.temperature()
radio.setGroup(10) // both devices must be in the same group
input.onButtonPressed(Button.A, function () {
basic.showNumber(t)
})
basic.forever(function () {
t = input.temperature()
radio.sendNumber(t) // sends the measured temperature
})
Tip: add a pause (ms) 1000 block at the end of the forever block. That way the temperature is sent once a second, as the steps say, instead of non-stop.
Code for the temperature-displaying device ("Receiver")
- Set the same radio group.
- Catch the received data with radio.onReceivedNumber().
- Show the received temperature on the LED screen.

In the picture of the blocks the variable is called spoljnaTemperatura (Serbian for "outside temperature"); in the code below it is outsideTemperature.
The same program in JavaScript (MakeCode):
let outsideTemperature = 0
radio.setGroup(10)
// a number arrived over the radio – it is stored as the outside temperature
radio.onReceivedNumber(function (receivedNumber) {
outsideTemperature = receivedNumber
})
input.onButtonPressed(Button.A, function () {
basic.showNumber(input.temperature()) // the temperature of this device
})
input.onButtonPressed(Button.B, function () {
basic.showNumber(outsideTemperature) // the temperature received over the radio
})
Extending the project
- Add an alarm that warns about extreme temperatures (e.g. above 30°C or below 0°C).
- Use an external temperature sensor (such as the DHT11 or DS18B20) for more precise measurements.
- Show additional information, such as humidity, pressure or the time of the last reading, using additional radio messages.
How can this become a weather station?
- Add more sensors (for humidity, light, pressure) connected to the "Sender" micro:bit.
- Use a custom display (e.g. an LCD module) on the "Receiver" device to show more data.
- Send the data to a computer or a server for long-term storage and analysis.
Project: "Watch out, thief!"
Description of the project:
The goal of this project is to make an alarm system using two micro:bit devices that communicate over the radio. The system works like this: one micro:bit (the "Sensor") watches the movement of a box or an object that holds something valuable, while the other micro:bit (the "Alarm") warns about a possible theft attempt. When the accelerometer on the sensor detects movement, an angry face appears on its screen and the message "Thief!" is sent to the alarm, which then plays a siren sound and warns about the movement.
Instructions
Hardware needed:
- Two micro:bit devices.
- Optional: a speaker connected to a micro:bit pin to play the siren.
Code for the "Sensor" micro:bit:
Tasks:
- Detect the movement of the object with the built-in accelerometer.
- Show an angry face on the LED screen when movement is detected.
- Send the message "Thief!" and turn on the "Alarm" micro:bit.
Main commands:
- input.acceleration(Dimension.Strength) to track the strength of the acceleration.
- radio.setGroup() to match the radio group.
- radio.sendString() to send the warning.
Code for the "Alarm" micro:bit
Tasks:
- Detecting movement with the built-in gesture sensor.
- Sending the radio message "Thief!" when movement is detected.
- Reacting to a received message by showing an icon and playing a melody.
Explanation of how it works:
- Detecting movement: The function input.onGesture(Gesture.Shake, function () { ... }) detects shaking of the device. When that happens, the alarm starts and a radio message is sent.
- Sending and receiving messages:
radio.sendString("Thief!") sends the message over the radio. When the message is received through radio.onReceivedString(function (receivedString) { ... }), the other device activates the alarm.
- Alarm:
The function alarm() shows an angry face icon and plays a melody using the micro:bit's built-in functions.
- Setting the radio group:
radio.setGroup(1) makes sure that both devices communicate in the same group.

In the picture of the blocks the message is "Lopovi" (Serbian for "Thieves"); in the code below it is "Thief!".
The same program in JavaScript (MakeCode):
function alarm () {
basic.showIcon(IconNames.Angry)
music.startMelody(music.builtInMelody(Melodies.Prelude), MelodyOptions.Once)
}
// "Sensor": when the box is moved (shaken), it sends a warning
input.onGesture(Gesture.Shake, function () {
radio.sendString("Thief!")
alarm()
})
// "Alarm": when a message arrives, it shows it and plays the siren
radio.onReceivedString(function (receivedString) {
basic.showString(receivedString)
music.startMelody(music.builtInMelody(Melodies.Ringtone), MelodyOptions.ForeverInBackground)
})
radio.setGroup(1)
The same program is flashed onto both micro:bits. The siren on the receiver plays until the device is reset (or add a stop all sounds block, e.g. on button A).
Extending the project
- Add detection of the box being opened using an additional sensor (e.g. a magnetic switch).
- Show the number of consecutive theft attempts on the screen of the "Alarm" micro:bit.
- Implement different alarm sounds depending on the detected event (e.g. a mild or an urgent alarm).
Conclusion
This project is an excellent example of how micro:bit devices can be used for wireless communication and practical warning systems. With additional sensors or modules, this system can easily be extended and adapted to different needs.
More complex practice tasks
- Using several communication channels:
- Task: Let two micro:bits communicate using different channels for different messages (e.g. channel 1 for text messages, channel 2 for commands).
- Instructions: Define the conditions for switching channels and use different channel numbers in the radio.setGroup() function. Let the users choose the channel by pressing a button.
- Encrypting messages:
- Task: Implement simple encryption of messages before sending (e.g. by shifting characters by a certain number of places in the ASCII table) and decryption on receiving.
- Instructions: Use string functions to change the text before sending, and implement the reverse operation on the receiving side.
- Group communication with acknowledgement:
- Task: Create a system where several micro:bits send messages, and the receiver sends an acknowledgement of receipt (ACK).
- Instructions: Implement a mechanism where the receiver automatically replies with the message "received", and the sender checks the reply.
- The "phone call" game:
- Task: Two micro:bits communicate in turns, simulating a phone call, where each sends a message and waits for a reply before sending the next one.
- Instructions: Use flags or variables to keep track of whose turn it is to send.
- Remote control of a device:
- Task: One micro:bit sends commands over the radio to control the LEDs on another micro:bit.
- Instructions: Define different commands (e.g. "ON", "OFF", "BLINK") and use conditional statements to interpret them on the receiving side.
- Estimating the distance of a message:
- Task: Investigate how the signal strength (radio.receivedPacket(RSSI)) can be used to estimate the distance between micro:bits.
- Instructions: Show the signal strength on the LED screen; students can investigate how the signal strength changes with distance and obstacles.
For advanced users: tasks to solve on your own
Task 1: Measuring the signal strength
Task text: Make a program that measures the strength of the signal of a received radio packet and shows the result on the screen. If the signal is weaker than -80, it shows a sad face, otherwise a happy one.
Instructions for solving it with blocks:
- Add the radio set group block and set the group (e.g. 1).
- Use the on radio received block from the Radio section.
- From the received packet block choose signal strength and save the result in a variable, using the set variable block.
- Add a condition with the if...then block:
- If the signal is weaker than -80, use show icon to show a sad face.
- Otherwise show a happy face.
- Test the program with two micro:bit devices.
Task 2: Setting the signal power
Task text: Make a program that lowers the transmission power when button B is pressed and raises it with button A. The signal power is shown on the LED screen.
Instructions for solving it with blocks:
- Set radio set transmit power to the starting value 3.
- Make a variable power and set it to 3.
- Use on button A pressed:
- Increase power by 1, but limit the maximum value to 7 (use an if condition).
- Update radio set transmit power to the value of the variable.
- Add the block on button B pressed to decrease power (limit the minimum value to 0).
- Use show number to show the current value of power.
Task 3: Identifying a device by its serial number
Task text: Make a program that sends a unique message containing the device's serial number. When another device receives the message, it shows the serial number on the screen.
Instructions for solving it with blocks:
- Enable sending the serial number with radio set transmit serial number.
- Set on button A pressed to send a message with radio send string (e.g. "Hello").
- On the receiving side use on radio received:
- Show the received packet serial number with show number.
Task 4: Changing the radio channel
Task text: Make a program that lets you change the radio channel by pressing a button. The current channel is shown on the LED screen.
Instructions for solving it with blocks:
- Make a variable channel and set it to the starting channel (e.g. 7).
- Set button A to increase channel by 1 (limit the maximum value to 13).
- Set button B to decrease channel (minimum value 0).
- Use radio set group to update the group according to the value of channel.
- Show the current channel with show number.
Task 5: Raising an event over the radio
Task text: Make a program that raises an event when it receives a specific message. Another device detects the event and shows a matching message.
Instructions for solving it with blocks:
- On the sending device set radio send string (e.g. "Event1") on pressing button A.
- On the receiving device use on radio received:
- If the received string equals "Event1", use radio raise event from source with value (e.g. source=100, value=1).
- Use on event to detect the event and show a message on the screen.
Check your knowledge
Open the quiz
Radio communication
1. What must be the same on two micro:bits for them to exchange messages?
2. Which block sends a number to another device?
3. When does the block on radio received receivedNumber run?
4. What does the block radio set transmit power do?
