XIAO ESP32-C6 bluetooth and platform io

Hi All,

I followed the tutorial to add the xiao esp32 c6 which kind of worked. It showed the board in board manager but could not create a project using it.
Also…I attempted to use NimBLE library for bluetooth but this did not work either. I could not compile a blank sketch without missing file errors. Has this happened to anyone else? I really want to be able to use the c6 xiao units that come with the new mmwave radar kits but so far I’ve had to swap them out for and xiao S3 because the bluetooth portion is essential to my project.

thanks,
Lucas

Hi there,
So can you post what you have in your platform.ini file?
I haven’t seen any issues with BLE and the C6 so it should work.
GL :slight_smile: PJ :v:

1 Like

I used the platform.ini file from the Seeed wiki tutorial titled 'XIAO ESP32C6 with Platform IO.

[env:seeed_xiao_esp32c6]
platform = https://github.com/mnowak32/platform-espressif32.git#boards/seeed_xiao_esp32c6
platform_packages = 
	framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.2
	framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.2/esp32-arduino-libs-3.0.2.zip
framework = arduino
board = seeed_xiao_esp32c6
monitor_speed = 115200
lib_deps = 
	adafruit/Adafruit NeoPixel@^1.12.3
	starmbi/hp_BH1750@^1.0.2
	h2zero/NimBLE-Arduino@^1.4.2type or paste code here

This compiled and worked fine until I added the NimBLE library which resulted in the following errors…

In file included from C:/Users/elect/.platformio/packages/framework-arduinoespressif32-libs/esp32c6/include/bt/include/esp32c6/include/esp_bt.h:17,
                 from .pio/libdeps/seeed_xiao_esp32c6/NimBLE-Arduino/src/NimBLEDevice.h:46,
                 from .pio/libdeps/seeed_xiao_esp32c6/NimBLE-Arduino/src/NimBLEScan.cpp:19:
c:\users\elect\.platformio\packages\framework-arduinoespressif32-libs\esp32c6\include\bt\controller\esp32c6\esp_bt_cfg.h:19:10: fatal error: syscfg/syscfg.h: No such file or directory
   19 | #include "syscfg/syscfg.h"
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
In file included from C:/Users/elect/.platformio/packages/framework-arduinoespressif32-libs/esp32c6/include/bt/include/esp32c6/include/esp_bt.h:17,
                 from .pio/libdeps/seeed_xiao_esp32c6/NimBLE-Arduino/src/NimBLEDevice.h:46,
                 from .pio/libdeps/seeed_xiao_esp32c6/NimBLE-Arduino/src/NimBLEServer.cpp:19:
c:\users\elect\.platformio\packages\framework-arduinoespressif32-libs\esp32c6\include\bt\controller\esp32c6\esp_bt_cfg.h:19:10: fatal error: syscfg/syscfg.h: No such file or directory
   19 | #include "syscfg/syscfg.h"
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
In file included from C:/Users/elect/.platformio/packages/framework-arduinoespressif32-libs/esp32c6/include/bt/include/esp32c6/include/esp_bt.h:17,
                 from .pio/libdeps/seeed_xiao_esp32c6/NimBLE-Arduino/src/NimBLEDevice.h:46,
                 from .pio/libdeps/seeed_xiao_esp32c6/NimBLE-Arduino/src/NimBLESecurity.cpp:19:
c:\users\elect\.platformio\packages\framework-arduinoespressif32-libs\esp32c6\include\bt\controller\esp32c6\esp_bt_cfg.h:19:10: fatal error: syscfg/syscfg.h: No such file or directory
   19 | #include "syscfg/syscfg.h"
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
*** [.pio\build\seeed_xiao_esp32c6\lib968\NimBLE-Arduino\NimBLEScan.cpp.o] Error 1
*** [.pio\build\seeed_xiao_esp32c6\lib968\NimBLE-Arduino\NimBLESecurity.cpp.o] Error 1
In file included from C:/Users/elect/.platformio/packages/framework-arduinoespressif32-libs/esp32c6/include/bt/include/esp32c6/include/esp_bt.h:17,
                 from .pio/libdeps/seeed_xiao_esp32c6/NimBLE-Arduino/src/NimBLEDevice.h:46,
                 from .pio/libdeps/seeed_xiao_esp32c6/NimBLE-Arduino/src/NimBLEService.cpp:20:
c:\users\elect\.platformio\packages\framework-arduinoespressif32-libs\esp32c6\include\bt\controller\esp32c6\esp_bt_cfg.h:19:10: fatal error: syscfg/syscfg.h: No such file or directory
   19 | #include "syscfg/syscfg.h"
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
*** [.pio\build\seeed_xiao_esp32c6\lib968\NimBLE-Arduino\NimBLEServer.cpp.o] Error 1
*** [.pio\build\seeed_xiao_esp32c6\lib968\NimBLE-Arduino\NimBLEService.cpp.o] Error 1
=================================================================================== [FAILED] Took 12.95 seconds ================

It seems it cannot find syscfg anywhere. this doesnt happen when i use a xiao esp32s3. Any ideas would be welcome.thx

Hi there,
So I was able to build and upload the Example sketch for Server_multiconnect.ino
I created a new Project and pasted it into the main.cpp
I had to tweak the Platform.ini to the following to build and upload Successfully.
The Git for ESP32C6 is updated to 3.0.7 and ESP_IDF to v5.1
Builds and works like a champ. SO why NimBLE?
matter or zigbee?

[env:seeed_xiao_esp32c6]
platform = espressif32
board = seeed_xiao_esp32c6
framework = arduino
platform_packages = 
	platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.7
	platformio/framework-arduinoespressif32-libs @ https://github.com/espressif/esp32-arduino-libs.git#idf-release/v5.1
upload_protocol = esptool
build_flags = 
		-DBOARD_HAS_PSRAM

BTW ii also builds AOK on a S3 too.

Code Example

#include <Arduino.h>
#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
#include <BLE2902.h>

BLEServer *pServer = NULL;
BLECharacteristic *pCharacteristic = NULL;
bool deviceConnected = false;
bool oldDeviceConnected = false;
uint32_t value = 0;

// See the following for generating UUIDs:
// https://www.uuidgenerator.net/

#define SERVICE_UUID        "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"

class MyServerCallbacks : public BLEServerCallbacks {
  void onConnect(BLEServer *pServer) {
    deviceConnected = true;
    BLEDevice::startAdvertising();
  };

  void onDisconnect(BLEServer *pServer) {
    deviceConnected = false;
  }
};

void setup() {
  Serial.begin(115200);

  // Create the BLE Device
  BLEDevice::init("ESP32");

  // Create the BLE Server
  pServer = BLEDevice::createServer();
  pServer->setCallbacks(new MyServerCallbacks());

  // Create the BLE Service
  BLEService *pService = pServer->createService(SERVICE_UUID);

  // Create a BLE Characteristic
  pCharacteristic = pService->createCharacteristic(
    CHARACTERISTIC_UUID,
    BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE | BLECharacteristic::PROPERTY_NOTIFY | BLECharacteristic::PROPERTY_INDICATE
  );

  // https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.descriptor.gatt.client_characteristic_configuration.xml
  // Create a BLE Descriptor
  pCharacteristic->addDescriptor(new BLE2902());

  // Start the service
  pService->start();

  // Start advertising
  BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
  pAdvertising->addServiceUUID(SERVICE_UUID);
  pAdvertising->setScanResponse(false);
  pAdvertising->setMinPreferred(0x0);  // set value to 0x00 to not advertise this parameter
  BLEDevice::startAdvertising();
  Serial.println("Waiting a client connection to notify...");
}

void loop() {
  // notify changed value
  if (deviceConnected) {
    pCharacteristic->setValue((uint8_t *)&value, 4);
    pCharacteristic->notify();
    value++;
    delay(10);  // bluetooth stack will go into congestion, if too many packets are sent, in 6 hours test i was able to go as low as 3ms
  }
  // disconnecting
  if (!deviceConnected && oldDeviceConnected) {
    delay(500);                   // give the bluetooth stack the chance to get things ready
    pServer->startAdvertising();  // restart advertising
    Serial.println("start advertising");
    oldDeviceConnected = deviceConnected;
  }
  // connecting
  if (deviceConnected && !oldDeviceConnected) {
    // do stuff here on connecting
    oldDeviceConnected = deviceConnected;
  }
}

from the arduino Server_multiconnect.ino.
Connects with NRF-Connect for desktop BLE and Nordic dongle and on the Nrf_connect for Android AOK :+1: a two to one connection.

as seen Here…

HTH
GL :slight_smile: PJ :v:

Post your code I can see what happens.
The NimBLE example server Compiles on an S3 in Arduino and Works perfect?


I think It’s just not supported yet by NimBLE yet.

I attempted to repeat the XIAO ESP32C6 with platformIO wiki using the platform.ini code you posted above. I was able to repeat the wiki without any issues but when I try to create a new project with the newly added seeed studio xiao esp32c6 board I get the following error…
`PIO Core Call Error: "The following files/directories have been created in C:\Users\elect\Documents\PlatformIO\Projects\c6 test oct28\r\ninclude - Put project header files here\r\nlib - Put project specific (private) libraries here\r\nsrc - Put project source files here\r\nplatformio.ini - Project Configuration File\r\nResolving seeed_xiao_esp32c6 dependencies…\r\n\n\nUnknownBoard: Unknown board ID ‘seeed_xiao_esp32c6’

It seems the board creation wiki does not work for me. Any ideas?

XIAO ESP32C6 in PlatformIO has details on using the pioarduino fork of platform-espressif32.