Skip to content

Instantly share code, notes, and snippets.

@EspaceRaspberryFrancais
Last active October 3, 2019 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EspaceRaspberryFrancais/83a889b46870380d9f91c43989e0aea2 to your computer and use it in GitHub Desktop.
Save EspaceRaspberryFrancais/83a889b46870380d9f91c43989e0aea2 to your computer and use it in GitHub Desktop.
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