BLE Device : iPixelcolor 96x16 軟性顯示屏
Web App : iPixelcolor
Question : looking for AMB82-mini example code to
- scan & connect to BLE device
- send text to BLE device
BLE Device : iPixelcolor 96x16 軟性顯示屏
Web App : iPixelcolor
Question : looking for AMB82-mini example code to
Hi @rkuo2000 ,
Scan & Connect to the BLE device
The BLEConnect::connect() method handles scanning and connecting. You need the target device’s Bluetooth address and address type. BLEConnect Class
BLEConnect* bleConn = BLEDevice::configConnection();
// Set scan parameters (optional)
bleConn->setScanInterval(500); // ms, must be >= scanWindow
// Connect by BT address (replace with iPixelcolor device address)
char targetAddr[] = "XX:XX:XX:XX:XX:XX"; // <-- replace with actual address
bool connected = bleConn->connect(targetAddr, GAP_REMOTE_ADDR_LE_PUBLIC, 5000);
if (connected) {
Serial.println("Connected to iPixelcolor!");
} else {
Serial.println("Connection failed.");
}
Note: You can first run the BLEScan example (Files → Examples → AmebaBLE → BLEScan) to discover the iPixelcolor device’s Bluetooth address and address type before connecting. BLE Scan
Discover Service & Characteristic, then Send Text
After connecting, use BLEClient to discover services and get the target characteristic, then write text using writeString(). BLERemoteCharacteristic writeString
// After connection, discover services
BLEClient* client = BLEDevice::addClient(connId);
client->discoverServices();
// Get the target service by UUID (replace with iPixelcolor's service UUID)
BLERemoteService* pService = client->getService("YOUR-SERVICE-UUID");
if (pService != nullptr) {
// Get the target characteristic by UUID (replace with iPixelcolor's characteristic UUID)
BLERemoteCharacteristic* pChar = pService->getCharacteristic("YOUR-CHAR-UUID");
if (pChar != nullptr) {
// Optionally increase buffer size for longer text
pChar->setBufferLen(230); // max 230 bytes
// Send text to the BLE device
bool success = pChar->writeString("Hello iPixelcolor!");
if (success)
{ Serial.println("Text sent successfully!"); }
else
{ Serial.println("Failed to send text."); }
}
}
Full Working Reference
For a complete working example of BLE client scan + connect + UART text exchange, please refer to the official BLEUartClient example: BLE UART Client
Files → Examples → AmebaBLE → BLEUartClient
Important Notes
You must identify the iPixelcolor device’s service UUID and characteristic UUID (for writing text) from its BLE profile. You can use nRF Connect (Android/iOS) to inspect the device’s GATT services and characteristics.
The characteristic data buffer defaults to 20 bytes and can be increased up to 230 bytes using setBufferLen(). setBufferLen
Thank you.