DFRobot Firebeetle 2 ESP32-S3 I2C/Serial communication

Hello all,
I am having difficulty configuring my DFRobot Firebeetle 2 ESP32-S3 board within PlatfomIO. Originally, I was using the Arduino IDE environment in which I was able to successfully upload my code and print to the serial monitor. The code uses a simple watchdog timer to wake the device from sleep mode and then take a distance measurement using the vl53l5cx sensor before going back to sleep. I had this running successfully at 1-minute intervals. After transitioning to PlatformIO I cannot get any readout to my serial monitor. I tried running a basic ‘hello world’ and nothing printed to the monitor. There are no error messages it just sits there running the task to no outcome. After disconnecting the vl53l5cx sensor and running the same ‘hello world’ script again I was able to print to the serial monitor. Basically, I cannot get any I2C communication and can only get serial communication when the I2C pins are disconnected. Please, please can someone help!!

This is my ini config file:

[env:dfrobot_firebeetle2_esp32s3]
platform = espressif32
board = dfrobot_firebeetle2_esp32s3
framework = arduino

lib_deps = 
    sparkfun/SparkFun VL53L5CX Arduino Library@^1.0.3

upload_protocol = esptool

upload_speed = 921600
monitor_speed = 115200
monitor_port = COM9

build_flags =
    -DARDUINO_USB_CDC_ON_BOOT
    -DARDUINO_USB_MODE=1

This is my main.cpp code:

#include <Arduino.h>
#include <Wire.h>
#include <SparkFun_VL53L5CX_Library.h>

#define uS_TO_S_FACTOR 1000000ULL  // Conversion factor for micro seconds to seconds
#define TIME_TO_SLEEP  60          // Time ESP32 will go to sleep (in seconds)

SparkFun_VL53L5CX myImager;
VL53L5CX_ResultsData measurementData; // Result data class structure, 1356 byes of RAM

RTC_DATA_ATTR int bootCount = 0;

int imageResolution = 0; //Used to pretty print output
int imageWidth = 0; //Used to pretty print output

/*
Method to print the reason by which ESP32
has been awaken from sleep
*/
void print_wakeup_reason() {
  esp_sleep_wakeup_cause_t wakeup_reason;

  wakeup_reason = esp_sleep_get_wakeup_cause();

  switch (wakeup_reason) {
    case ESP_SLEEP_WAKEUP_EXT0:     Serial.println("Wakeup caused by external signal using RTC_IO"); break;
    case ESP_SLEEP_WAKEUP_EXT1:     Serial.println("Wakeup caused by external signal using RTC_CNTL"); break;
    case ESP_SLEEP_WAKEUP_TIMER:    Serial.println("Wakeup caused by timer"); break;
    case ESP_SLEEP_WAKEUP_TOUCHPAD: Serial.println("Wakeup caused by touchpad"); break;
    case ESP_SLEEP_WAKEUP_ULP:      Serial.println("Wakeup caused by ULP program"); break;
    default:                        Serial.printf("Wakeup was not caused by deep sleep: %d\n", wakeup_reason); break;
  }
}

void setup() {
  Serial.begin(115200);
  delay(1000); // Give time to open the serial monitor

  Wire.begin(); //Initialise I2C
  Wire.setClock(400000);
  Serial.println("I2C initialized.");

  static int bootCount = 0;
  ++bootCount;
  Serial.println("Ladies and gentlemen this is boot number: " + String(bootCount));

  //Print wakeup reason
  print_wakeup_reason();

  // Configure the timer to wake up
  esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
  //Serial.println("Setup ESP32 to sleep for every " + String(TIME_TO_SLEEP) + " Seconds");

  if (myImager.begin() == false) {
    Serial.println("Sensor not found - check your wiring.");
    while (1);
  }
  Serial.println("VL53L5CX sensor initialized.");

  delay(1000);

  myImager.setResolution(4*4); //(8*8) To enable all 64 pads
  
  imageResolution = myImager.getResolution(); //Query sensor for current resolution - either 4x4 or 8x8
  imageWidth = sqrt(imageResolution); //Calculate printing width

  myImager.startRanging();
}

void loop() {
  // This part of the code will only run after waking up from deep sleep

//Poll sensor for new data
if (myImager.isDataReady() == true)
  {
if (myImager.getRangingData(&measurementData)) //Read distance data into array
    {
      //The ST library returns the data transposed from zone mapping shown in datasheet
      //Pretty-print data with increasing y, decreasing x to reflect reality
      for (int y = 0 ; y <= imageWidth * (imageWidth - 1) ; y += imageWidth)
      {
        for (int x = imageWidth - 1 ; x >= 0 ; x--)
        {
          Serial.print("\t");
          Serial.print(measurementData.distance_mm[x + y]);
        }
        Serial.println();
      }
      Serial.println();
    }
   //}
  delay(10); //Small delay between polling

//Wait for completion of outgoing data transmission
  Serial.flush();

  // Go back to sleep
  Serial.println("Going to sleep now");
  esp_deep_sleep_start();
  Serial.println("This won't print cause I'm schweeping");
  }
}

This is my serial monitor output

Let’s try a very basic and simple sketch:

main.cpp

#include <Arduino.h>

void setup() {
    Serial.begin(115200);
    Serial.println("Hello World");
}

void loop() {
    Serial.println("alive...");
    delay(1000);
}

platformio.ini

[env:dfrobot_firebeetle2_esp32s3]
platform = espressif32 @ 6.8.1
board = dfrobot_firebeetle2_esp32s3
framework = arduino
build_flags =
  -DARDUINO_USB_CDC_ON_BOOT=1
monitor_speed = 115200
  • upload the sketch
  • (manually reset the ESP)
  • open and watch the serial monitor

What do you see?