Hi,
I am trying to connect a barcode scanner (iBall LS-392) to Arduino UNO through a USB Host Shield.
I've successfully connected it and got the following HID_desc:
Start
0000: 05 01 09 06 A1 01 05 07 19 E0 29 E7 15 00 25 01
0010: 75 01 95 08 81 02 95 01 75 08 81 01 95 03 75 01
0020: 05 08 19 01 29 03 91 02 95 05 75 01 91 01 95 06
0030: 75 08 15 00 26 FF 00 05 07 19 00 2A FF 00 81 00
0040: 09 00 95 10 75 08 B1 00 C0
Usage Page Gen Desktop Ctrls(01)
Usage Keypad
Collection Application
Usage Page Kbrd/Keypad(07)
Usage Min(E0)
Usage Max(E7)
Logical Min(00)
Logical Max(01)
Report Size(01)
Report Count(08)
Input(00000010)
Report Count(01)
Report Size(08)
Input(00000001)
Report Count(03)
Report Size(01)
Usage Page LEDs(08)
Usage Min(01)
Usage Max(03)
Output(00000010)
Report Count(05)
Report Size(01)
Output(00000001)
Report Count(06)
Report Size(08)
Logical Min(00)
Logical Max(FF00)
Usage Page Kbrd/Keypad(07)
Usage Min(00)
Usage Max(FF00)
Input(00000000)
Usage
Report Count(10)
Report Size(08)
Feature(00000000)
End Collection
which says it is a Keyboard.
But when I load USBHIDBootKbd, it does not show any data on Serial Monitor after scanning. (Also, it beeps differently after scanning than the way it does when it is connected to PC).
I tried connecting a simple keyboard to the shied which works perfectly fine.
Also I am supplying power to Arduino UNO through external 9V supply. (In case if power is an issue.)
**Scanner works fine when connected to PC, so it is not faulty either.
Hardware I am using:
Arduino UNO.
UHS mini V2 Shield.
LS-392 iBall Scanner.
Library:
USB Host Shield V2.0
Found best solution here:
opened 03:42AM - 22 Oct 17 UTC
closed 01:17PM - 27 Oct 17 UTC
Hi guys, I'm trying to connect my barcode scanner to Arduino using the USB Host … Shield. I've followed tutorial from [circuit@home](https://www.circuitsathome.com/mcu/connecting-barcode-scanner-arduino-usb-host-shield/), and there it said :
> To make sure a device is indeed a boot keyboard, take a look at device descriptors using USB_Desc example from USB Host library – a sample output is given below. Class, Subclass, Protocol in interface descriptor (lines 29-31) should be 03, 01, 01. If Subclass is zero, boot protocol is not supported. Non-boot scanner is still useful but accessing it is going to be slightly more complicated. I will cover HID report protocol in one of the next articles.
Fortunately, my barcode scanner has `Intf. Class = 03`, `Intf. Subclass = 01` and `Intf. Protocol = 01`, therefore according to the tutorial, my barcode scanner should work using `HID Protocol Keyboard`. However, in practice two of my barcode scanners didn't work, but my wired keyboard worked. The barcode is powered up, but doesn't print anything.
Here is my code :
```c
#include <hidboot.h>
#include <usbhub.h>
#include <SPI.h>
class KbdRptParser : public KeyboardReportParser
{
protected:
virtual void OnKeyDown(uint8_t mod, uint8_t key);
virtual void OnKeyPressed(uint8_t key);
};
void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key)
{
uint8_t c = OemToAscii(mod, key);
if (c) OnKeyPressed(c);
}
void KbdRptParser::OnKeyPressed(uint8_t key)
{
Serial.print("ASCII: ");
Serial.println((char)key);
};
USB Usb;
HIDBoot<USB_HID_PROTOCOL_KEYBOARD> HidKeyboard(&Usb);
KbdRptParser Prs;
void setup()
{
Serial.begin( 115200 );
Serial.println("Start");
if (Usb.Init() == -1) {
Serial.println("OSC did not start.");
}
delay( 200 );
HidKeyboard.SetReportParser(0, &Prs);
}
void loop()
{
Usb.Task();
}
```
Here is my `USB_desc` :
```
Start
01
--
Device descriptor:
Descriptor Length: 12
Descriptor type: 01
USB version: 0200
Device class: 00
Device Subclass: 00
Device Protocol: 00
Max.packet size: 40
Vendor ID: 0483
Product ID: 5750
Revision ID: 0200
Mfg.string index: 01
Prod.string index: 02
Serial number index: 03
Number of conf.: 01
Configuration descriptor:
Total length: 0022
Num.intf: 01
Conf.value: 01
Conf.string: 00
Attr.: C0
Max.pwr: 64
Interface descriptor:
Intf.number: 00
Alt.: 00
Endpoints: 01
Intf. Class: 03
Intf. Subclass: 01
Intf. Protocol: 01
Intf.string: 00
Unknown descriptor:
Length: 09
Type: 21
Contents: 10010001222D000705
Endpoint descriptor:
Endpoint address: 81
Attr.: 03
Max.pkt size: 0008
Polling interval: 01
Addr:1(0.0.1)
```
And here is my `USBHID_desc` :
```
Start
0000: 05 01 09 06 A1 01 95 08 75 01 05 07 19 E0 29 E7
0010: 15 00 25 01 81 02 95 01 75 08 81 01 95 06 75 08
0020: 15 00 25 FF 05 07 19 00 29 FF 81 00 C0
Usage Page Gen Desktop Ctrls(01)
Usage Keypad
Collection Application
Report Count(08)
Report Size(01)
Usage Page Kbrd/Keypad(07)
Usage Min(E0)
Usage Max(E7)
Logical Min(00)
Logical Max(01)
Input(00000010)
Report Count(01)
Report Size(08)
Input(00000001)
Report Count(06)
Report Size(08)
Logical Min(00)
Logical Max(FF)
Usage Page Kbrd/Keypad(07)
Usage Min(00)
Usage Max(FF)
Input(00000000)
End Collection
```
I am successful in getting barcode of serial monitor using below link.
opened 03:42AM - 22 Oct 17 UTC
closed 01:17PM - 27 Oct 17 UTC
Hi guys, I'm trying to connect my barcode scanner to Arduino using the USB Host … Shield. I've followed tutorial from [circuit@home](https://www.circuitsathome.com/mcu/connecting-barcode-scanner-arduino-usb-host-shield/), and there it said :
> To make sure a device is indeed a boot keyboard, take a look at device descriptors using USB_Desc example from USB Host library – a sample output is given below. Class, Subclass, Protocol in interface descriptor (lines 29-31) should be 03, 01, 01. If Subclass is zero, boot protocol is not supported. Non-boot scanner is still useful but accessing it is going to be slightly more complicated. I will cover HID report protocol in one of the next articles.
Fortunately, my barcode scanner has `Intf. Class = 03`, `Intf. Subclass = 01` and `Intf. Protocol = 01`, therefore according to the tutorial, my barcode scanner should work using `HID Protocol Keyboard`. However, in practice two of my barcode scanners didn't work, but my wired keyboard worked. The barcode is powered up, but doesn't print anything.
Here is my code :
```c
#include <hidboot.h>
#include <usbhub.h>
#include <SPI.h>
class KbdRptParser : public KeyboardReportParser
{
protected:
virtual void OnKeyDown(uint8_t mod, uint8_t key);
virtual void OnKeyPressed(uint8_t key);
};
void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key)
{
uint8_t c = OemToAscii(mod, key);
if (c) OnKeyPressed(c);
}
void KbdRptParser::OnKeyPressed(uint8_t key)
{
Serial.print("ASCII: ");
Serial.println((char)key);
};
USB Usb;
HIDBoot<USB_HID_PROTOCOL_KEYBOARD> HidKeyboard(&Usb);
KbdRptParser Prs;
void setup()
{
Serial.begin( 115200 );
Serial.println("Start");
if (Usb.Init() == -1) {
Serial.println("OSC did not start.");
}
delay( 200 );
HidKeyboard.SetReportParser(0, &Prs);
}
void loop()
{
Usb.Task();
}
```
Here is my `USB_desc` :
```
Start
01
--
Device descriptor:
Descriptor Length: 12
Descriptor type: 01
USB version: 0200
Device class: 00
Device Subclass: 00
Device Protocol: 00
Max.packet size: 40
Vendor ID: 0483
Product ID: 5750
Revision ID: 0200
Mfg.string index: 01
Prod.string index: 02
Serial number index: 03
Number of conf.: 01
Configuration descriptor:
Total length: 0022
Num.intf: 01
Conf.value: 01
Conf.string: 00
Attr.: C0
Max.pwr: 64
Interface descriptor:
Intf.number: 00
Alt.: 00
Endpoints: 01
Intf. Class: 03
Intf. Subclass: 01
Intf. Protocol: 01
Intf.string: 00
Unknown descriptor:
Length: 09
Type: 21
Contents: 10010001222D000705
Endpoint descriptor:
Endpoint address: 81
Attr.: 03
Max.pkt size: 0008
Polling interval: 01
Addr:1(0.0.1)
```
And here is my `USBHID_desc` :
```
Start
0000: 05 01 09 06 A1 01 95 08 75 01 05 07 19 E0 29 E7
0010: 15 00 25 01 81 02 95 01 75 08 81 01 95 06 75 08
0020: 15 00 25 FF 05 07 19 00 29 FF 81 00 C0
Usage Page Gen Desktop Ctrls(01)
Usage Keypad
Collection Application
Report Count(08)
Report Size(01)
Usage Page Kbrd/Keypad(07)
Usage Min(E0)
Usage Max(E7)
Logical Min(00)
Logical Max(01)
Input(00000010)
Report Count(01)
Report Size(08)
Input(00000001)
Report Count(06)
Report Size(08)
Logical Min(00)
Logical Max(FF)
Usage Page Kbrd/Keypad(07)
Usage Min(00)
Usage Max(FF)
Input(00000000)
End Collection
```
However, could anyone please tell me that is it possible that on a specific barcode value i want my arduino to run specific steps to stepper motor. how to do that?
i bought this barcode scanner :mh-et live scanner v3
after i run USBHID_desc
my serial monitor Received alien code...