I am trying to get the serial log to output to my iphone from a nano 33 BLE. I'm not seeing the device unless I use nRF Connect app. But even then, it seems to disconnect quickly. Additionally, I was trying to use an app for serial called "Tiny BLESerial" i'm not sure if anyone has had luck with this? The code I have looks like this:
#include <ArduinoBLE.h>
BLEService uartService("6E400001-B5A3-F393-E0A9-E50E24DCCA9E");
BLECharacteristic txCharacteristic("6E400002-B5A3-F393-E0A9-E50E24DCCA9E", BLERead | BLENotify, 20);
BLECharacteristic rxCharacteristic("6E400003-B5A3-F393-E0A9-E50E24DCCA9E", BLEWrite | BLEWriteWithoutResponse, 20);
void setup() {
Serial.begin(9600);
while (!Serial);
if (!BLE.begin()) {
Serial.println("Failed to initialize BLE");
while (1);
}
BLE.setDeviceName("Nano 33 BLE");
BLE.setLocalName("Nano 33 BLE");
BLE.setAdvertisedService(uartService);
uartService.addCharacteristic(txCharacteristic);
uartService.addCharacteristic(rxCharacteristic);
BLE.addService(uartService);
BLE.advertise();
}
void loop() {
if (Serial.available()) {
String message = Serial.readStringUntil('\n');
txCharacteristic.writeValue(message.c_str(), message.length());
}
}