Interface barcode scanner with arduino yun

Dear All,

I wish to interface my USB type barcode scanner with arduino yun board and for the every scan the scanned value should be shown on the serial monitor. This is my task.

I'm not able to find any HID USB interfacing examples for Arduino Yun board in the software. If any body guide me to reach the goal, that will be very useful. If any body have the sample code for HID concept, please share.


Hope this link will help you

But the concept of Arduino yun is different from all other. It uses brige concept na. If you find any other links or reference, please let me know.


opkg update
opkg install kmod-hid
opkg install kmod-input-evdev
opkg install kmod-input-core
opkg install kmod-usb-hid
ls -l /dev/input/
crw-r--r--    1 root     root       13,  64 Jan  1  1970 event0
crw-r--r--    1 root     root       13,  65 Oct 18 06:27 event1

The barcode scanner is at


Now we need compile c program "barcode"

download it from here:

 /mnt/sda1/barcode  /dev/input/event1
Reading From : /dev/input/event1 (WIT Electron Company WIT 122-UFS V2.03)

Caution Yun USB only give out ~4.5V power supply, use powered USB hub!

All above is about 1D barcode, but it starts fade out.

2D barcode is hot cake now, Opencv and video camera is needed for 2D barcode...

Dear Mr.Sonnyyu,

Thanks a lot for the details. I can understand your coding steps. But I do not know the way to impliment the same. Hence I'm new to both arduino yun and linux and this is my first try in this board, even I understand its bridge concepts, it's programming ways are confusing me a lot. Kindly bear and please explain the way to do this in step by step manner. From where I have to execute "opkg update" command. What are all the hardware connection I need at that time.


When I try to install "kmod-hid" using - opkg install command, getting error message.

root@Arduino:/# opkg install kmod-hid
Unknown package 'kmod-hid'.
Collected errors:

  • opkg_install_cmd: Cannot install package kmod-hid.

What I have to do. Should I have to place any file in SD card or should I have to upload any files to processor. If it is, please share the way.


You missed to run the first command sonnyyu wrote

opkg update

I tried it.

root@Arduino:/# opkg update
Signature check failed.
Remove wrong Signature file.
Collected errors:

Updation is failed. How to solve this.

Maybe the Yun is not connected or the server was down. As you can read it fails to download files.
Check the internet connection and retry

Anybody please confirm my hardware set up is right?

Connected PC and arduino via USB. Loaded ipk files in SD card card which is inserted in Arduino Yun. Established internet connection in PC.

If I were you, I will connect ethernet cable between router and Yun.

I can understand your words.

Please clarify my doubt. Is there any way to do "opkg update" without internet connection? Is it possible to download the required packages to SD card? and Can we update the opkg with this files in SD card?

Because in my current set up, I'm using Reliance Dongle for my internet connection. It is like pen drive and I do not have any router set up. That's why I'm looking for a alternate idea.

opkg will install the packages from the sd card if you give the full path/file name, something like:

opkg install /mnt/sda1/kmod-hid_3.3.8-1_ar71xx.ipk

You need to satisfy the dependencies yourself, for instance you would need to download and install these first:

opkg install /mnt/sda1/kmod-input-core_3.3.8-1_ar71xx.ipk
opkg install /mnt/sda1/kmod-input-evdev_3.3.8-1_ar71xx.ipk

Getting error while installing kmod-input-core.

root@Arduino:/# opkg install /mnt/sda1/kmod-input-core_3.3.8-1_ar71xx.ipk


Installing kmod-input-core (3.3.8-1) to root...
Collected errors:

  • satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-input-core:
  • kernel (= 3.3.8-1-bd655b187e04910d9917973d44f685fb) *
  • opkg_install_cmd: Cannot install package kmod-input-core.


I upgraded arduino yun to the latest image.

Below is my kernel details.

root@Arduino:/# opkg list | grep ^kernel
kernel - 3.3.8-1-openwrtyun1

How to solve this kernel error?

Internet Connection Sharing

Thanks for the details Mr.Sonnyyu.

Finally I installed the files from my SD card and now I connected one USB mouse with yun. It is detected and shown at event 1 as mentioned by you .

Now I want to detect the mouse click. This means if I click the right mouse button, right button clicked message should be displayed in terminal. How can I do this.

In your sample, you showed a C program. Pls let me know the compiler and editor details.

I'm little confused. C or Phython which is better to write these programs. Should I have to install any compiler softwares in linux processor?