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:
- I have the configured the ttyS0 on my RPi.
- I can see ttyS0 if I do
ls /dev -l
cat /dev/ttyS0
- opens a connection, not getting I/O error- Ive scanner RX (IN) connected to RPI TX (Out)
- Ive scanner TX (OUT) connected to RPI RX (IN)
- 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?