Possible to disable USB power but still have Serial debugging?

Is there a way to disable USB power & LiPo charging? Or some way to test battery code with serial debugging?

I built this USB power switch for that purpose:

You can also switch to using Serial1 debugging and use a FT232 USB to Serial adapter.

1 Like

Thanks. One question, if I were to go with Serial1 is there a global way to convert all my serial commands to serial 1?
ie Serial = Serial1; So all my Serial.println() statements will get routed to Serial1 instead or perhaps mirror them so it goes to both.

No, there is no way to remap. But this would be a good time to investigate switching from Serial.print to Log.info. It is possible to remap the LogHandler between serial ports with a one line code change. You can even do it at runtime if you want. And you’ll catch the system logging messages as well.

Good idea, I’ve been meaning to switch over but the one thing that’s held me up is all the system messages. I see the constructor takes a Filters argument but I can’t find any documentation on that. How would I disable the low level system messages? Ideally I’d like to know connect/disconnect and other major events but I don’t need to see every network packet or state change.

Something like this should work:

SerialLogHandler logHandler(LOG_LEVEL_INFO, { // Logging level for non-application messages
    { "app", LOG_LEVEL_TRACE } // Default logging level for all application messages

You can add as more of those to set the level for any logging category (system, ncp, hal, etc.). You can also use more specific filters like “sys.power”. The most specific match is the one that’s used.

1 Like