Last active
September 29, 2019 10:30
-
-
Save ypelletier/42429afe023b421ea017999e2fe08232 to your computer and use it in GitHub Desktop.
Utilisation d'un capteur de lumière TSL2561 avec un Raspberry Pi. Chaque seconde, le terminal affiche l'intensité lumineuse en lux.
This file contains hidden or 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
#!/usr/bin/python | |
# -*- coding:utf-8 -*- | |
''' | |
Utilisation d'un capteur de lumière TSL2561 avec | |
un Raspberry Pi. | |
Chaque seconde, le terminal affiche l'intensité | |
lumineuse en lux. | |
Plus d'infos: | |
https://electroniqueamateur.blogspot.com/2019/02/capteur-de-lumiere-tsl2561-et-raspberry.html | |
''' | |
import smbus # pour la communication i2c | |
import time # pour le chronométrage du délai | |
import tsl2561 # https://github.com/keiichishima/RPiSensors | |
bus = smbus.SMBus(1) # bus i2c | |
capteur = tsl2561.Tsl2561(bus) #initialisation du capteur | |
while True: | |
print ("Intensite lumineuse : %0.3f lux" %capteur.lux) | |
time.sleep(1) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment