This should do the trick. There seemsI did not try to bego further, but I know there is some communicationinformation passing on Serial1 when you plug a device, you should be able to detect it with this code.
void setup() {
Serial.begin(115200);
Serial1.begin(250000);
}
void loop() {
if(!Serial1.available()) {
Serial.println("OFF");
delay(500);
}
else {
Serial.println("ON");
Serial1.end();
delay(500);
Serial1.begin(250000);
}
}
Maybe you can try to see if depending on the device, information is persistent, in which case you should be able to detect a specific device / kinf of device ? I'll look at it tomorrow, maybe will have more code to show...