Barcode scanner

Hi everyone!

I need help for a project i'm working on, involving a barcode scanner.
I'm using an Arduino Uno, an USB host shield, and a Manhattan 177672. But i don't receive any data, even if it is suposed to be like a keyboard.

The scanner is recognized : if i launch USB_desc i get :

Intf. Class:		03
Intf. Subclass:		01
Intf. Protocol:		01

which means, if i understand well, it should be like a keyboard.

But if i launch USBHUD_desc, i get this :

Start
0000: 06 00 FF 09 01 A1 01 19 00 29 FF 15 00 25 FF 95
0010: 01 75 08 81 02 19 00 29 FF 15 00 25 FF 95 01 75
0020: 08 91 02 C0
Usage Page Undef(00)
Usage
Collection Application

I don't understant the first two lines, but the usage page undef means it is not a keyboard but... a thing.

Interesting infos :

  • the scanner is set on USB mode. There is a keyboard mode, but then the Arduino does not even recognize the device
  • when the scanner is plugged on my PC, it makes a beep when scanning. When plugged to the Arduino, it makes the same beep, then another beep one second later, probably to say it is not happy. I think it is waiting for an feedback it doesn't have.

Sorry for my english BTW!

Assuming this is the scanner then the manual also says it has a RS232 mode that may make life easier.
If you plug the scanner into your PC with it set to keyboard mode, open a new text file for editing and scan a barcode the barcode number should be injected into the text editor (assuming it had focus when you scanned the barcode). If this does not work then maybe you have not configured the scanner correctly.

When your using the USB host shield is its sketch configured to work as a HID device?

Thank you Riva.

When i set the scanner to keyboard mode, it works indeed on my computer like a keyboard. So the problem is probably not the setting of the scanner.

If i want to use RS232 mode, i need a max232, correct? And then there is a simple way to read infos from the scanner then? I have never done that.

houile:
When i set the scanner to keyboard mode, it works indeed on my computer like a keyboard. So the problem is probably not the setting of the scanner.

This makes me think you have not got the Arduino USB host shield setup correctly as a HID keyboard device.
What shield & libraries are you using?

houile:
If i want to use RS232 mode, i need a max232, correct? And then there is a simple way to read infos from the scanner then? I have never done that.

I think RS232 mode still uses the USB connector but it sends barcode numbers using the serial protocol. You would need to setup your USB host shield with SSP (simple serial protocol) drivers. No need for a MAX232 chip.

I am using an official Arduino USB Host Shield R3, with USB Host Shield Library 2.0

What do you mean by setting up the host shield? I am running tests with the examples scripts from the library so i guess all the setups are correct. I am missing something here?
I tried to plug my keyboard instead of the scanner, and i receive information each time i press a key.

About the RS232, i was thinking about a cheap usb to ttl convertor, which could avoid using the host shield. You are right, the connector is UBS anyway on this model.

houile:
What do you mean by setting up the host shield? I am running tests with the examples scripts from the library so i guess all the setups are correct. I am missing something here?
I tried to plug my keyboard instead of the scanner, and i receive information each time i press a key.

Are you running the USBHIDBootKbd.ino sketch to do this or some other sketch?

houile:
About the RS232, i was thinking about a cheap usb to ttl convertor, which could avoid using the host shield. You are right, the connector is UBS anyway on this model.

A USB2TTL converter will not work as it is designed to plug into a host. The barcode scanner is most likely a slave device.

I wrote in my first post the sketch i'm using : USB_desc and USBHID_desc
As it is not regognized as a HID keyboard, nothing happen when i use USBHIDBootKbd

houile:
I wrote in my first post the sketch i'm using : USB_desc and USBHID_desc
As it is not regognized as a HID keyboard, nothing happen when i use USBHIDBootKbd

From your first post...

Intf. Class: 03
Intf. Subclass: 01
Intf. Protocol: 01

This means it's a HID, Boot Interface Subclass, Keyboard Protocol.
Do/did you load drivers on the PC to get the scanner working in keyboard mode?
If you have the USBHIDBootKbd.ino example loaded, the scanner programmed as keyboard mode and plugged into the USB host shield then it should work.

I did not have to load any driver to make it work on the computer.

I know it doesn't make any sense, that's why i'm puzzled.

USB_desc tells me its a HID, Boot Interface Subclass, Keyboard Protocol, but USBHID_desc does not see it as a keyboard :

Start
0000: 06 00 FF 09 01 A1 01 19 00 29 FF 15 00 25 FF 95 
0010: 01 75 08 81 02 19 00 29 FF 15 00 25 FF 95 01 75 
0020: 08 91 02 C0 
Usage Page Undef(00)
Usage
Collection Application
Usage Min(00)
Usage Max(FF)
Logical Min(00)
Logical Max(FF)
Report Count(01)
Report Size(08)
Input(00000010)
Usage Min(00)
Usage Max(FF)
Logical Min(00)
Logical Max(FF)
Report Count(01)
Report Size(08)
Output(00000010)
End Collection

If i scan something i get 2 beep sounds (instead of 1 with my computer) and nothing is diplayed in the serial monitor with USBHID_desc neither with USBHIDBootKbd

Sorry houile but this is looks like it's beyond my knowledge of USB, maybe someone else can step in and save the day.

It's OK Riva, a friend helped me finding the solution without using the USB shield.

The RS232 mode was easier indeed. I removed the plug, and found a RJ45 10 pins connector. It was easy to find ground and +5V using the original usb cable. I just had to test the remaining wires on a regular RJ45 cable to find the TX, and then connect it to an RX of my Mega board.

I have the feeling it should not work (because the voltage is not the same) but it does, with a simple Serial.read()

houile:
I have the feeling it should not work (because the voltage is not the same) but it does, with a simple Serial.read()

It would be a lot safer to use a RS232 to TTL converter to ensure the Arduino pins are not damaged but glad you got it working in the end.