Built-in radio capability on micro:bit with Arduino IDE

Hi everyone!

TLDR: building a wireless IR transmitter, need help using built-in radio capability for two micro:bits to communicate while one of the units is programmed using Arduino IDE instead of MakeCode.

STORY (not required to understand my problem):
I’ve been tinkering with micro:bits for a while and have managed to build some nice-looking IR transmitters, each powered by one micro:bit controller (see picture). I want to control some of my home appliances from PC using micro:bits over IR and mostly my system already works except for my air conditioner which uses longer IR commands.

I have decoded those commands. I have got raw IR data from my A/C’s IR remote and decoded each command into a hex string. However, these commands are MUCH longer than any available MakeCode IR extension can handle.

E.g. while a standard NEC IR code looks like this: 0xC160008E;
a decoded A/C command from my A/C remote looks like this: 0x182c14092000100000000300000d980400000000

They work perfectly when trasmitted raw using Arduino UNO (checked that), but this A/C IR module is my last, so I don’t wanna switch and scrap all my work.
I understand that MakeCode won’t let me send neither “long” datagrams nor raw IR data whatever IR-related extension I choose (there aren’t many anyway), so I want to use Arduino IDE with some libraries to do this.

PROBLEM:
I have no idea as to how to make a micro:bit unit programmed with Arduino IDE understand radio data transmitted by another micro:bit unit. I know how to read and write pins, use led matrix and stuff, but I can’t use its radio capability.

How can I send, say, one number from one unit and have it received on the other one with Arduino IDE?

I know this should be possible, because I got this script working fine, but I don’t get any consistent results with it. I can tell WHEN there is a transmission, but I can’t tell WHAT is being transmitted.

Image from Original Post so we don't have to download it. See this Simple Image Posting Guide

...R

n3ver:
PROBLEM:
I have no idea as to how to make a micro:bit unit programmed with Arduino IDE understand radio data transmitted by another micro:bit unit.

PROBLEM ... what is a micro:bit ?

...R

Hi, Robin2, ty for taking the image out! :slight_smile: I've read the Image Posting Guide and won't make such mistakes further on.

Micro:bit is an "entry-level" microcontroller on nRF51822 by BBC. It's easier to start working with for a rookie than Arduino because it has quite a lot of stuff built into it (e.g. buttons, compass, accelerometer, temperature sensor, magnetometer, 5x5 dot LED screen, bluetooth) and its GUI-based code editor has an oversimplified mode along with Python/JS that makes programming super easy (I've never been into coding since I work as a translator, but I managed to do some sort of IR-based IoT with that).

Example of MB code in simplified block mode:

BUT pushing anywhere beyond that is much harder for a novice, because any sensible person would simply switch to Arduino (which I sure will, but after I finish this project). Thus, there's little to no information on the internet.

So, speaking of my problem, micro:bit use their own wireless BLE connectivity. Basically, you can have multiple MB units talk with each other using various channels at the same time. It works like a charm out of the box when MB's own IDE (MakeCode) is used for programming. But I'm having trouble making wireless work using Arduino IDE.

For the micro:bit to work on Arduino, someone had to put together the Arduino core code, and the required libraries. It looks like Adafruit did some or all of the Bluetooth radio stuff, so their forum would be the place to post.

See https://cdn-learn.adafruit.com/downloads/pdf/use-micro-bit-with-arduino.pdf

jremington:
It looks like Adafruit did some or all of the Bluetooth radio stuff, so their forum would be the place to post.

Thank you. I’ve read what they have to offer regarding micro:bit radio. It looks like they only use its BLE to connect it to their mobile application. I’ve found their libraries in Arduino, but found nothing to make two micro:bit devices talk to each other.

I have found, however, another library that seems to be doing what I want. But I lack experience to understand if it is capable of making the MB transmit and receive any actual user data.

When I upload the example onto the board, it seems to be picking up… something of what I’m trying to send from the other unit (the one that is still programmed by micro:bit’s native software). It reacts and prints the output into the console, but this output has nothing to do with what I’m sending.

I don’t really hope to get Arduino-programmed and a MakeCode-programmed micro:bits compatible with each other at this point. I could reprogram all my units with Arduino if I have to, but I’ve got to understand how to make them send/receive strings or at least integer values over radio.

If anyone has ideas, pls halp.

n3ver:
I have found, however, another library that seems to be doing what I want. But I lack experience to understand if it is capable of making the MB transmit and receive any actual user data.

Most all Arduino libraries include examples.

The library you posted a link to appears to have a ping pong example, I would guess thats an example that demonstrates TX and RX.

srnet:
Most all Arduino libraries include examples.

The library you posted a link to appears to have a ping pong example, I would guess thats an example that demonstrates TX and RX.

Yeah, it's just the contents of what's actually being sent there remained mystery to me. But it looks like some of the data in that example CAN be customized, so I can use that to send different commands depending on serial input just as planned.

Too bad I can't keep my original code on my existing micro:bit units for this to work, but it's better than nothing.

the contents of what's actually being sent there remained mystery to me.

In the example code, it appears to be random bits from uninitialized memory.

If you want to send some data, put the data in the Framebuffer struct, in .payload. Study the radio library .h file for the details.

jremington:
Study the radio library .h file for the details.

Thank you a lot for looking into it!
I'm gonna do that tomorrow and see if I can make this work.

For now I found out that the 'version' part of the transmitted data can store integers from 0 to 255, which can be extracted on the remote device and stored in a variable. I know that's not the way it's supposed to be used, but this is the first time I got consistent results.

Thanks once again, I'll see how using payload can help me further. Transmitting strings would be helpful since I used text commands in my old micro:bit code.

The .payload member of the Framebuffer struct is currently dimensioned to hold 32 bytes.