I was wondering if anyone had gotten Bluetooth LE to work on the UNO R4 WiFi. When attempting to use the Arduino BLE library, the following compile warning. is produced:
WARNING: library ArduinoBLE claims to run on samd, megaavr, mbed, apollo3, mbed_nano, mbed_portenta, mbed_nicla, esp32, mbed_giga architecture(s) and may be incompatible with your current board which runs on renesas_uno architecture(s).
Doe anyone know if this library plans to support the R4 at some point, or if there are any other libraries that work on the R4?
Everything is now in place for us to invite the community to test out the work linked above to add support for using the ArduinoBLE library with the UNO R4 WiFi board. I provide instructions here:
Dear @ptillisch - I am here including a little code for everyone to try out to see if it works, when experimenting with ArduinoBLE library which I installed the way you wrote about it:
The code makes the Arduino board publish itself as "R4" and waits for any user to connect to it. When connected, it says: "Connected". I am yet to try sending a file from my laptop to it, but, it connects as it should, flawlessly. So, first bridge has been crossed. I will write further updates as I go by.
#include <ArduinoBLE.h>
// Define the name of the Bluetooth peripheral
const char* peripheralName = "R4";
// Create a BLE Service
BLEService fileTransferService("19B10000-E8F2-537E-4F6C-D104768A1214");
// Create a BLE Characteristic for receiving data
const char* dataCharacteristicUUID = "19B10001-E8F2-537E-4F6C-D104768A1214";
BLECharacteristic dataCharacteristic(dataCharacteristicUUID, BLEWrite | BLERead, "");
void setup() {
// Initialize the Serial communication for debugging
Serial.begin(9600);
// Initialize the BLE library
if (!BLE.begin()) {
Serial.println("Starting BLE failed!");
while (1);
}
// Set the local name of the Bluetooth peripheral
BLE.setLocalName(peripheralName);
BLE.setAdvertisedService(fileTransferService);
// Add the characteristics to the service
fileTransferService.addCharacteristic(dataCharacteristic);
// Start advertising
BLE.advertise();
Serial.println("Bluetooth peripheral advertising...");
}
void loop() {
BLEDevice central = BLE.central();
if (central) {
Serial.print("Connected to central: ");
Serial.println(central.address());
char receivedData [200] ;
while (central.connected()) {
if (dataCharacteristic.written()) {
strcpy (receivedData, (const char*) dataCharacteristic.value());
// Process the received data (e.g., parse JSON)
Serial.print("Received data: ");
Serial.println(receivedData);
}
}
}
}