Simple Temp monitor example using LCDLabel
Posted: Thursday 17th September 2020 8:09pm
This is a simple text based temperature display using LCDLabel
Made as an example it is simple and has many descriptive comments.
Gets temperature in one of 3 ways,
Either runs a command and uses it's direct output or
loads a temp file that stores the temperature as a simple number being the temperature X 1000
For raspberry pi many other systems simply give it the file path...
'/sys/class/thermal/thermal_zone0/temp'
Auto-detect checks ALL /sys/class/thermal zones and reports the hottest one found.
or it can use a shell command like sensors (from package lm-sensors) with grep and awk to get the temperature text.
Use 'sudo apt-get install lm-sensors' or use your package manager to install.
Command Example...
The above command runs 'sensors', uses grep to find the line with 'Core 0' in it that for me looks like this...
Core 0: +45.0°C (high = +82.0°C, crit = +100.0°C)
and then uses awk to get the 3rd bit of text '+45.0°C' (space separation makes 'Core 0:' 2 words)
Written in Gambas basic
Code has FULL comments explaining everything.
Has a minimum-requirement-installer to install required gambas components.
Other features...
Change background / text and highlight colour
Set Time delay between checks.
Show/Hide Window border/titlebar
Drag-Move/resize window
Bruce
(Note this is version 1.2 , scroll down for updated version 1.4)
Made as an example it is simple and has many descriptive comments.
Gets temperature in one of 3 ways,
Either runs a command and uses it's direct output or
loads a temp file that stores the temperature as a simple number being the temperature X 1000
For raspberry pi many other systems simply give it the file path...
'/sys/class/thermal/thermal_zone0/temp'
Auto-detect checks ALL /sys/class/thermal zones and reports the hottest one found.
or it can use a shell command like sensors (from package lm-sensors) with grep and awk to get the temperature text.
Use 'sudo apt-get install lm-sensors' or use your package manager to install.
Command Example...
Code: Select all
sensors|grep 'Core 0'|awk '{print $3}'
Core 0: +45.0°C (high = +82.0°C, crit = +100.0°C)
and then uses awk to get the 3rd bit of text '+45.0°C' (space separation makes 'Core 0:' 2 words)
Written in Gambas basic
Code has FULL comments explaining everything.
Has a minimum-requirement-installer to install required gambas components.
Other features...
Change background / text and highlight colour
Set Time delay between checks.
Show/Hide Window border/titlebar
Drag-Move/resize window
Bruce
(Note this is version 1.2 , scroll down for updated version 1.4)