Skip to content
Buy 10+ on select items — save 10% auto-applied
Free US shipping on orders $35+
Order by 3pm ET — ships same-day from the US
Skip to main content

Arduino MAX3421E USB Host Shield: Read USB Barcodes | ShillehTek

May 15, 2026 32 views

Arduino MAX3421E USB Host Shield: Read USB Barcodes | ShillehTek
Project

Build an Arduino MAX3421E USB Host Shield project that reads a USB HID barcode scanner and prints each scan to Serial for easy inventory input with ShillehTek.

30 min Intermediate3 parts

Project Overview

Arduino + MAX3421E USB Host Shield barcode reader: Build an Arduino project that reads a USB HID-mode barcode scanner through a MAX3421E USB Host Shield and prints each scan to the Serial Monitor.

Most Arduino boards can talk to peripherals over UART, SPI, and I2C, but not USB host. The MAX3421E changes that by turning your Arduino into a USB host so it can read USB keyboards, gamepads, and (most importantly here) USB barcode scanners.

  • Time: ~30 minutes
  • Skill level: Intermediate
  • What you will build: An Arduino reading scanned barcodes from a USB barcode scanner and printing them to Serial.
Arduino connected to a MAX3421E USB Host Shield reading a USB barcode scanner
USB Host Shield + barcode scanner + Arduino = stand-alone barcode reader.

Parts List

From ShillehTek

External

  • USB HID-mode barcode scanner (many low-cost scanners ship in HID keyboard mode)
  • 5 V power supply (optional, if the scanner draws more current than your setup can provide)

Note: The MAX3421E itself is 3.3 V; the breakout includes a regulator so it can be powered from 5 V.

Step-by-Step Guide

Step 1 - Inspect the MAX3421E USB Host Shield

Goal: Identify the USB connector and the SPI/control pins you will wire to the Arduino.

What to do: Locate the USB-A port (for the barcode scanner) and the SPI breakout pins on the shield/module. Confirm the board layout matches the pin labels you will use for wiring.

Top view of a MAX3421E USB Host Shield showing the USB-A port and MAX3421E IC
USB-A jack on top, MAX3421E IC, SPI breakout on the side.
MAX3421E mini USB Host Shield stacked on an Arduino Pro Mini style footprint
Mini Host Shield form factor designed to sit on top of a Pro Mini footprint.

Expected result: You know where to plug in the USB barcode scanner and which pins will be wired for SPI, CS, and interrupts.

Step 2 - Wire the shield to the Arduino (SPI + control lines)

Goal: Connect power, SPI, chip select, and interrupt so the Arduino can communicate with the MAX3421E.

What to do: Make the following connections between your Arduino and the MAX3421E module. Use the SPI pins appropriate for your Arduino board.

Wiring diagram showing an Arduino connected to a MAX3421E USB Host Shield over SPI with CS and INT
SPI plus CS, RST, GPX, and INT signals (exact set depends on your board and library defaults).
  • VCC to 5 V, GND to GND
  • MOSI / MISO / SCK to the Arduino SPI pins
  • SS / CS to D10 (or whichever CS the library expects)
  • INT to D9

Expected result: The Arduino is physically connected to the MAX3421E for SPI communication and interrupt signaling.

Step 3 - Install the USB Host Shield Library 2.0

Goal: Add the required Arduino library and confirm the example sketches are available.

What to do: Install USB Host Shield Library 2.0 by Oleg Mazurov using the Arduino Library Manager. Then browse to File → Examples → USB Host Shield Library 2.0 → HID → USBHIDBootKbd.

Expected result: You can open the HID keyboard example sketch, which is the basis for reading a HID-mode barcode scanner.

Step 4 - Upload the barcode scanner (HID keyboard) sketch

Goal: Run firmware that treats the USB barcode scanner as a USB HID keyboard and prints characters to Serial.

What to do: Use the sketch below. A USB barcode scanner in HID mode behaves like a keyboard. This code prints each character as it arrives and prints a newline when the Enter key (0x28) is received, which commonly terminates a barcode scan.

Code:

#include <hidboot.h>
#include <usbhub.h>

USB Usb;
HIDBoot<USB_HID_PROTOCOL_KEYBOARD> kbd(&Usb);

class KbdRptParser : public KeyboardReportParser {
  void OnKeyDown(uint8_t mod, uint8_t key) override {
    uint8_t c = OemToAscii(mod, key);
    if (c) Serial.write(c);
    if (key == 0x28) Serial.println();   // Enter ends a barcode
  }
};
KbdRptParser P;

void setup() {
  Serial.begin(115200);
  if (Usb.Init() == -1) { Serial.println("USB init failed"); while (1); }
  kbd.SetReportParser(0, &P);
}

void loop() { Usb.Task(); }

Expected result: The sketch uploads successfully, initializes USB, and is ready to accept scanner input.

Step 5 - Scan a barcode and verify serial output

Goal: Confirm that scans appear as text in the Serial Monitor.

What to do: Plug the barcode scanner into the USB-A port on the host shield. Open the Serial Monitor at 115200 baud, then scan a barcode.

Arduino Serial Monitor output showing barcode text received from a USB HID barcode scanner through MAX3421E
Each barcode prints as a complete line.

Expected result: The scanned barcode prints to the Serial Monitor, with each barcode ending on a new line.

Step 6 - Extend the project

Goal: Use the scanned barcode data in a real application.

What to do: Build on the working serial output by integrating the barcode string into your own logic.

  • Look up the barcode in a local product database stored on microSD
  • POST the barcode to a Wi-Fi-attached inventory server
  • Replace the barcode scanner with a USB keyboard for command input
  • Read USB gamepads to control RC cars / robots

Expected result: You have a clear next direction for turning barcode input into inventory, kiosk, or control workflows.

Conclusion

The MAX3421E USB Host Shield expands Arduino projects to support USB host peripherals, including USB HID-mode barcode scanners. With the wiring complete and the HID keyboard example running, your Arduino can capture barcode scans and print them to Serial as complete lines.

Want the exact parts used in this build? Grab them from ShillehTek.com. If you want help customizing this project or building inventory or kiosk firmware for your product, check out our IoT consulting services.