The V-USB library is a pretty handy piece of code that lets you add USB connectivity to ATtiny microcontrollers (it was previously named tinyUSB). But if you’ve ever looked into adding the library to your own projects you may have been stymied by the complexity of the code. There are many examples, but there’s a lack of a concise quick-start for the uninitiated. [Joonas Pihlajamaa] has been working to correct that shortfall with his four-part V-USB tutorial series. It’s not for the absolute newbie; you should already be comfortable working with AVR chips but that’s the only real prerequisite we can see.
He starts the series with a look into the hardware considerations. USB provides a 5V power rail but the data lines expect 3.3V logic so this must be accounted for. With the test rig built on a breadboard he moves on to pick apart the code, covering various user-defined variables that you’ll need to set based on your project’s needs. We’re going to keep this on the back burner and hopefully the Troll Sniffing Rat will get a makeover (although we must say comments have been a lot nicer as of late… keep it up!).
We’ve embedded links to all four tutorial parts after the break.
- http://codeandlife.com/2012/01/22/avr-attiny-usb-tutorial-part-1/ (primer)
- http://codeandlife.com/2012/01/25/avr-attiny-usb-tutorial-part-2/ (hardware)
- http://codeandlife.com/2012/01/29/avr-attiny-usb-tutorial-part-3/ (software)
- http://codeandlife.com/2012/02/04/avr-attiny-usb-tutorial-part-4/ (wrapping up)
17 thoughts on “Learning To Use The V-USB (AVR USB Firmware) Library”
V-USB is very intuitive to use, highly recommeded. There is bit of learning curve, once passed possibilities are endless.
I did an example project a while back that includes SHT-11 sensor, if anyone interested, it’s available:
Very cool. Thanks for sharing, Stan.
Ive got some SHT sensors that I sampled a while ago and didnt know what to do with them until now. Thanks for your template. The Python PC side app is a good bonus.
did i need to program it first with usbasp programmer !!!
because i am trying to connect it at first time with cable usb
it reads the atmega as unknown device and the usbasp driver is installed already
That’s really great! I have already tried to start with V-USB, but it really looked too complicated for kick-start without proper tutorial. Now I hope things will get a lot better and I will finally be able to start using USB in my projects.
Perfect timing, yet again. :) I’ve been having an interesting time getting an ATmega32U4’s USB to work as I want it, and this looks like a great help to better understanding how it works, particularly the fourth part of the tutorial. Thanks, HaD!
And look, no tArduino stuff! :D WOOHOO!!!!
I believe the 32u4 uses LUFA, not V-USB for the usb interface.
Nice tutorial…have loved V-USB since back when it was AVR-USB and I used it in the Capslocker project. Just this week I set up V-USB on an ATtiny45 as a custom class device, to act as an I2C gateway to a ChronoDot (trying to re-create the Maxim DS3231 live demo). The V-USB documentation wiki is also pretty useful.
Also, doing USB device interfacing on Linux or Mac is SO EASY compared to Windows. I would say that USB interfacing using LibUSB is actually easier on Linux, in some cases, than RS232!
Sadly, serial is still much easier to use.
libusb is great for developing, but a PITA for non-technical end users.
Where possible, I try to make HID or MIDI devices.
Let me share my tutorial on V-USB:
If you are interested in using V-USB with Arduino I ported it a couple of years back:
I haven’t checked if it needs to be updated for 1.0 though.
The problem with all the V-USB examples is that most of them require libusb-win32 which I found to be too complicated for the common user.
I would like to see a dumb’ed down Arduino lib like Rancidbacon’s http://code.google.com/p/vusb-for-arduino/ but with HID comms examples (not keyboard/mouse) that are easy to get working for Win7x64 users without libusb or custom/hacked drivers.
But I think most of the Arduino crowd are just moving to atmega32u4 style chips that support USB CDC (serial) natively.
Those are some loooong wire runs on those breadboards Pilgrim. You sure are lookin’ for trouble there. You’d also do right to add a lot of bypass caps to those power rails.
Thanks for every reader who visited the tutorial, I was really happy to see such interest and hope many found the articles useful! As a thanks, I added a post on turning the project to a USB HID mouse:
If you were referring to me then yes, placing ATtiny, regulator/USB circuit and ISP programming header on different corners of the breadboard for clarity made for some long wire runs. Don’t try this at home! ;)
I see a lot of circa 2012 dates. Being it is now 2021, does all this hold up? Does this work in a Win 10 64 bit environment?
Please be kind and respectful to help make the comments section excellent. (Comment Policy)