Connect Your Rust-Powered microbit to a Phone Using nRF Connect
The coding part is done. Now let's run the program and connect to the micro:bit using the nRF Connect mobile app. There is also a desktop version of the app available if you prefer to use your computer instead.
Clone the existing project
If you run into any issues, feel free to clone (or refer to) the project I've created and navigate to the "hello-ble" folder.
git clone https://github.com/ImplFerris/microbit-projects
cd microbit-projects/hal-embassy/hello-ble
Flash
You can flash the program into the micro:bit.
cargo run
You should see output like this:
softdevice RAM: 13328 bytes
If you encounter a panic about insufficient RAM, or a warning that you've allocated more RAM than needed, follow the steps in this guide to adjust the SoftDevice RAM settings.
How to connect?
Once you flash the code, open the nRF Connect mobile app. Scan for the Bluetooth name we set (mine is "implRust") and connect to it.
If successful, you should get the following gets printed in the system console
advertising done! I have a connection.
The app will show the supported service and characteristics.
Reading the value
To read the current battery level, tap the icon highlighted in the image below:
Subscribing to Notifications
To receive automatic updates when the battery level changes, tap the icon with three downward arrows under the characteristic (as shown in the image). This subscribes your phone to notifications from the micro:bit.
What's Next?
All we did here was use the demo mobile app provided by Nordic. In a real-life scenario, you might need to build your own app or figure out how to send data in a way that matches an existing app.