This is a project we use here at adafruit to check incoming goods as well as QC products out of manufacturing. If you have a USB device, the chip inside has a unique VID (vendor ID) and PID (product ID). For non-programmable parts, this pair is 'fixed' by the chipset itself. For programmable parts, like a microcontroller, the VID/PID is programmed in. Basically, you can use it to check chipsets and/or whether your Flora, say, has the right bootloader installed.

This is something we have to check a few times a day, so we made  stand-alone tester!

You'll also want some sort of display, such as a plain or RGB 16x2 LCD shield kit. Be sure to follow the product tutorial to assemble

Put it together, add code!

OK not a lot going on here, put the LCD shield on top, install the Arduino library, upload the shield demo code & adjust the contrast potentiometer so you know it works. Then upload this code:

// include the library code:

#include <Wire.h>
#include <utility/Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>
#include <avrpins.h>
#include <max3421e.h>
#include <usbhost.h>
#include <usb_ch9.h>
#include <Usb.h>
#include <usbhub.h>
#include <address.h>

USB     Usb;
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();

void setup () {
  Serial.begin(9600);			/* Initialize serial for status msgs */
  Serial.println(F("\nVID PID tester"));

  lcd.begin(16, 2);
  lcd.print("USB VID/PID Test");
  lcd.print("Waiting for USB");

void loop (void) {
  // initialize USB
  Serial.println("USB Start");

  if (Usb.Init() == -1) {
    Serial.println("OSC did not start.");
    while (1);
  Serial.println("Waiting for connection...");

  while (1) {
    if( Usb.getUsbTaskState() == USB_STATE_RUNNING ) break;
  uint8_t rcode = 0;
  byte num_conf = 0;

  rcode = Usb.getDevDescr(1, 0, 0x12, ( uint8_t *)&buf );
  if( rcode ) {
    Serial.print("USB ERROR: "); Serial.println( rcode );
    while (1);
  Serial.print("VID: 0x"); Serial.print(buf.idVendor, HEX);
  Serial.print(" PID: 0x"); Serial.println(buf.idProduct, HEX);

  lcd.print("VID: "); lcd.print(buf.idVendor, HEX);
  lcd.print("PID: "); lcd.print(buf.idProduct, HEX);
  while (1);

That's it! When the ADK is powered it will display:

Plug in something that will enumerate, into the USB port, and you'll see the HEX code for VID and PID

This guide was first published on Aug 25, 2015. It was last updated on Aug 25, 2015.

This page (Let's do this thing) was last updated on Aug 25, 2015.

Text editor powered by tinymce.