Hi there,
@msfujino gave you the straight answer.
and So I will add, there is a WiKi , or post somewhere that has a write up of the differences and why you have to use certain BSP’s to have access to parts of the capabilities. FWIW when I tested the original combo, the errors were in ArduinBLE. So there’s that, and they don’t maintain it.
here is the output from a good compile. with versions 2.9.2 & 1.37, BSP & ArduinoBLE respectively.
FQBN: Seeeduino:mbed:xiaonRF52840
Using board 'xiaonRF52840' from platform in folder: C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.2
Using core 'arduino' from platform in folder: C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.2
____EDIT_for _brevity___
Using library ArduinoBLE at version 1.3.7 in folder: D:\Arduino_projects\libraries\ArduinoBLE
"C:\\Users\\Dude\\AppData\\Local\\Arduino15\\packages\\Seeeduino\\tools\\arm-none-eabi-gcc\\7-2017q4/bin/arm-none-eabi-size" -A "C:\\Users\\Dude\\AppData\\Local\\Temp\\arduino\\sketches\\E65CCFF477B430C3FE36F3A3F280BDAE/sketch_oct6a.ino.elf"
Sketch uses 321016 bytes (39%) of program storage space. Maximum is 811008 bytes.
Global variables use 69688 bytes (29%) of dynamic memory, leaving 167880 bytes for local variables. Maximum is 237568 bytes.
I tried your code with the Bluefruit it appears to work the same.
#include <bluefruit.h>
// Define BLE services and characteristics
BLEService ledService = BLEService("19b10000-e8f2-537e-4f6c-d104768a1214");
BLECharacteristic redCharacteristic = BLECharacteristic("19b10001-e8f2-537e-4f6c-d104768a1214");
BLECharacteristic greenCharacteristic = BLECharacteristic("19b10002-e8f2-537e-4f6c-d104768a1214");
BLECharacteristic blueCharacteristic = BLECharacteristic("19b10003-e8f2-537e-4f6c-d104768a1214");
const int redPIN = LED_RED; // pin to use for the red LED (D11)
const int greenPIN = LED_GREEN; // pin to use for the green LED (D12)
const int bluePIN = LED_BLUE; // pin to use for the blue LED (D13)
uint8_t prevRedValue = 0;
uint8_t prevGreenValue = 0;
uint8_t prevBlueValue = 0;
void setup() {
Serial.begin(115200);
pinMode(redPIN, OUTPUT); // Set pins as outputs and set LED's HIGH (HIGH is off for this board)
digitalWrite(redPIN, HIGH);
pinMode(greenPIN, OUTPUT);
digitalWrite(greenPIN, HIGH);
pinMode(bluePIN, OUTPUT);
digitalWrite(bluePIN, HIGH);
// Initialize Bluefruit
Bluefruit.begin();
Bluefruit.setTxPower(4); // Check the max power for your module and use accordingly
Bluefruit.setName("BLE_RGB");
// Setup the BLE LED service and characteristics
ledService.begin();
redCharacteristic.setProperties(CHR_PROPS_READ | CHR_PROPS_WRITE | CHR_PROPS_NOTIFY);
redCharacteristic.setPermission(SECMODE_OPEN, SECMODE_OPEN);
redCharacteristic.setFixedLen(1);
redCharacteristic.begin();
greenCharacteristic.setProperties(CHR_PROPS_READ | CHR_PROPS_WRITE | CHR_PROPS_NOTIFY);
greenCharacteristic.setPermission(SECMODE_OPEN, SECMODE_OPEN);
greenCharacteristic.setFixedLen(1);
greenCharacteristic.begin();
blueCharacteristic.setProperties(CHR_PROPS_READ | CHR_PROPS_WRITE | CHR_PROPS_NOTIFY);
blueCharacteristic.setPermission(SECMODE_OPEN, SECMODE_OPEN);
blueCharacteristic.setFixedLen(1);
blueCharacteristic.begin();
// Start advertising
Bluefruit.Advertising.addService(ledService);
Bluefruit.Advertising.start();
}
void loop() {
uint8_t redValue = redCharacteristic.read8();
uint8_t greenValue = greenCharacteristic.read8();
uint8_t blueValue = blueCharacteristic.read8();
// Check for changes in characteristic values and update LEDs accordingly
if (redValue != prevRedValue) {
digitalWrite(redPIN, redValue); // Update red LED
prevRedValue = redValue;
}
if (greenValue != prevGreenValue) {
digitalWrite(greenPIN, greenValue); // Update green LED
prevGreenValue = greenValue;
}
if (blueValue != prevBlueValue) {
digitalWrite(bluePIN, blueValue); // Update blue LED
prevBlueValue = blueValue;
}
delay(100); // Optional delay to avoid too frequent updates
}
compiler output of successful build
FQBN: Seeeduino:nrf52:xiaonRF52840
Using board 'xiaonRF52840' from platform in folder: C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\nrf52\1.1.8
Using core 'nRF5' from platform in folder: C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\nrf52\1.1.8
---- EDIT for Brevity____
Using library Adafruit Bluefruit nRF52 Libraries at version 0.21.0 in folder: C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\nrf52\1.1.8\libraries\Bluefruit52Lib
Using library Adafruit nRFCrypto at version 0.0.5 in folder: C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\nrf52\1.1.8\libraries\Adafruit_nRFCrypto
Using library Adafruit TinyUSB Library at version 1.7.0 in folder: C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\nrf52\1.1.8\libraries\Adafruit_TinyUSB_Arduino
Using library Adafruit Little File System Libraries at version 0.11.0 in folder: C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\nrf52\1.1.8\libraries\Adafruit_LittleFS
Using library Adafruit Internal File System on Bluefruit nRF52 at version 0.11.0 in folder: C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\nrf52\1.1.8\libraries\InternalFileSytem
"C:\\Users\\Dude\\AppData\\Local\\Arduino15\\packages\\Seeeduino\\tools\\arm-none-eabi-gcc\\9-2019q4/bin/arm-none-eabi-size" -A "C:\\Users\\Dude\\AppData\\Local\\Temp\\arduino\\sketches\\E65CCFF477B430C3FE36F3A3F280BDAE/sketch_oct6a.ino.elf"
Sketch uses 115600 bytes (14%) of program storage space. Maximum is 811008 bytes.
Global variables use 14024 bytes (5%) of dynamic memory, leaving 223544 bytes for local variables. Maximum is 237568 bytes.
Changes:
- Removed
valueUpdated()
and replaced it with the read8()
function to get the current value of each characteristic.
- Added variables (
prevRedValue
, prevGreenValue
, prevBlueValue
) to store previous values and compare them with the current value.
- LEDs are updated only if the characteristic value changes.
I hope that helps you get some understanding, Problems are just Opportunities’ with a different POV
GL PJ
Probably use less power as well , hands down the Non-mbed has on that stat.