remove weird characters from LCD display

213 views Asked by At

I'm trying to display the pH value from a sensor, for this I have a bash script in which I retrieve the pH value and generate a file with the last pH recorded:

READ=`dd if=/dev/ttyUSB1 count=5 status=none` #Reads pH from USB
echo -n "$READ" > $PWD/.2displaypH.tmp  #Creates file with last pH

Then I use .2displaypH.tmp in a script in python, so I can send it to the 4x20 lcd display:

while True:

        peache = open("/home/pi/Documents/SensorTempRpi/Scripts/.2displaypH.tmp").read()

        lcd.lcd_display_string("Hello", 1)
        lcd.lcd_display_string("pH: %s" %peache, 2)
        lcd.lcd_display_string("Bomba: OFF", 3)
        lcd.lcd_display_string("Enfriador: ON", 4)

time.sleep(2)

The problem is that the pH in the 4x20 screen shows a weird character at the end. If I send any value manually, such as echo -n "7.123" > .2displaypH.tmp I don't get any weird characters, which makes me think is a problem of a newline, unfortunately, my code (echo -n "$READ" > $PWD/.2displaypH.tmp) doesn't prevent it. Any ideas?

0

There are 0 answers