The radio blocks in MakeCode let you send instructions from one micro:bit to another. But what if you have multiple micro:bits transmiting and receiving data. How will they know which micro:bit to respond to?
The radio blocks in MakeCode let you set a group as a way to assign a particular number to a each micro:bit using radio
Inside the Makecode editor, you can explicitly set the radio group with the radio > set group blocks.
The group number can be any number from 0 to 255. The group number at the transmitting end, and receiving end, must match, if you are to transfer data between two or more micro:bits.
The radio blocks in MakeCode mak use of the micro:bit radio protocol in the DAL. The radio protocol is based on a proprietary short-range wireless interface provided in the Nordic nRF51 software development kit.
The micro:bit DAL puts a group code in the first byte of all payloads transmitted via the radio interface. At the receiving end, if this group code does not match the group code set by the receiving script, the payload is ignored by the receiver, and your script will never see that data payload.
In the Makecode editor, if you do not explicitly set the group number, then the editor will allocate one for you. It does this by taking a 'hash' of your script, and choosing the radio group based on that. So, if you load the same script (same .hex file) into two or more micro:bits, they will automatically be set to use the same radio group by default.
If you have two different MakeCode editor scripts, then there is a 1 in 256 chance that they may be on the same radio group. But it is quite unlikely that the same group will be used. This is useful, because if you have multiple students working on radio projects, they can just leave the group code undefined, and providing the same script is loaded into two micro:bits, those two micro:bits will be able to communicate, without interfering with other micro:bits.
The radio interface on the micro:bit sends broadcast messages, so if multiple micro:bits have the same group code set then they will all be able to see the messages sent by others. It is also possible to change the group code while the micro:bit is running your code, so you could use different group codes for different purposes, on a single micro:bit.
Keywords for search: radio groups, not working,