USB RS232 Barcode Scanner with SparkFun USB shield

Hi

I'm trying to make my arduino run a code once it's recognizing certain input from a barcode scanner

I'm able to get a "Ready" from the HID code in the serial monitor, but no input :frowning: :frowning: :frowning:

USB RS232 Barcode Scanner

Sparkfun USB shield

What am I missing here?

(deleted)

Sorry :slight_smile:

Here is the code:

It is the example code of USB HID Boot Keyboard

There is no wiring as it is a USB Shield, except connecting reset to digital 7 on the USB shield.

(deleted)

oh sorry
My part of the code is not yet written until I can verify I'm getting working serial input from the barcode scanner.

Once that happens I'll add a simple servo engine activation code

I suggest testing the shield using a USB keyboard to make sure it works. Post everything that comes out of the serial console.

Hi :slight_smile:

The code works perfectly on a standard keyboard
I'm getting the ascii values of the key strokes:

Start
DN      >04<     
ASCII: a
UP      >04<     
DN      >04<     
ASCII: a
UP      >04<     
DN      >04<     
ASCII: a
UP      >04<     
DN      >17<     
ASCII: t
UP      >17<     
DN      >0A<     
ASCII: g
UP      >0A<     
DN      >0B<     
ASCII: h
UP      >0B<     
DN      >0A<     
ASCII: g
UP      >0A<     
DN      >0A<     
ASCII: g
UP      >0A<     
DN      >16<     
ASCII: s
UP      >16<     
DN      >15<     
ASCII: r
UP      >15<     
DN      >1A<     
ASCII: w
UP      >1A<     
DN      >13<     
ASCII: p
UP      >13<     
DN      >33<     
ASCII: ;
UP      >33<     
DN      >0E<     
ASCII: k
UP      >0E<     
DN      >10<     
ASCII: m
UP      >10<     
DN      >05<     
ASCII: b
UP      >05<     
DN      >06<     
ASCII: c
UP      >06<

on the barcode scanner I'm not getting anything :frowning:

See if this patch helps.

nope, doesn't help :frowning:

Any ideas? I'm at loss here

Verify the VUSB pin at the USB connector is providing 5V. Some shields output only 3.3V which might work for low power device such as keyboards but not barcode readers.

Barcode readers can drawn hundreds of mA. The other possibility is 5V souce is not providing enough current for the barcode reader. One option is to power the Arduino using a powered USB hub. Another option is to power the Arduino using the barrel connector with 7-12V DC.

the barcode seems to be working, though I will check the voltage tomorrow once I have access to voltmeter

ALSO!
I thought maybe regular HID code doesn't apply to barcode scanners. this the USB HID code:

This is a code that adapted an old version of the USB HID to work with barcode scanners, but I can't implement it now, probably due to updates. It also doesn't respond at all.

found here:
https://www.circuitsathome.com/mcu/connecting-barcode-scanner-arduino-usb-host-shield/

May be that can be a lead?

Use this library with the USB Host shield. It can be installed using the IDE library manager.

Use the USBHIDBootKbd example.

Does you scanner work when plugged into a PC? You should be able to open an editor and scan codes directly into the editor. If not, the scanner does not emulate a USB keyboard.

I have used 2 different barcode scanners with the USBHIDBootKbd example and they both work.

Run the example USB_desc example and post the console output.