yavstr
Posts: 7
Joined: Mon Mar 20, 2017 5:25 pm

Unresponsive

Sun Jul 09, 2017 7:27 pm

I have a pi hooked up to 5 temp/humidity sensors, 5 relay switches as well as a load cell and a pressure sensor.

All hookups seem fine and when working on my project I started with the temp/humidity first and they worked fine. I then started working on a new app with just the relays. I followed this for each piece of my application and each seemed fine.

Now when putting it all tighter with Tk for the GUI on an LCD I'm running into all sorts of issues.
If I have a while True: my GUI locks ups and becomes slow to respond.

What I'd like to do is update the GUI with temperature, humidity and pressure with data from the sensors. And based on that information I can click a button to ask a relay to do something.

Again, if the while True: is in place to read the sensors and update the GUI its slow to respond to clicks on buttons. If I turn off the while True the GUI responds with no issues but I can't get a readout from my sensors.

I'm somewhat new to the Pi and have limited experience with Python so perhaps I'm doing something wrong in my while True: loop?

Code: Select all

while True: 
     displayTemmp['text'] = getTempData()
     displayHumid['text'] = getHumidData()
     displayPressure['text'] = getPressureData()
     displayWeight['text'] = getWeight()
     win.update_idletasks()
     win.update()
     time.sleep(3)
Each of the methods just read the data from the sensor and return back strings for display.

Thanks for any advice or help.

User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: Unresponsive

Mon Jul 10, 2017 6:56 am

i not know if your problem is related to LCD specifics, i can not help,
but there might be a concept question:
sensors ( spec. smart sensors using links and protocols... also like USB..arduino ...)
should have their own program, a background service.
that should collect the data and save it ( like in a file at RAM DISK /run/shm/)

if you work with array / record structures there are very easy tools in python
to do that file read write ( from to your variable structure ) in a one line.. ( pickle.dump or pickle.load )

as a background service it might finally be auto started at boot

it could do additional jobs like historic data reduction / collection / cloud storage...

the visualization gets its own program, could be a desktop ( like your TKinter.. ) operator interface
or even a web page ( with websever )
and its timing depends totally on the operation, and it reads the data from that RAM DISK file.

Return to “Beginners”