The micro:bit has made a huge impact on getting “quicker to awesome” in the classroom. From third grade to high school and beyond, it has proved itself to be a platform that is easy to learn and prototype projects on. But sometimes there is that one thing that sometimes just causes you to stub your toe. For many people that is the radio functionality that comes natively on the micro:bit.
If you have two micro:bits sitting around, grab them and join me in this post to take a closer look at how to set up the radio for communication and how to send data from one micro:bit to another. Ready? Good! Here we go…
First of all we are going to be using Microsoft® MakeCode to program our micro:bit! Head on over to makecode.microbit.org!
The radio is native to MakeCode, which means we don’t need to add anything and can just start working with the blocks that are already at hand. You should have just the basic On Start and Forever blocks in your coding area.
Now, the first thing that most people overlook when they are exploring the radio and get hung up on is assigning a group ID to your micro:bit(s). You do that by using the Set Group (#) block. This is the same thing as setting your micro:bit to a specific channel. For two micro:bits to communicate with one another, they need to be on the same channel. This is often overlooked when you are doing this for the first time. For example, we set our micro:bit to group 4. All micro:bits that we are planning on communicating with should be assigned the same group # in the On Start block.
Now that the micro:bit channel is set, we are free to send data out over the radio. Any data that is sent can be heard by any other micro:bit that is on that channel. So, if we were to send the number 3 over the radio on group 4, all other radios on group 4 could receive that number and do something with it.