3 031 octets ajoutés
, 10 septembre 2015 à 11:20
{{RASP-SENSE-HAT-ASTRO-PI-NAV}}
{{traduction}}
== Senseur de température ==
{{bloc-etroit|text=The Sense HAT features a number of sensors, including un senseur de pression.
Le source anglaise de cette traduction se trouve ici [https://www.raspberrypi.org/learning/astro-pi-guide/sensors/temperature.md www.raspberrypi.org/learning/astro-pi-guide/sensors/temperature.md]
}}
[[Fichier:RASP-SENSE-HAT-ASTRO-PI-Temperature-00.jpg]]
The image above shows a clinical thermometer. You may have been asked to place one in your mouth when you've been ill. Notice that the numbers start at 35, so it's only used for measuring human body temperature. The Sense HAT temperature sensors can measure temperatures from as low as -40 degrees Celsius up to +120 degrees Celsius though, so they are much more versatile than a clinical thermometer. The Sense HAT has two temperature sensors. One is built into the humidity sensor and the other is built into the pressure sensor. You can choose which one to use, or you could use both and average the result.
== Qu'est ce que la température? ==
'''1.''' Open '''Python 3''' from a terminal window as sudo by typing:
<nowiki>sudo idle3 &</nowiki>
'''2.''' Enter the following code into a new window:
<nowiki>from sense_hat import SenseHat
sense = SenseHat()
sense.clear()
temp = sense.get_temperature()
print(temp)</nowiki>
'''3.''' Select {{fname|File > Save}} (''Fichier > Sauver'') and choose a file name for your program.
'''4.''' Select {{fname|Run > Run module}} ''Executer > Exécuter module''.
'''5.''' If you see the error {{fname|Humidity Init Failed}}, please run as {{fname|root}} en utilisant {{fname|sudo}} (look on the last line of the message in red), it means you haven't followed the instructions above. Close everything and go back to step 1.
'''6.''' ou should see something like this:
<nowiki>Humidity sensor Init Succeeded
28.6293258667</nowiki>
La première ligne "Humidity sensor Init Succeeded" signifie ''Senseur d'humidité initialisé avec succès''. Il se fait que le senseur de température est embarqué sur le senseur d'humidité, un autre senseur de température est embarqué sur le senseur de pression.
'''7.''' Just before the {{fname|print(temp)}} line add this line below:
<nowiki>temp = round(temp, 1)</nowiki>
'''8.''' You should now see something like this (without all the numbers after the decimal point):
<nowiki>Humidity sensor Init Succeeded
28.6</nowiki>
'''9.''' Try the following functions instead of get_temperature.
* {{fname|get_temperature_from_humidity}} (uses the humidity sensor, {{fname|get_temperature}} is a short version of this)
* {{fname|get_temperature_from_pressure}} (uses the pressure sensor)
For example:
<nowiki>from sense_hat import SenseHat
sense = SenseHat()
sense.clear()
temp = sense.get_temperature_from_pressure()
temp = round(temp, 1)
print(temp)</nowiki>
Your code takes one measurement and then exits.
== Surveiller la température ==
{{traduction}}
{{RASP-SENSE-HAT-ASTRO-PI-TRAILER}}