remote_ssh_based_gui
Inhaltsverzeichnis
GUI
Remote ssh based GUI
export DISPLAY=:0.0
Remote browser based GUI
Overview of html - mqtt - php - sh implemened GUI
simple HTML gui
color codes (see https://www.rapidtables.com/web/color/html-color-codes.html:
- green: rgb(127,255,0)
- yellow: rgb(255,255,0)
- cyan: rgb(0,255,255)
- skyblue: rgb(135,206,235)
- blue: rgb(0,0,255)
- violet: rgb(238,130,238)
- white: rgb(255,255,255)
- lightgray: rgb(211,211,211)
- black: rgb(0,0,0)
- red: rgb(255,0,0)
plotly based HTML gui
Idea: creating images on pi and display these images as html files remotely
Use lighttpd as minimal webserver on pi
sudo apt-get install lighttpd sudo pip install plotly
Check status
sudo systemctl status lighttpd
Set access rights
sudo groupadd www-data sudo usermod -G www-data -a pi sudo chown -R www-data:www-data /var/www/html sudo chmod -R 775 /var/www/html
restart service
sudo service lighttpd force-reload
move html file to be displayed into /var/www/html/
remote browser access html file by:
http://192.168.1.xx/<filename>
PHP installieren
Only use Python3
sudo apt-get install php7.3-cgi php7.3 sudo lighty-enable-mod fastcgi-php sudo service lighttpd force-reload
php- files in /var/www/html ablegen
mqtt Mosquitto installieren
Only use Python3
sudo apt-get install mosquitto mosquitto-clients -y
paho installieren
Paho is needed to call a shell procedure from python. Only availabe under python 3
pip3 install paho-mqtt
sensormqtt.py autostart
/etc/rc.local
nohup /home/pi/browserGUI/sensormqtt.py &
Basic code
import plotly.graph_objects as go
import random
def nextvalue():
return (random.randint(10,104))
def displayserver():
while True:
fig = go.Figure(go.Indicator(
mode = "gauge+number",
value = nextvalue(),
domain = {'x': [0, 1], 'y': [0, 1]},
title = {'text': "Temperatur"}))
fig.write_html('/var/www/html/labor.html', auto_open=True)
#fig.show()
#
# Main
#
if __name__== '__main__':
try:
displayserver()
except KeyboardInterrupt:
exit()
shell script lesen DB
getlatestvalue.sh
sqlite3 /home/pi/sensor/sensor.db <<END_SQL .timeout 2000 select ' ',* from latestvalueLabor_A; END_SQL
hand over values to thermometer.py
python3 thermometer.py `getlatestvalue.sh`
remote_ssh_based_gui.txt · Zuletzt geändert: von 127.0.0.1

