# Simple Arduino-based USB VID & PID tester

## Let's do this thing

Danger: This older guide uses an Arduino board no longer in production. It is suggested you follow the modern guide [HID Reporter](https://learn.adafruit.com/hid-reporter) for building new projects.

![](https://cdn-learn.adafruit.com/assets/assets/000/027/386/medium800/projects_vidpid.jpg?1440522558)

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&nbsp; stand-alone tester!

# Ingredients

- [You'll need an Arduino with a USB host shield, I just used an Arduino ADK.](https://www.adafruit.com/product/563)

![](https://cdn-learn.adafruit.com/assets/assets/000/027/381/medium800/projects_x563-00.jpg.pagespeed.ic.ApkGws5akh.jpg?1440522349)

You'll also want some sort of display,&nbsp;[such as a plain](https://www.adafruit.com/product/772) or [RGB 16x2 LCD shield](https://www.adafruit.com/products/716) kit. Be sure to follow the product tutorial to assemble

![](https://cdn-learn.adafruit.com/assets/assets/000/027/382/medium800/projects_716-08.jpg?1440522370)

# 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:

```auto
// 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.setBacklight(0x7);
  lcd.print("USB VID/PID Test");
  lcd.setCursor(0,1);
  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) {
    Usb.Task();
  
    if( Usb.getUsbTaskState() == USB_STATE_RUNNING ) break;
  }
  uint8_t rcode = 0;
  byte num_conf = 0;

  USB_DEVICE_DESCRIPTOR buf;
  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.clear();
  lcd.print("VID: "); lcd.print(buf.idVendor, HEX);
  lcd.setCursor(0,1);
  lcd.print("PID: "); lcd.print(buf.idProduct, HEX);
  
  Serial.println("***Done!***");
  
  while (1);
}
```

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

![](https://cdn-learn.adafruit.com/assets/assets/000/027/384/medium800/projects_waiting.jpg?1440522476)

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

![](https://cdn-learn.adafruit.com/assets/assets/000/027/385/medium800/projects_vidpid.jpg?1440522511)


## Featured Products

### Arduino Mega R3 Android Accessory Development Kit (ADK) Board

[Arduino Mega R3 Android Accessory Development Kit (ADK) Board](https://www.adafruit.com/product/563)
Fast track your Android phone hardware development or just design cell-phone robots with the Arduino ADK! The Arduino ADK is a microcontroller board based on the powerful ATmega2560 ([datasheet](http://www.atmel.com/dyn/resources/prod_documents/doc2549.PDF)). It has a USB host...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/563)
[Related Guides to the Product](https://learn.adafruit.com/products/563/guides)
### RGB LCD Shield Kit w/ 16x2 Character Display - Only 2 pins used!

[RGB LCD Shield Kit w/ 16x2 Character Display - Only 2 pins used!](https://www.adafruit.com/product/714)
This new Adafruit shield makes it easy to use a 16x2 Character LCD. We really like the RGB LCDs we stock in the shop both the [RGB negative](http://www.adafruit.com/products/399) and [RGB positive](http://www.adafruit.com/products/398). Unfortunately, these LCDs do...

In Stock
[Buy Now](https://www.adafruit.com/product/714)
[Related Guides to the Product](https://learn.adafruit.com/products/714/guides)
### LCD Shield Kit w/ 16x2 Character Display - Only 2 pins used!

[LCD Shield Kit w/ 16x2 Character Display - Only 2 pins used!](https://www.adafruit.com/product/772)
This new Adafruit shield makes it easy to use a 16x2 Character LCD. We really like the [Blue & White 16x2 LCDs we stock in the shop](http://www.adafruit.com/products/181). Unfortunately, these LCDs do require quite a few digital pins, 6 to control the LCD and then another pin to...

In Stock
[Buy Now](https://www.adafruit.com/product/772)
[Related Guides to the Product](https://learn.adafruit.com/products/772/guides)
### RGB LCD Shield Kit w/ 16x2 Character Display - Only 2 pins used!

[RGB LCD Shield Kit w/ 16x2 Character Display - Only 2 pins used!](https://www.adafruit.com/product/716)
This new Adafruit shield makes it easy to use a 16x2 Character LCD. We really like the RGB LCDs we stock in the shop both the [RGB negative](http://www.adafruit.com/products/399) and [RGB positive](http://www.adafruit.com/products/398). Unfortunately, these LCDs do...

In Stock
[Buy Now](https://www.adafruit.com/product/716)
[Related Guides to the Product](https://learn.adafruit.com/products/716/guides)
### Adafruit I2C Controlled + Keypad Shield Kit for 16x2 LCD

[Adafruit I2C Controlled + Keypad Shield Kit for 16x2 LCD](https://www.adafruit.com/product/715)
We really like the range of LCDs we stock in the shop, such as our classic [blue & white](http://www.adafruit.com/products/181) and the fancy [RGB negative](http://www.adafruit.com/products/399) and [RGB positive](http://www.adafruit.com/products/398)....

In Stock
[Buy Now](https://www.adafruit.com/product/715)
[Related Guides to the Product](https://learn.adafruit.com/products/715/guides)

## Related Guides

- [RGB LCD Shield](https://learn.adafruit.com/rgb-lcd-shield.md)
- [Sous-vide controller powered by Arduino - The SousViduino!](https://learn.adafruit.com/sous-vide-powered-by-arduino-the-sous-viduino.md)
- [Arduino "Hunt The Wumpus"](https://learn.adafruit.com/arduino-hunt-the-wumpus.md)
- [Adafruit Capacitive Touch Sensor Breakouts](https://learn.adafruit.com/adafruit-capacitive-touch-sensor-breakouts.md)
- [Trinket RGB Shield Clock](https://learn.adafruit.com/trinket-rgb-shield-clock.md)
- [Adafruit 555 PWM Output STEMMA](https://learn.adafruit.com/adafruit-555-pwm-output-stemma.md)
- [Ninja Timer: Giant 7-Segment Display](https://learn.adafruit.com/ninja-timer-giant-7-segment-display.md)
- [Adabox 001](https://learn.adafruit.com/adabox001.md)
- [Water Drip Dress with Oozemaster 3000](https://learn.adafruit.com/water-drip-dress-with-oozemaster-3000.md)
- [Adafruit RP2040 CAN Bus Feather](https://learn.adafruit.com/adafruit-rp2040-can-bus-feather.md)
- [14-Segment Alpha-numeric LED FeatherWing](https://learn.adafruit.com/14-segment-alpha-numeric-led-featherwing.md)
- [Feather RP2040 DVI Video Synth](https://learn.adafruit.com/feather-rp2040-dvi-video-synth.md)
- [Accessing and Using Adafruit PCB Design Files](https://learn.adafruit.com/accessing-and-using-adafruit-pcb-design-files.md)
- [Adafruit IoT Button with NeoPixel BFF](https://learn.adafruit.com/adafruit-iot-button-with-neopixel-bff.md)
- [Adafruit MCP3421 18-Bit ADC](https://learn.adafruit.com/adafruit-mcp3421-18-bit-adc.md)
