I've been using a 2560 with a hardware serial bluetooth setup and want to use the Nano 33 iot to communicate with my existing mobile app. Is there a library that lets me use the 33 bluetooth as if it were serial / just polling read and write calls?
The mobile app is BLE, but I'm just looking for a wrapper that lets me treat it like serial on the Arduino side. I've used ArduinoBLE to set up the service and characteristic and make a connection, so if I can just retain the hardware serial style interface, I'd be all set.
You must have a routine in the Mega program which reads input from the monitor over usb serial, and then sends it out to a second hardware serial port connected to the bluetooth module.
You will use a similar process with BLE, and how you write this serial input value to be read by the phone app depends on how you have written the characteristic.
Please post some code if you want more detailed advice.
For the Mega 2560 configuration, I'm using this device and connecting RX / TX to the Arduino. The mobile device is just a monitor and the Arduino reports sensor data (formatted strings) to the mobile device in realtime.
There is no Characteristic set up on the Mega 2560 arduino side using that device. I just send strings back and forth between the arduino and mobile app. I'd like to do the same with the Nano BT device and hoped someone had already written a wrapper to make it work like serial.
If not, I made a quick attempt to get the string coming from the app with no luck.
BLEService Service("0000ffe0-0000-1000-8000-00805f9b34fb");
BLEByteCharacteristic Characteristic("0000ffe1-0000-1000-8000-00805f9b34fb", BLERead | BLENotify | BLEWriteWithoutResponse);
...
if (!BLE.begin())
{
Serial.println("starting Bluetooth® Low Energy failed!");
}
else
{
BLE.setLocalName("ActiveAero");
BLE.setAdvertisedService(Service);
Service.addCharacteristic(Characteristic);
BLE.addService(Service);
BLE.advertise();
}
...
BLEDevice central = BLE.central();
if (central && central.connected())
{
while (Characteristic.valueUpdated())
{
byte Value = 0;
Characteristic.readValue(Value);
BLEMessage += static_cast<char>(Value);
}
}
Great.
Let me know how it goes adapting your code to the library.
What is your application that wants a UART service between the Nano 33 iot and mobile app. What data is being sent from the Nano33 to the app, and from the app to the Nano 33?