Hi
I wrote this code to try to detect if serial cable is connected, it did not work, any idea if this is possible?
Idea behind this is that I program a macro that disables serial print to save power, but If I connect a computer then serial print macro starts to send debug info to serial.
MCU ESP32 wroom bare bone, with an external programmer
void setup() {
Serial.begin(115200);
// delay(50);
if (Serial.available() > 0) {
Serial.print("Seriell kabel IS connected, sWrite settes til 1 (true)");
// sWrite = 1
} else {
Serial.print("Seriell kabel NOT connect, sWrite settes til 0 (false)");
// sWrite = 0
}
Serial Output (cable obviously connected):
Seriell kabel NOT connect, sWrite settes til 0 (false)
6 posts - 4 participants