0

Im having some issues reading from a barcode scanner module.. The scanner works just fine if it is used with a USB adapter, my goal is to use the RX & TX GPIO of my RPi to control it.

What I am trying to do is something similar to this:

https://www.rtscan.net/raspberry-pi-barcode-scanner/

My problem is that I am not getting any data after scanning the barcodes.

This is what I have done so far:

  1. I have the configured the ttyS0 on my RPi.
  2. I can see ttyS0 if I do ls /dev -l
  3. cat /dev/ttyS0 - opens a connection, not getting I/O error
  4. Ive scanner RX (IN) connected to RPI TX (Out)
  5. Ive scanner TX (OUT) connected to RPI RX (IN)
  6. wrote small python file to read and write info on the screen:
import serial
import time 

port = serial.Serial('/dev/ttyS0')
#port.baudrate=9600
while True:
    port.write("Say something:\n")
    rcv = port.read(10)
    port.write("rnYou sent:" + repr(rcv))
    time.sleep(0.10)

Any ideas on what I might be missing?

  • So your program in Step 7 does not seem to work. I would suggest two things: (1) Modify your program to do a loopback test, to make sure the wiring etc is OK. (2) Instead of the python program, use a terminal emulator (I would recommend SuperTerm, as recommended by SparkFun), to input something, say "AT<new Line>" to the barcoder, and see if there is something back, hopefully "OK <newline>. If your have something in something out, then it is time to run your python program. If you have no experience on testing UART loop back, let me know and I can show you a newbie version. – tlfong01 Sep 7 '19 at 1:59
  • you might find my answer to a similar question helpful: raspberrypi.stackexchange.com/questions/102239/… – tlfong01 Sep 7 '19 at 2:01
  • @tlfong01, I don't have any experience on testing UART.. my main issue is that I am not getting any data when scanning the barcodes.. – MrServer Sep 7 '19 at 3:25
  • Ah, let me see. I remember another barcode hobbyist asked the same question and my answer seems to have helped him. raspberrypi.stackexchange.com/questions/96562/… – tlfong01 Sep 7 '19 at 3:35
  • Your might to let me know more about your setup, such as which model are your using, do you use the Rpi UART pins, or a USB serial cable etc. Another answer might also help. raspberrypi.stackexchange.com/questions/96232/… – tlfong01 Sep 7 '19 at 3:44
0

Thank you tlfon01, you pointed me on the right direction. I ended up solving this problem by disabling the BT, and using ttyAMA0 instead of ttyS0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.