I am using Arduino Nano BLE 33. I succesfully completed the tutorial "
Controlling RGB LED Through Bluetooth
" and it runs exactly as described using the LightBlue app. When I send over a hex/oct value the ports go high/low accordingly.
Now I want to create my own app with MIT APP Inventor and no longer use the Light Blue.
So far my app can see a list of available devices and I can connect to the Nano. (I see the orange light (DL1) come on).
How do I send the hex values to the NANO? Nothing I try seems to work so I think I'm missing a step.
I tried BLE1.WriteBytes/ WriteIntegers / WriteStrings.... I can't figure out what to send so that the Nano understands it the same way that it does from the LightBlue app.
Also Q2.
Do I have to send over the full characteristic value "0000180a-0000-1000-8000-00805f9b34fb"
or the short version "180a"?
Also Q3.
are those GUID case sensitive? is "180a" treated as different to "180A"?
Thank you.
Hi Bob. The full sketch is in the link...
https://docs.arduino.cc/tutorials/nano-33-ble/bluetooth/
The LightBlue app is sending hex values but I don't know if it's in bytes or what? I don't understand the "swithCharateristic" in the code.
#include <ArduinoBLE.h>
BLEService ledService("180A"); // BLE LED Service
// BLE LED Switch Characteristic - custom 128-bit UUID, read and writable by central
BLEByteCharacteristic switchCharacteristic("2A57", BLERead | BLEWrite);
void setup() {
Serial.begin(9600);
while (!Serial);
// set LED's pin to output mode
pinMode(LEDR, OUTPUT);
pinMode(LEDG, OUTPUT);
pinMode(LEDB, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW); // when the central disconnects, turn off the LED
digitalWrite(LEDR, HIGH); // will turn the LED off
digitalWrite(LEDG, HIGH); // will turn the LED off
digitalWrite(LEDB, HIGH); // will turn the LED off
// begin initialization
if (!BLE.begin()) {
Serial.println("starting Bluetooth® Low Energy failed!");
while (1);
// set advertised local name and service UUID:
BLE.setLocalName("Nano 33 BLE");
BLE.setAdvertisedService(ledService);
// add the characteristic to the service
ledService.addCharacteristic(switchCharacteristic);
// add service
BLE.addService(ledService);
// set the initial value for the characteristic:
switchCharacteristic.writeValue(0);
// start advertising
BLE.advertise();
Serial.println("BLE LED Peripheral");
void loop() {
// listen for BLE peripherals to connect:
BLEDevice central = BLE.central();
// if a central is connected to peripheral:
if (central) {
Serial.print("Connected to central: ");
// print the central's MAC address:
Serial.println(central.address());
digitalWrite(LED_BUILTIN, HIGH); // turn on the LED to indicate the connection
// while the central is still connected to peripheral:
while (central.connected()) {
// if the remote device wrote to the characteristic,
// use the value to control the LED:
if (switchCharacteristic.written()) {
switch (switchCharacteristic.value()) { // any value other than 0
case 01:
Serial.println("Red LED on");
digitalWrite(LEDR, LOW); // will turn the LED on
digitalWrite(LEDG, HIGH); // will turn the LED off
digitalWrite(LEDB, HIGH); // will turn the LED off
break;
case 02:
Serial.println("Green LED on");
digitalWrite(LEDR, HIGH); // will turn the LED off
digitalWrite(LEDG, LOW); // will turn the LED on
digitalWrite(LEDB, HIGH); // will turn the LED off
break;
case 03:
Serial.println("Blue LED on");
digitalWrite(LEDR, HIGH); // will turn the LED off
digitalWrite(LEDG, HIGH); // will turn the LED off
digitalWrite(LEDB, LOW); // will turn the LED on
break;
default:
Serial.println(F("LEDs off"));
digitalWrite(LEDR, HIGH); // will turn the LED off
digitalWrite(LEDG, HIGH); // will turn the LED off
digitalWrite(LEDB, HIGH); // will turn the LED off
break;
// when the central disconnects, print it out:
Serial.print(F("Disconnected from central: "));
Serial.println(central.address());
digitalWrite(LED_BUILTIN, LOW); // when the central disconnects, turn off the LED
digitalWrite(LEDR, HIGH); // will turn the LED off
digitalWrite(LEDG, HIGH); // will turn the LED off
digitalWrite(LEDB, HIGH); // will turn the LED off
Just some of the ways that I've been trying to send over the data. 
I can't help thinking that there is some other value that I should be setting ?!
@b707 No. And everything I've tried, hex / oct / binary / int is not going across to the Nano. But from the Light Blue app everything works as expected.
@UKHeliBob
A list of values to send to the device...
When I connect with my MIT app I can see in the Serial Monitor that I'm connecting and disconnecting.
On my app I am getting the Service GUID and Characteristics from the Nano
Only thing that's missing is my data being sent to the Nano 
Serial.PrintLn displays nothing at all when I use my app but displays the value I sent using the LightBlue
After LightBlue data was sent...
Also I can read from the Nano. If using LightBlue I change the "5" to another value then I can see it updated in my MIT app.
Only problem I appear to be having is that it won't WRITE to the Nano
It is not a solution for your issue, but why do you using these weird case values in the switch operator in the code:
switch(switchCharacteristic.value() ) {
case 01:
as "case 01", "case 02".
If this a hex values, it should be writtten as 0x01 and 0x02
But in general there is no difference between 0x01 and just 1 (decimal) for the controller 
To begin with I strictly followed the Arduino example given. From there I wanted to use the MIT to create a custom app.
Their code is looking for Octal but Hex is fine too if the number is low enough. I am only sending the values 0, 1, 2, 3, 4, 5, 9, 10, 11. I don't mind figuring out these little things. I imagine later there is a need to send over all sorts of data back and forth but of course I'm trying to do the minimum of setting the ports on/off for starters.
Just to add; I've tried INTs, Strings, Bytes, Binary... and anything else I could think of.
If I send Binary 4 / 100 in LightBlue it will work anyway and the Serial Monitor displays "4"