0

I am trying to read Barcode Reader data over serial using Raspberry Pi and then print it on 16*2 LCD Display. I was able to read the barcode data but when i tried to print it on LCD display it doesn't print the data on display.

I tried to display int number, float and strings and it is displaying everything except Barcode Data. Can someone help. Thanks

The code that i tried is given below:

    import serial
    import string
    import RPi.GPIO as gpio
    import time
    import Adafruit_CharLCD as LCD

    port = "/dev/ttyAMA0" 
    ser = serial.Serial(port, baudrate = 9600, timeout = 0.5)

    lcd_rs = 25
    lcd_en = 24
    lcd_d4 = 23
    lcd_d5 = 17
    lcd_d6 = 18
    lcd_d7 = 22
    lcd_backlight = 2

    lcd_columns = 16
    lcd_rows = 2

    lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, 
    lcd_backlight)

    while 1:

      data = ser.readline()
      print(data)
      lcd.message("Barcode:")
      lcd.message(str(data))
    time.sleep(2)       

The data that i am getting from Barcode reader is in Bytes and i need to conver it to String. So i used byte.decode("utf-8") and then tried to display it on LCD but no Luck.

can anyone tell me how can i convert Bytes to String. Thanks

Ashish
  • 1
  • 2

0 Answers0