I’m trying to send msg from my nano 33 BLE Sense board to an arduino mega through an AT-09 board (which is almost the same as HM-10, both are for bluetooth 4.0)
Here is my nano’s code (from: https://rootsaid.com/arduino-ble-example/):
#include <ArduinoBLE.h>
BLEService wandService("1101");
BLEUnsignedCharCharacteristic gestureMsg("2101", BLERead | BLENotify);
void setup() {
Serial.begin(9600);
//while (!Serial);
//if (!BLE.begin())
//{
//Serial.println("starting BLE failed!");
//while (1);
//}
BLE.begin();
BLE.setLocalName("MagicWand");
BLE.setAdvertisedService(wandService);
wandService.addCharacteristic(gestureMsg);
BLE.addService(wandService);
//gestureMsg.writeValue(oldBatteryLevel);
BLE.advertise();
Serial.println("Bluetooth device active, waiting for connections...");
}
void loop()
{
BLEDevice central = BLE.central();
if (central)
{
Serial.print("Connected to central: ");
Serial.println(central.address());
while (central.connected()) {
Serial.print("Msg: ");
gestureMsg.writeValue('t');
delay(200);
}
}
Serial.print("Disconnected from central: ");
Serial.println(central.address());
}
I can find the device on my android app, and receive correct msgs.
But I can’t find any devices on my AT-09 board when I use the AT+INQ command (nano BLE Sense has disconnected with my phone).
the AT-09 is connected to the correct softwareserial port on an Arduino Mega R3 (or else the AT commands wouldn’t work)
does anyone no what the problem is? Or if this approach is totally wrong? thanks.