Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 8 of 8

Thread: T3.2 - USB detection?

  1. #1
    Senior Member
    Join Date
    Oct 2016
    Posts
    170

    T3.2 - USB detection?

    Hi, it's possible to know if the USB is connected or not to T3.2?
    I hope that it's possible to know for make a specific code if is connected to the USB or by battery.
    Thank u
    Dan

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,927
    If you edit the low-level USB code, you can detect whether the USB host has assigned an address and a configuration number.

  3. #3
    Senior Member
    Join Date
    Jun 2013
    Posts
    296
    Code:
    if (usb_configuration) {
    
    }

  4. #4
    Senior Member
    Join Date
    Oct 2016
    Posts
    170
    Quote Originally Posted by yeahtuna View Post
    Code:
    if (usb_configuration) {
    
    }
    Works fine but if i unplug the USB cable "if (usb_configuration)" stay true... it's possible to reset without power off?

  5. #5
    Senior Member
    Join Date
    Jun 2013
    Posts
    296
    I'm not sure it this would work, but couldn't you read the voltage on the USB 5v when an analogRead?

  6. #6
    Senior Member
    Join Date
    Oct 2016
    Posts
    170
    itís perfect but is always true after the first plug of USB (computer, if itís a power supply stay false).

    Itís perfect but canít recognise when is disconnected after the first connection..

  7. #7
    Senior Member
    Join Date
    Jun 2013
    Posts
    296
    You will have to roll your own solution. Another thing I can think of would be to set a timer that periodically sends date to the host. If the function returns 0 bytes sent, you could likely infer that the connection was lost.

  8. #8
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    2,952
    Quote Originally Posted by yeahtuna View Post
    I'm not sure it this would work, but couldn't you read the voltage on the USB 5v when an analogRead?
    Depending on the Teensy, you would might need a voltage divider to bring the voltage down to 0..3.3v. You wouldn't need an analog read, a normal digital read would do.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •