I am building a project to send HID keystrokes to a computer with an ATTiny85. I want to detect when the USB communication is working, in order to turn on a LED saying that everything is good. If USB stops working, I want a watchdog to turn the LED off. Ideally it would also attempt to reconnect automatically.

DigiUSB has the DigiUSB.available() method, but DigiKeyboard does not, and I can't seem to use both headers in the same program because of conflicts. How can I do this without DigiUSB?

  • I see, well I would like to figure out any way to determine the connection status, and I'm coming up short. – Bobby Tables Jul 24 '20 at 20:24
  • @jsotola it is specifically in reference to using the attiny85 with a Micronucleus bootloader being programmed from the Arduino IDE. Unfortunately, delving into the complexities of V-USB and DigiKeyboard/DigiUSB headers is beyond my skill set, so I'm posting to try and find someone who does know. – Bobby Tables Jul 24 '20 at 20:48
  • Well, that's slightly complicated. It appears as two different devices in Windows - when first plugged in, it shows up under libusb-win32 devices as Micronucleus, and then after the 5-second bootloader timeout that becomes disconnected and then it shows up as HID Keyboard. I haven't had an issue with it disconnecting randomly, but I'm attempting to think ahead in case such a thing did happen. For example, the board has a separate power input independent of the USB power, so if comms are lost and the board still has power, I want it to be able to detect that and provide an output. – Bobby Tables Jul 25 '20 at 2:06
  • some thoughts ... turn the LED on when the device is enumerated ... turn the LED off when the device misses getting polled a couple of times .... reset the device when the device misses getting polled 10 times or so – jsotola Jul 25 '20 at 2:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.