M5Stack, Core2 Bluetooth Example Code???
-
I'm trying to get Bluetooth to work with an M5Stack, Core2 AWS to pass Serial Data.
There is an M5Unified.h example for Bluetooth:
M5Unified.h Bluetooth Example
but it's so obfuscated, I can't make heads or tails of how to extract some simple Bluetooth commands out of it. PLUS, I can't get it to compile...I've had Bluetooth running on an ESP32 WROOM using BluetoothSerial.h (previous project), it connects and passes data. If I use the same Library on the M5Core2 (with the M5Unified.h, latest version) I can see the M5Stack Bluetooth on my Bluetooth device where I get the data (ICOM IC-705), it's discovered when I search, but it won't connect.
Using this simple code:
//ESP32 Specific: #include "BluetoothSerial.h" #if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED) #error Bluetooth is not enabled! Please run `make menuconfig` to and enable it #endif BluetoothSerial SerialBT; void setup() { Serial.begin(115200); SerialBT.begin("IC-705-ESP"); //Bluetooth device name Serial.println("The device started, now you can pair it with bluetooth!"); } void loop() { while(1); }
I can connect with the ESP32 WROOM (using ESP32 Dev Module) but it won't work with the M5Stack, Core2.
Is there something I'm missing, or can someone point me in the direction of some more simplified Bluetooth code for the M5Core2?
I tried others like one that was:
#include <M5Stack.h> #include <BLEDevice.h> #include <BLEUtils.h> #include <BLEServer.h> #include <BLE2902.h>
but again, that didn't work...
Sir Michael
-
I finally figured it out, even after trying all of the examples in the SerialBluetooth.h example directory on the M5Stack Core2.
I finally found that I had to Initialize the Bluetooth settings on my device, after that, the connections worked find.
Sir Michael