Ligne 35 : |
Ligne 35 : |
| === Brancher un BMP280 === | | === Brancher un BMP280 === |
| [[Fichier:FEATHER-MICROPYTHON-BMP280.jpg|640px]] | | [[Fichier:FEATHER-MICROPYTHON-BMP280.jpg|640px]] |
| + | |
| + | == Utiliser == |
| + | |
| + | === Utiliser le BME280 === |
| + | |
| + | <syntaxhighlight lang="python"> |
| + | from machine import Pin, I2C |
| + | from bme280 import * |
| + | |
| + | i2c = I2C(scl=Pin(5), sda=Pin(4)) |
| + | bme = BME280(i2c=i2c) |
| + | |
| + | print(bme.values) |
| + | </syntaxhighlight> |
| + | |
| + | === Utiliser le BMP280 === |
| + | |
| + | <syntaxhighlight lang="python"> |
| + | from machine import Pin, I2C |
| + | from bme280 import * |
| + | |
| + | i2c = I2C(scl=Pin(5), sda=Pin(4)) |
| + | bmp = BME280(i2c=i2c, address=BMP180_I2CADDR ) |
| + | |
| + | print(bmp.values) |
| + | </syntaxhighlight> |
| + | |
| + | Qui produit un tuple de valeurs avec des informations Human Readeable: |
| + | * La température en degrés Celcius (valeur en , |
| + | * La pression en HectoPascal |
| + | * L'humidité relative en pourcent<br />Pour un BMP280, la valeur de l'humidité sera toujours égale à 0 parce que le BMP280 ne dispose pas du senseur d'humidité. |
| + | |
| + | <syntaxhighlight lang="python"> |
| + | ('22.36C', '1005.65hPa', '0.00%') |
| + | </syntaxhighlight> |
| + | |
| + | La classe propose également une propriété {{fname|raw_values}} qui retourne un tuple avec des valeurs numériques: |
| + | |
| + | Par exemple, l'appel de : |
| + | |
| + | <syntaxhighlight lang="python"> |
| + | print(bmp.raw_values) |
| + | </syntaxhighlight> |
| + | |
| + | Ce qui produira... |
| + | |
| + | <syntaxhighlight lang="python"> |
| + | (22.36, 1005.65, 0.0) |
| + | </syntaxhighlight> |
| + | |
| + | == Encore Plus == |
| + | * [https://github.com/mchobby/esp8266-upy/tree/master/bme280-bmp280 Voyez la page GitHub pour plus de détails sur la lecture des données] (''MCHobby GitHub'') |
| | | |
| == Où acheter == | | == Où acheter == |
| * [http://shop.mchobby.be/product.php?id_product=1118 Adafruit BMP280 (ADA2651)] disponible chez MCHobby | | * [http://shop.mchobby.be/product.php?id_product=1118 Adafruit BMP280 (ADA2651)] disponible chez MCHobby |
| * [http://shop.mchobby.be/product.php?id_product=684 Adafruit BME280 (ADA2652)] disponible chez MCHobby | | * [http://shop.mchobby.be/product.php?id_product=684 Adafruit BME280 (ADA2652)] disponible chez MCHobby |