Barcode scanner


I’m trying to make a barcode scanner with an electric IMP module
Do you know if this one : works with electric IMP ?

If so, do you know how to configure the pin ?
I tried lot’s of different configurations, but i didn’t succeed so far.

Thank you.

That’s just a pure analog transmitter and receiver. You may be better off getting a serial scanner from ebay and hooking that up to the imp (may need a level shifter)

How about something like this?

Is laser required/preferred (Honeywell type) for your purposes or could an image-based scanner be used as I know there are 3v3 options available and many would also provide a simpler serial comms interface, otherwise usb host shield/module may also be required. I believe Zebra Technologies offer a few 3v3 OEM image based options which may be worth investigating (thereby avoiding level shifter interface).

Sorry for the delay, i didn’t saw your answers.

Thank you very much for your help. It helps me a lot.
Based on your recommandation (serial scanner) i found this one :
But i can’t make it works with Electric Imp as the barcode communicate over RS-232.

I’m using this converter ( to translate RS232 to TTL and use the TXD output of the converter with an UART pin of electricimp 002. Unfortunatly, it doesn’t works : i have random values everytime i scan the same barcode, although i’m sure the parameter “baudRate, wordSize, parity & stopBits” are well configured.

Did i missed something ?
How can we communicated with electric imp from RS-232 to UART ?

@mlseim : i think i would have the same issue with the ones you recommend ( as they have USB or PS2 output (need to be converted as well).

Thank you for you help.

Heh, annoyingly it seems the module actually outputs the right signal for an imp (TTL levels would be ok) but then it runs it through a converter on the baseboard to get to real RS232 levels :slight_smile:

It should be fine - seems like it’s 9600bps. Can you take a picture of your setup and attach your code?

eg this should work:

`uart <- hardware.uart1289;
line <- "";

// Accumulate data into a line, print it when we have a whole one
function handler() {
  local b =;
  while(b >= 0) {
    if (b == 0x0d) {
      server.log("received: "+line);
      line = "";
    } else {
      line += b.tochar();
    b =;

// Configure uart
uart.configure(9600, 8, PARITY_NONE, 1, NO_CTSRTS, handler);

(edit: added the missing flags field)

Oh so the signal is converted twice !

Thank you for you code. Yes the barcode is sending : 9600bps, 8 data bits, 1 stop bit, no parity, no handshaking (NO_CTSRTS)

I did my test in 4 different situation :

1/ Without any converter, imp directly connected to the pin 2 of RS232
Setup :
General view
Zoom on RS232 (pin 2, RDX)
Code & log :
I got some data out (14 line = 13 digits on the barcode + carriage return), but the numbers change from one barcode to another. There is no correspondance we can establish.

2/ With a converter, with a male to male DB9 plug.
Setup :
General view
Zoom on the converter board (RX pin connected to imp)
I got NO data at all (same code, no log).

3/ With a converter, manually connecting PIN-2 of the 2 DB9 plugs (RS323)
Setup : No current is passing through the power supply line of the breadboard
Code & Log :
I got some weird log : it change every time i scan the SAME barcode

4/ With a converter, manually connecting PIN-2 of the 2 DB9 plugs and a power supply of +5VCC injected thought PIN 5 and PIN9
Setup :
+5 VCC is passing through the power supply line of the breadboard
Zoom on DB9 plug
Zoom on TTL converter to imp
Code :
I got the same result as the configuration 3.

Actually the situation 1 seems the best one, even if it makes no sense to connect directly RS232 to TTL logic.

Here is the reference of the hardware i use :

I also have a RS-232 to USB converter, do you think it would be easier to connect an imp002 to a USB plug ?

Do you think i need to change the hardware for an other reference ?

Thank you very much for you help.

You may well have blown up the imp pin with your test number (1). RS232 is +/- 5v or higher, depending on the buffer being used, which is out of range for the imp pins.

In picture 2, you have not connected power to the converter board. You need to attach VCC to 3.3v and GND to GND as well as connecting the data line to pin 9 on the imp.

Picture 3/4 are just wrong. Power goes in on the breadboard side to the converter. You cannot supply power to the converter via the DB9 interface. The GND of the supply must be attached to the GND of the imp, so it’s generally best just to attach the VCC/GND of the converter to the 3.3v/GND of the imp breakout.

Summary: you must use a converter. You must also power the converter (from 3.3v) and ensure that the ground reference is the same as the imp.


Here is an update about the tests i did.
Thank you again for your precious help. It seems that i was doing all wrong !

I followed your advices : i power the converter with 3.3v from the imp and the ground reference is now the same as the imp. I also tried with an other imp (April card) as you suggested that my previous tests might have destroy the imp.

Even with a fresh new imp, it doesn’t works better.
It seems that the barcode works well : connecting the DB9 plug to a led show activity on RX pin.

My conclusion is that the RS232 to TTL converter is broken (maybe because of my previous tests). I’m waiting the delivery of a fresh new RS232 to TTL converter. As soon as i receive it, i will post update.

Thank you.