Last active
October 3, 2019 13:38
-
-
Save EspaceRaspberryFrancais/83a889b46870380d9f91c43989e0aea2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from RPLCD.gpio import CharLCD | |
from time import sleep | |
lcd = CharLCD(cols=16, rows=2, pin_rs=37, pin_e=35, pins_data=[33, 31, 29, 23]) | |
def lireFichier(emplacement): | |
fichTemp = open(emplacement) | |
contenu = fichTemp.read() | |
fichTemp.close() | |
return contenu | |
def recupTemp(contenuFich): | |
secondeLigne = contenuFich.split("\n")[1] | |
temperatureData = secondeLigne.split(" ")[9] | |
temperature = float(temperatureData[2:5]) | |
temperature = temperature / 10 | |
return temperature | |
while True: | |
contenuFich = lireFichier("/sys/bus/w1/devices/28-80000026cf81/w1_slave") | |
temperature = recupTemp(contenuFich) | |
lcd.cursor_pos = (0, 0) | |
lcd.write_string("Temperature :") | |
lcd.cursor_pos = (1, 0) | |
res = str(temperature) + " C" | |
lcd.write_string(res) | |
sleep(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment