Ramirous Ramirous - 1 year ago 36
Python Question

Python while loop not updating

I'm very new to Python.

I'm trying to display the current temperature from a sensor, which I get from a bash script. I use

to replace the string in the python script (
), which prints that string to an LCD Display.

Unfortunately, when I run
, it only shows the temperature it has at the moment I run it, but it will not update, even though the
script is constantly changing (it only shows one temperature).

while True:
lcd_string("Temp: 25.123 *C",LCD_LINE_1,1)

25.123 is changing constantly in
, but not the different temperatures are not shown in the LCD

Is there any way to get it to update?

Answer Source

have your sed script constantly update a file called "label.txt" (you probably dont even need sed ... as an aside, why arent you just interfacing the sensor from python?)

then in your temp.py script

while True:

that is probably the easiest way to just make it work ... (See ned's answer as to why your original implementation did not work)