Modifications

Sauter à la navigation Sauter à la recherche
305 octets ajoutés ,  20 mai 2015 à 18:23
Ligne 43 : Ligne 43 :     
== Utilisation ==
 
== Utilisation ==
To learn how to use the MCP9808 Python library you can run and review an example program included with the library. To run the example navigate to the examples directory and run the simpletest.py script by executing:
+
Pour savoir comment utiliser la bibliothèque Python du MCP9808, le plus simple est encore d'exécuter et réviser le programme d'exemple fournit avec la bibliothèque. Pour exécuter l'exemple, naviguez jusqu'au répertoire d'exemple (nommé ''examples'') et exécutez le script {{fname|simpletest.py}}:
    
  <nowiki>cd examples
 
  <nowiki>cd examples
 
sudo python simpletest.py</nowiki>
 
sudo python simpletest.py</nowiki>
   −
If everything goes well you should see the sensor's temperature displayed every second:
+
Si tout se passe bien, vous devriez voir la température du senseur affichée toutes les secondes:
    
  <nowiki>Press Ctrl-C to quit.
 
  <nowiki>Press Ctrl-C to quit.
Ligne 56 : Ligne 56 :  
...</nowiki>
 
...</nowiki>
   −
If you see an error make sure you're running the program as root with the sudo command, and that the dependencies & library were installed successfully.
+
Si vous constatez une erreur, assurez-vous d'avoir exécuté le programme comme super-utilisateur (''root'') avec la commande {{fname|sudo}} et que toutes les dépendances et bibliothèques soient installées correctement.
   −
To understand the usage, open '''simpletest.py''' in a text editor and follow along with the description of the code below.
+
Nous allons maintenant ouvrir le fichier {{fname|simpletest.py}} dans un éditeur de texte pour comprendre comment le programme fonctionne. Voyons, ci-dessous, ce qu'il contient.
    
  import Adafruit_MCP9808.MCP9808 as MCP9808
 
  import Adafruit_MCP9808.MCP9808 as MCP9808
   −
First the MCP9808 module is imported with a Python import statement.  
+
Pour commencer, le module MCP9808 est importé avec la commande python {{fname|import}}.  
    
  <nowiki># Default constructor will use the default I2C address (0x18) and pick a default I2C bus.
 
  <nowiki># Default constructor will use the default I2C address (0x18) and pick a default I2C bus.
Ligne 77 : Ligne 77 :  
#sensor = MCP9808.MCP9808(address=0x20, busnum=2)</nowiki>
 
#sensor = MCP9808.MCP9808(address=0x20, busnum=2)</nowiki>
   −
Next an instance of the MCP9808 class is created.   
+
Ensuite, une instance de la classe MCP9808 est créé avec l'instruction{{fname|1=sensor = MCP9808.MCP9808()}}.   
    
Notice that if nothing is passed in to the initializer function the library will pick a default I2C device address (0x18) and bus number.  If you need to specify the I2C address or bus number you can do so by specifying them as optional parameters in the MCP9808 initializer.
 
Notice that if nothing is passed in to the initializer function the library will pick a default I2C device address (0x18) and bus number.  If you need to specify the I2C address or bus number you can do so by specifying them as optional parameters in the MCP9808 initializer.
29 917

modifications

Menu de navigation