My ESP32 board wont respond to my code. I can erase the flash via Platformio and VS Code and through esptool.py, but I cannot get anything out of the board (Serial, LED blinking). It doesnt do even the most basic stuff like:
#include "Arduino.h"
void setup() {
}
void loop() {
digitalWrite(PIN_NEOPIXEL, HIGH); // Turn the RGB LED white
delay(1000);
digitalWrite(PIN_NEOPIXEL, LOW); // Turn the RGB LED off
delay(1000);
}
or
digitalWrite(RGB_BUILTIN, HIGH); // Turn the RGB LED white
delay(1000);
digitalWrite(RGB_BUILTIN, LOW); // Turn the RGB LED off
delay(1000);
or
digitalWrite(LED_BUILTIN, HIGH); // Turn the LED on
delay(1000);
digitalWrite(LED_BUILTIN, LOW); // Turn the LED off
delay(1000);
How I ended up at this point: I am currently working on a project where i want to use an MPU9250 for some running style analysis. Since I have hit a dead end, I wanted to have a small programm that I can use to write and read register of the MPU via serial while its running.
So I used an LLM to give me some code, that parses incoming serial input and does some stuff:
#include <Wire.h>
#include "Arduino.h"
#include "MPU9250.h"
// MPU9250 I2C Adresse
#define MPU9250_ADDRESS 0x68
#define I2C_SCL 6
#define I2C_SDA 7
// Globale Variablen für Sensordaten
int16_t aX, aY, aZ, gX, gY, gZ;
bool continuousPrinting = false;
float gyroScale = 500.0 / 32768.0; // ±500°/s Skalierung
float accelScale = 4.0 / 32768.0; // ±4g Skalierung
void setup()
{
Serial.begin(115200);
Wire.begin(I2C_SDA, I2C_SCL);
delay(500);
writeRegister(MPU9250_ADDRESS, 0x6B, 0x00); // Wake up MPU9250
delay(100);
}
void loop()
{
if (Serial.available() > 0) {
String input = Serial.readStringUntil('\n');
input.trim();
if (input.startsWith("w:"))
{
// Schreibbefehl verarbeiten
processWriteCommand(input);
}
else if (input.startsWith("r:"))
{
// Lesebefehl verarbeiten
processReadCommand(input);
}
else if (input.startsWith("Collect:"))
{
// Sammelbefehl verarbeiten
processCollectCommand(input);
}
else if (input.equalsIgnoreCase("print"))
{
continuousPrinting = true;
Serial.println("Starte kontinuierliche Ausgabe...");
}
else if (input.equalsIgnoreCase("stop"))
{
continuousPrinting = false;
Serial.println("Stoppe Ausgabe...");
}
else if (input.equalsIgnoreCase("help"))
{
printoutOptions();
}
if (continuousPrinting)
{
getaccelgyro();
printSensorData();
delay(500); // 500ms Verzögerung
}
}
}
My platformio.ini:
[env:esp32-s3-devkitc-1]
platform = espressif32
board = esp32-s3-devkitc-1
framework = arduino
monitor_speed = 115200
monitor_echo = yes ; <-- Echo immer aktivieren
monitor_filters = send_on_enter
debug_tool = esp-builtin
upload_protocol = esptool
upload_speed = 921600
build_flags =
-D ARDUINO_USB_MODE=1
-D ARDUINO_USB_CDC_ON_BOOT=1
-O0
debug_build_flags = -O0 -ggdb3 -g3
I got it to recieve the "help" input and execute that function once from within the vs code serial monitor. I dont know what I did exactly but after that, I could not get any responses out of it, and doing minimal programs like just Serial.println("some stuff") in the setup sections or anywhere else or blinking the onboad led did not work anymore. I can upload my code normally and i get no errors from that process, but it just doesnt go further. I get the correct IDs here:
COM3
Hardware ID: USB VID:PID=303A:1001 SER=74:4D:BD:AB:AC:EC
Description: USB Serial Device (COM3)
I am kind of lost, and i dont know if im missing something very obvious about the whole situation. Also a weird behavior i whitnessed: when I was using hterm (a serial terminal program) I could not connect to the serial port. On the first try it said Baud rate not supported, when i changed the baudrate from 115200 to 9600 it said port blocked by another application. when i pressed the reset button on the esp32 and tried again, it said with 9600 baudrate stop bit not supported(setting was on 1), and then again with 2 stop bits port blocked by another application. Also in VS code i whitnessed that even when there was no serial monitor open, I could often not flash my code and had to hold the boot button, press reset, release boot button before I gained serial access again.
