Detect USB

17 Dec 2009

Is there a simple way for the program running on an mbed to detect wether or not it is connected to a PC via the USB link please?

 

I am writing a data logger and would like to have it automatically write to the local file system when it is not connected to a PC

18 Dec 2009 . Edited: 18 Dec 2009

Hi Allan,

Allan Newton wrote:
Is there a simple way for the program running on an mbed to detect wether or not it is connected to a PC via the USB link please?

No, not that we've explicitly put in.

I was just about to hit post and say I can't think of a way to construct that detection and hence it was a feature request, but while filing the ticket I thought of this:

Wire VU to a DigitalIn - If it is 1 (5v), USB is connected!

Could that work?

Simon

18 Dec 2009

The other processor ('magic' chip) will know if its connected, yes?

So would it just be matter of providing some interface through the libraries to pole the status?

18 Dec 2009

Simon,

 

Thanks, I will try it and report back. It seems almost certain that this or a simple variant will work.

I will post here when I get soemthing to work.

Allan

18 Dec 2009

Simon,

Your idea works well thank you.

A minor improvement though is to use DigitalIn to detect the battery power. This will then allow testing under battery operating conditions whilst still having PC access.

All my transducers will give an analogue output and be read by AnalogueIn so there are no other devices to help detect the USB.

 

Allan