https://wiki.aaeon-community.com/index.php?title=Monitor_PICO-APL3_CPU_Cores%E2%80%99_temperature_using_LEDs_on_a_custom_external_circuit&feed=atom&action=historyMonitor PICO-APL3 CPU Cores’ temperature using LEDs on a custom external circuit - Revision history2024-03-29T12:14:25ZRevision history for this page on the wikiMediaWiki 1.30.0https://wiki.aaeon-community.com/index.php?title=Monitor_PICO-APL3_CPU_Cores%E2%80%99_temperature_using_LEDs_on_a_custom_external_circuit&diff=5434&oldid=prevFilippo: /* Demo Circuit */2018-12-18T20:48:49Z<p><span dir="auto"><span class="autocomment">Demo Circuit</span></span></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr style="vertical-align: top;" lang="en">
<td colspan="2" style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: white; color:black; text-align: center;">Revision as of 20:48, 18 December 2018</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l103" >Line 103:</td>
<td colspan="2" class="diff-lineno">Line 103:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>== Demo Circuit ==</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>== Demo Circuit ==</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">//image</del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">[[File:Democircuittemperature.png|800px]]</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>We have used a digital inverter IC (74HC04) to provide buffering for the GPIO signals.  The main reasons is that this type of device is very easy to get, has a wide power supply range that allows to use the 3.3V available in the CN60 header, their outputs can drive the currents required by an LED  and, finally, this way the wiring is greatly simplified.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>We have used a digital inverter IC (74HC04) to provide buffering for the GPIO signals.  The main reasons is that this type of device is very easy to get, has a wide power supply range that allows to use the 3.3V available in the CN60 header, their outputs can drive the currents required by an LED  and, finally, this way the wiring is greatly simplified.</div></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l109" >Line 109:</td>
<td colspan="2" class="diff-lineno">Line 109:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>We connect the GPIO signals (digital outputs) to the inverters’ inputs, and drive the LEDs with the outputs. The 74HC04 includes 6 inverters as shown in the following diagram:</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>We connect the GPIO signals (digital outputs) to the inverters’ inputs, and drive the LEDs with the outputs. The 74HC04 includes 6 inverters as shown in the following diagram:</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">//diagram</del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">[[File:Diagram.jpg]]</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>We are only using four or them (1-4), so we connect the inputs of the remaining inverters 5 and 6 to Vcc (could be also GND, they just need to be tied to a constant logic level) to avoid unwanted switching and oscillations.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>We are only using four or them (1-4), so we connect the inputs of the remaining inverters 5 and 6 to Vcc (could be also GND, they just need to be tied to a constant logic level) to avoid unwanted switching and oscillations.</div></td></tr>
<!-- diff cache key smpxkwkych:diff:version:1.11a:oldid:5431:newid:5434 -->
</table>Filippohttps://wiki.aaeon-community.com/index.php?title=Monitor_PICO-APL3_CPU_Cores%E2%80%99_temperature_using_LEDs_on_a_custom_external_circuit&diff=5431&oldid=prevFilippo: /* Demo Circuit */2018-12-18T20:46:50Z<p><span dir="auto"><span class="autocomment">Demo Circuit</span></span></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr style="vertical-align: top;" lang="en">
<td colspan="2" style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: white; color:black; text-align: center;">Revision as of 20:46, 18 December 2018</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l115" >Line 115:</td>
<td colspan="2" class="diff-lineno">Line 115:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>Every LED is controlled by one of the GPIOs. So as the temperature increases the LEDs will turn on in order, controlled by the '''drive_leds()''' function:</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>Every LED is controlled by one of the GPIOs. So as the temperature increases the LEDs will turn on in order, controlled by the '''drive_leds()''' function:</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">\\table</del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">{| class="wikitable"</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">|-</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">! Temperature !! L0 !! L1 !! L2 !! L3</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">|-</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">| T <= 39°C || off || off || off || off </ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">|-</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">| 39°C < T <= 46°C || on|| off || off || off </ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">|-</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">| 46°C < T <= 50°C || on|| on|| off || off </ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">|-</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">| 50°C < T <= 53°C || on|| on|| on|| off </ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">|-</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">| T > 53°C || on|| on|| on|| on</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">|}</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>== Testing the Script ==</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>== Testing the Script ==</div></td></tr>
<!-- diff cache key smpxkwkych:diff:version:1.11a:oldid:5430:newid:5431 -->
</table>Filippohttps://wiki.aaeon-community.com/index.php?title=Monitor_PICO-APL3_CPU_Cores%E2%80%99_temperature_using_LEDs_on_a_custom_external_circuit&diff=5430&oldid=prevFilippo: Created page with "= Introduction = In the previous tutorial we followed the steps required to retrieve the te..."2018-12-18T20:40:12Z<p>Created page with "= Introduction = In the <a href="/index.php?title=Accessing_boards%E2%80%99_sensors:_how_to_display_Internal_Temperature_using_Python" title="Accessing boards’ sensors: how to display Internal Temperature using Python">previous tutorial</a> we followed the steps required to retrieve the te..."</p>
<p><b>New page</b></p><div>= Introduction =<br />
<br />
In the [[Accessing boards’ sensors: how to display Internal Temperature using Python |previous tutorial]] we followed the steps required to retrieve the temperature information provided by the on-board sensors, using the lm_sensors package. We extracted this information from the output of the sensors command and displayed the results on the terminal screen.<br />
<br />
Taking the work done so far as a starting point, we will now show how the temperature information can be used to control external devices. A real-life situation in which this can be useful is the control of a cooling fan for the processor/board. The speed of the fan can be increased or decreased depending on the measured temperatures, or, if they are low enough, the fan can be stopped.<br />
<br />
But for the purpose of demonstrating the interaction with external devices we will take a simpler approach and use the digital signals that we already discussed in previous posts to drive a set of LEDs. This will also give us the chance to see how the '''GPIO''' can be controlled from a '''Python script'''.<br />
<br />
== GPIO Control in Python ==<br />
<br />
When we worked with the GPIO signals from the command line or in shell scripts we had to access different files in the '''/sys/class/gpio/''' directory hierarchy. <br />
In Python we have a library that encapsulates and hides these accesses and provides us with a very convenient programming interface. This library is '''python-periphery''' and we need to install it before making any additions to our Python code. But first we need to install pip, a Python package manager that is used to install python-periphery. <br />
So, these are the installation steps:<br />
> sudo apt install python3-pip<br />
> sudo pip3 install python-periphery<br />
<br />
Now we are ready to use the periphery module in our Python code.<br />
<br />
== Python Script: temp_control.py ==<br />
<br />
We will complete our new Python program by adding to our [[Accessing boards’ sensors: how to display Internal Temperature using Python | previous script]] '''the code that manages the GPIO.'''<br />
<br />
When we execute the sensor command on the PICO-APL3 board we get four temperature measurements. <br />
For the sake of simplicity we are using the maximum of these temperatures as our unique control input. For that reason we have modified the '''update_output()''' function to compute and display the maximum temperature.<br />
<br />
The other modifications are additions needed to manage the GPIO and are highlighted in the following listing.<br />
<br />
#!/usr/bin/python3<br />
<br />
import subprocess<br />
import re<br />
import sys<br />
import time<br />
'''from periphery import GPIO'''<br />
<br />
'''N_OUTPUTS = 4'''<br />
'''gpio_outs = []'''<br />
'''temp_thrs = [39.0, 46.0, 50.0, 53.0]'''<br />
<br />
def get_sensor_data():<br />
sensors_out = subprocess.run(['sensors'], stdout=subprocess.PIPE)<br />
return sensors_out.stdout.decode('utf-8')<br />
<br />
def parse_temps(sensor_data):<br />
temps = re.findall('\d+(?:\.\d+)?°C ', sensor_data, re.MULTILINE)<br />
return [x[:-3] for x in temps]<br />
<br />
def update_output(temps):<br />
sys.stdout.write("Board: %s - Package: %s - Core 0: %s - Core 2: %s | MAX: %s\r" %<br />
(temps[0], temps[1], temps[2], temps[3], max(temps)))<br />
sys.stdout.flush()<br />
<br />
def shutdown():<br />
'''cleanup_gpio()'''<br />
print()<br />
print("Goodbye!")<br />
print()<br />
<br />
''' def init_gpio(n_outs):'''<br />
'''global gpio_outs'''<br />
'''gpio_outs = [GPIO(n, "low") for n in range(n_outs)]'''<br />
<br />
'''def cleanup_gpio():'''<br />
'''for gpio in gpio_outs:'''<br />
'''gpio.write(False)'''<br />
'''gpio.direction = "in"'''<br />
'''gpio.close()'''<br />
<br />
'''def drive_leds(values):'''<br />
'''temp = float(max(values))'''<br />
'''for k in range(len(gpio_outs)):'''<br />
'''gpio_outs[k].write(temp > temp_thrs[k])'''<br />
<br />
# Main program<br />
'''init_gpio(N_OUTPUTS)'''<br />
print()<br />
print("System temperatures (°C) reported by the 'sensors' command (Ctrl-C to stop):")<br />
try:<br />
while True:<br />
data = get_sensor_data()<br />
temp_values = parse_temps(data)<br />
update_output(temp_values)<br />
'''drive_leds(temp_values)'''<br />
time.sleep(1)<br />
except KeyboardInterrupt:<br />
shutdown()<br />
<br />
At the beginning of the script the GPIO class is imported from the periphery module and some variables are defined:<br />
<br />
* '''N_OUTPUTS''': The number of digital outputs used by the script.<br />
* '''gpio_outs''': a list of GPIO objects, which represent the four digital outputs.<br />
* '''temp_thrs''': a list of temperature thresholds.<br />
<br />
Additionally, we define the new functions:<br />
<br />
* '''init_gpio()''': sets up the specified number of GPIOs as digital outputs and sets its value to LOW.<br />
* '''cleanup_gpio()''': changes all allocated outputs to inputs (for safety) and releases them.<br />
* '''drive_leds()''': computes the maximum temperature and compares it with the threshold values defined in temp_thrs: if the temperature is greater than one threshold, then the corresponding digital output is set HIGH, otherwise it is set LOW. For example, for the values shown in the listing above, for a temperature of 52°C the first three outputs will be activated, but not the fourth (the fourth threshold is 53°C).<br />
<br />
The '''drive_leds()''' function is called on every iteration of the main loop, so the digital outputs will be updated periodically following the variations of the maximum temperature. <br />
<br />
<br />
== Demo Circuit ==<br />
<br />
//image<br />
<br />
We have used a digital inverter IC (74HC04) to provide buffering for the GPIO signals. The main reasons is that this type of device is very easy to get, has a wide power supply range that allows to use the 3.3V available in the CN60 header, their outputs can drive the currents required by an LED and, finally, this way the wiring is greatly simplified.<br />
<br />
We connect the GPIO signals (digital outputs) to the inverters’ inputs, and drive the LEDs with the outputs. The 74HC04 includes 6 inverters as shown in the following diagram:<br />
<br />
//diagram<br />
<br />
We are only using four or them (1-4), so we connect the inputs of the remaining inverters 5 and 6 to Vcc (could be also GND, they just need to be tied to a constant logic level) to avoid unwanted switching and oscillations.<br />
<br />
Every LED is controlled by one of the GPIOs. So as the temperature increases the LEDs will turn on in order, controlled by the '''drive_leds()''' function:<br />
<br />
\\table<br />
<br />
== Testing the Script ==<br />
<br />
In this case the script requires root permissions because of the access to the GPIO signals:<br />
<br />
apl3@APL3:~$ sudo python3 temp_control.py <br />
<br />
System temperatures (°C) reported by the 'sensors' command (Ctrl-C to stop):<br />
Board: 35.0 - Package: 39.0 - Core 0: 41.0 - Core 2: 39.0 | MAX: 41.0<br />
<br />
The control of the LEDs can be checked by temporarily increasing the processor load and thereby the temperature:<br />
<br />
> stress -c 16 -t 30s -q & python3 temp_display.py<br />
<br />
The '''stress''' command will cause a temperature increase enough to turn on the four LEDs. After 30 seconds the load will return to a normal level and the ‘higher’ LEDs will turn off; only L0 (and maybe, sporadically, L1) will remain on.</div>Filippo