Upload sketch to ESP32 C6 Super mini

I purchased two ESP32 C6 super mini modules from Aliexpress. I want to use a small footprint bluetooth module to control a TB6612FNG module to experiment with battery powered HO scale model trains.

I was using the Live Mini Kit ESP32 which worked fine but was hoping to use the C6 smaller footprint.

However I cannot upload the sketch. I have tried several different boards in Arduino but no success.

I have tried to hold the boot button down , press and release the reset button. This brings on the blue led and changes the port available in Arduino from 10 to 14. But I get the same failed upload.

Here’s the code

#include <BluetoothSerial.h>




// Check if Bluetooth is available

#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)

#error Bluetooth is not enabled! Please run `make menuconfig` to enable it

#endif

// Check Serial Port Profile

#if !defined(CONFIG_BT_SPP_ENABLED)

#error Serial Port Profile for Bluetooth is not available or not enabled. It is only available for the ESP32 chip.

#endif

BluetoothSerial SerialBT;

const int PWM_CHANNEL = 0;    // ESP32 has 16 channels which can generate 16 independent waveforms

const int PWM_FREQ = 3000;     // Recall that Arduino Uno is ~490 Hz. Official ESP32 example uses 5,000Hz

const int PWM_RESOLUTION = 8; // We'll use same resolution as Uno (8 bits, 0-255) but ESP32 can go up to 16 bits 

// The max duty cycle value based on PWM resolution (will be 255 if resolution is 8 bits)

const int MAX_DUTY_CYCLE = (int)(pow(2, PWM_RESOLUTION) - 1); 

const int OUTPUT_PIN = 19;

const int DELAY_MS = 100;  // delay between fade increments

// input codes from Battery Throttle

bool  Power = 0;       // P0 = power off, P1 = power on

bool  Direction = 1;   // D0 = reverse,  D1 = forward

bool  HLights = 0;     // HL0 = headlights off, HL1 = headlights on

bool  TLights = 0;     // TL0 = taillights off, TL1 = taillights on.

bool  Horn = 0;        // S0 = Horn off, S1 = Horn on

int AIN1 = 16;         // D2 direction output

int AIN2 = 17;         // D3 direction output

int STBY = 32;         // D4 must be High to drive motor

String loco_ID = "L4599"; //store loco_ID etc in eeprom.

char buffer[2];

int DataReadIn[2];

bool locoDirection = 0;   //forward

int Speed = 0;

int debug = 1;    //set to 1 to show debug info on serial port.

String commandString;




void setup() {

  pinMode(AIN1, OUTPUT);

  pinMode(AIN2, OUTPUT);

  pinMode(STBY, OUTPUT);

  digitalWrite(STBY, HIGH);   //high to enable DRV8833

  Serial.begin(115200);

  SerialBT.begin(loco_ID);

  DataReadIn[0] = 0;

  DataReadIn[1] = 0;

  DataReadIn[2] = 0;

  // Sets up a channel (0-15), a PWM duty cycle frequency, and a PWM resolution (1 - 16 bits) 

  ledcAttachChannel(OUTPUT_PIN, PWM_FREQ, PWM_RESOLUTION, PWM_CHANNEL);

 }




void loop() {

  if (SerialBT.available()>0) {

    commandString = SerialBT.readStringUntil(62);  //>

    interpretCommand();

    if (debug){

    Serial.print("Values In [0]= ");

    Serial.print(DataReadIn[0]);

    Serial.print(" and [1]= ");

    Serial.print(DataReadIn[1]);

    Serial.print(" and [2]= ");

    Serial.println(DataReadIn[2]);

  }

    delay(2000);

}

    SerialBT.flush();

}




void interpretCommand(){

  int index1 = commandString.indexOf("L");

  String whichLoco = commandString.substring(index1, 5);

  if (whichLoco == loco_ID){

    Serial.println ("Command is for this loco");

    int commandCode = commandString.substring(6, 1).toInt();

  switch (commandCode){

    case 1: {doEStopStart();} break;  // Emergency stop

    case 2: {doDirection();} break;   // direction

    case 3: {doSpeed();} break;       // speed

    case 4: {doHLights();} break;     // head lights

    case 5: {doTLights();} break;     // tail lights

    case 6: {doHorn();} break;        // horn

  } 

  }

}




void doHLights(){

int commandValue = commandString.substring(7, 1).toInt();

  switch (commandValue){

    case 0: {Serial.println("Head lights Off");}  break;    // Hlights off

    case 1: {Serial.println("Head lights On");}  break;

  }

}




void doTLights(){

int commandValue = commandString.substring(7, 1).toInt();

  switch (commandValue){

    case 0: {Serial.println("Tail lights Off");}  break;    // Tlights off

    case 1: {Serial.println("Tail lights On");}  break;

  }

}




void doHorn(){

int commandValue = commandString.substring(7, 1).toInt();

  switch (commandValue){

    case 0: {Serial.println("Horn Off");}  break;    // horn off

    case 1: {Serial.println("Horn On");}  break;

  }

}




void doDirection(){

int commandValue = commandString.substring(7, 1).toInt();

switch(commandValue){

  case  0: {Serial.println("Direction is reverse");

              digitalWrite(AIN1, LOW);

              digitalWrite(AIN2, HIGH);} break;

  case  1: {Serial.println("Direction is forward");

              digitalWrite(AIN1, HIGH);

              digitalWrite(AIN2, LOW);} break;

              }

}




void doSpeed(){

int commandValue = commandString.substring(7, 1).toInt();

        if (commandValue>=0){

          if (debug){

        Serial.print("Speed is ");

        Serial.println(commandValue);

          }

        int dutyCycle = (commandValue);

        analogWrite(OUTPUT_PIN, dutyCycle);

        }

        if (debug) {

          Serial.print("Speed is ");

          Serial.println(commandValue);

        }

}




void doEStopStart(){

int commandValue = commandString.substring(7, 1).toInt();

  switch (commandValue){

    case 0:{

    digitalWrite(STBY, LOW);

    digitalWrite(AIN1, LOW);

    digitalWrite(AIN2, LOW);

    Serial.println("STOP");} break;

    case 1:{

    digitalWrite(STBY, HIGH);

    Serial.println("RUN");} break;

    }

}


and this is the error message

Compilation error. #error Bluetooth is not enabled! Please run make menuconfig to enable it.

Where can I find make menuconfig? A search on Google only directs me to Linux articles.

The board selected is the ESP32C3 Dev module. I get the same error when ESP32C6 Dev module selected.

My apologies if I have posted this article in the wrong place.

Hope someone can make sense of my problem and help me out.

I would expect that library using classic bluetooth, which C6 doesn't have (BLE only).

The category where you posted is OK. Your topic title a little less so :wink:
When I did read the title I thought it was an upload problem but it is a compile problem.

Maybe you should change the topic title :wink:

Pushing whatever button on your board will not solve compile problems. Compilation can actually be done without a board connected.

if you have a look at Comparison chips (SoCs) table for ESP8266/ESP32/ESP32-S2/ESP32-S3/ESP32-C3/ESP32-C6 - it shows the ESP32C6 only supports BLE
try File>Examples>BLE>UART for a BLE serial example

if you require Bluetooth Classic try the original ESP32

Information in the atached file may help you:
Text-1ESP32C3SuperMini (1).pdf (360.8 KB)

Thank you sterretje,. I have compiled two example sketches, Server.ino and Scan.ino from the BLE examples. No problems in compiling but I cannot upload either sketch unless I hold down the boot btn. However, after what appears to be a successful upload I see nothing on the system monitor despite the setup having a Serial.println(“Stating BLE work!”)

thank you horace. I tried two example sketches from the BLE section - Scan.ino and Servo. ino. If I hold the boot btn down I can upload either sketch but when I open the system monitor I see nothing despite the setup having the code Serial.println(“Starting BLE work!”).

Make sure to have the option USB-CDC on boot “enabled”

Thank you to all who replied to my post with various suggestions. A very simple solution - I bypassed my USB hub and used a cable directly to a second USB port on the PC. Problem solved, sketches upload without any issues.