DHT 11 / DHT 22
Les DHT11 et DHT 22 sont des sondes numériques mesurant la température et le taux d'humidité.
DHT11

La température de 0°C à 50°C ± 2°C, et pour le taux d'humidité: 20-90% ±5%
DHT22

La température de -40°C à +80°C ±0,5°C, et pour le taux d'humidité: 0-100% ±2%
DHT11 ou DHT22
Vu les précisions du DHT22, vous comprenez que pour faire une installation régulant le chauffage, il faudra le préférer, d'autant que la différence de prix n'est pas importante entre le DHT11 et le DHT22: comptez entre 3 et 4 euros pour le DHT22 standard contre environ 2 à 2,50 euros pour un DHT11.
Montage électrique sur Raspberry
Il faut:
- un DHT11 ou mieux un DHT22
- une résistance de 4,7kOhm
- du fil et un fer à souder ou une platine d'expérimentation (breadboard) 400 Points sans soudure devrait suffir si vous n'avez pas de fer pour faire des tests ...
- un raspberryNano-ordinateur monocarte concu par le créateur de jeux vidéo David Braben !
L'installation:
- Brancher le 3.3V sur la borne 1 du DHT
- Brancher un GPIO (exemple le GPIO n°4, soit le pinPersonal Identification Number ou plus rarement NIP pour Numéro d'identification personnel. Code à 4 chiffres ou plus permettant d'authentifier le propriétaire d'une carte SIM, carte de paiement...3 saisies incorrectes du code PIN provoque le blocage de la carte SIM (seul un code PUK déverrouillera la carte) ou l'avalement de la carte bleue par un distributeur automatique de billets (DAB) impliquant l'envoi de votre carte à votre agence bancaire pour vérification. Pin peut aussi être un terme en électronique. des pin sont des broches permettant de brancher des nappes ou fils provenant de cartes électroniques. n°7 sur raspberryNano-ordinateur monocarte concu par le créateur de jeux vidéo David Braben Pi2 et Pi3 par exemple) sur la borne 2 du DHT
- La borne 3 du DHT est inutilisée
- La borne 4 du DHT retourne sur le ground du raspberryNano-ordinateur monocarte concu par le créateur de jeux vidéo David Braben
- La résistance est branchée entre le 3,3Volt (récupérable sur la borne 1 du DHT ou depuis la ligne + du breadboard) et la borne 2 du DHT
Avant d'installer votre sonde, débranchez votre Raspberry Pi (y compris la RJ45, où du courant passe même si l'appareil est débranché du secteur).

Voilà pour la partie bricolage...

ou avec une carte d'expérimentation:

Reste à lire les données de la sonde à partir du Raspberry !
Auparavant, la librairie AdaFruit était récupérée en tapant:
mkdir adafruit
cd adafruit
wget https://github.com/adafruit/Adafruit-RaspberryNano-ordinateur monocarte concu par le créateur de jeux vidéo David Braben-Pi-Python-Code/archive/master.zip
cd Adafruit-RaspberryNano-ordinateur monocarte concu par le créateur de jeux vidéo David Braben-Pi-Python-Code*
unzip master.zip
Mais voilà, il n'y a plus qu'un fichier readme.md qui dit ceci:
Adafruit's Legacy RaspberryNano-ordinateur monocarte concu par le créateur de jeux vidéo David Braben Pi Python Code Library
## What happened to all the RaspberryNano-ordinateur monocarte concu par le créateur de jeux vidéo David Braben Pi Python code!?
In the past this repository held all of the RaspberryNano-ordinateur monocarte concu par le créateur de jeux vidéo David Braben Pi related Python code
that Adafruit published. For example code to talk to sensors like the BMP085,
TCS34725, and other hardware like character LCD plates. Over time we found it
difficult to manage so much code in a single repository, and couldn't easily put
the code on Python's package index for simple installation. Now we've broken out
all of the previous Python code into individual GitHub repositories, and we've
loaded all of these repositories on the [Python package index](https://pypi.python.org/pypi)
so they can be installed with `pip` (note that pip won't install example code so for most users
it's recommended to install from source).In addition **all** of the Python libraries below support **both** Python 2.7 and Python 3.x! Note
if you do plan to use Python 3 it has totally separate libraries from Python 2 so you might
need to install all the libraries you use in **both** Python 2 and 3. See this video stream
for more details: https://www.youtube.com/watch?v=rRFG32EebNc In particular on a RaspberryNano-ordinateur monocarte concu par le créateur de jeux vidéo David Braben Pi
you probably want to install Python 3, PIP for Python 3, and the RPi.GPIO library (used
to talk to GPIO pins on the Pi) with these commands:sudo apt-get update
sudo apt-get install -y python3 python3-pip python-dev
sudo pip3 install rpi.gpio## Where do I find the new RaspberryNano-ordinateur monocarte concu par le créateur de jeux vidéo David Braben Pi Python code?
Here is a table with each of the old libraries and a link to their new unique
GitHub repositories and easy pip install names:| Old Library Name | New Library Location | New `pip install` Package Name | Notes |
|------------------|----------------------|--------------------------------|-------|
| Adafruit_ADS1x15 | https://github.com/adafruit/Adafruit_Python_ADS1X15 | adafruit-ads1x15 | [See guide](https://learn.adafruit.com/raspberryNano-ordinateur monocarte concu par le créateur de jeux vidéo David Braben-pi-analog-to-digital-converters). |
| Adafruit_ADXL345 | https://github.com/adafruit/Adafruit_Python_ADXL345 | adafriut-adxl345 | - |
| Adafruit_BMP085 | https://github.com/adafruit/Adafruit_Python_BMP | adafruit-bmp | [See guide](https://learn.adafruit.com/using-the-bmp085-with-raspberryNano-ordinateur monocarte concu par le créateur de jeux vidéo David Braben-pi/using-the-adafruit-bmp085-python-library). |
| Adafruit_CharLCD | https://github.com/adafruit/Adafruit_Python_CharLCD | adafruit-charlcd | [See new character LCD guide](https://learn.adafruit.com/character-lcd-with-raspberryNano-ordinateur monocarte concu par le créateur de jeux vidéo David Braben-pi-or-beaglebone-black/overview). |
| Adafruit_CharLCDPlate | https://github.com/adafruit/Adafruit_Python_CharLCD | adafruit-charlcd | [See new character LCD guide](https://learn.adafruit.com/character-lcd-with-raspberryNano-ordinateur monocarte concu par le créateur de jeux vidéo David Braben-pi-or-beaglebone-black/overview). |
| Adafruit_DHT_Driver | https://github.com/adafruit/Adafruit_Python_DHT | None, must be manually installed to properly compile C extension. | See the [C code for reading the DHT sensor](https://github.com/adafruit/Adafruit_Python_DHT/tree/master/source/Raspberry_Pi_2) in the updated Python driverPilote de périphérique. Il s'agit d'un programme qui va permettre à un système d'exploitation la reconnaissance d'un matériel et son utilisation en tant que périphérique (imprimante, clé USB, ...). |
| Adafruit_DHT_Driver_Python | https://github.com/adafruit/Adafruit_Python_DHT | None, must be manually installed to properly compile C extension. | [See updated DHT sensor guide](https://learn.adafruit.com/dht-humidity-sensing-on-raspberryNano-ordinateur monocarte concu par le créateur de jeux vidéo David Braben-pi-with-gdocs-logging/overview) |
| Adafruit_I2C | https://github.com/adafruit/Adafruit_Python_GPIO | adafruit-gpio | See [updated I2C code](https://github.com/adafruit/Adafruit_Python_GPIO/blob/master/Adafruit_GPIO/I2C.py) in the Python GPIO library. Import with `import Adafruit_GPIO.I2C as I2C` and create an instance of `I2C.Device` instead of the old `Adafruit_I2C` class. |
| Adafruit_LEDBackpack | https://github.com/adafruit/Adafruit_Python_LED_Backpack | adafruit-led-backpack | [See new LED backpacks guide.](https://learn.adafruit.com/led-backpack-displays-on-raspberryNano-ordinateur monocarte concu par le créateur de jeux vidéo David Braben-pi-and-beaglebone-black/overview) |
| Adafruit_LEDpixels | https://github.com/adafruit/Adafruit_Python_WS2801 | adafruit-ws2801 | - |
| Adafruit_LSM303 | https://github.com/adafruit/Adafruit_Python_LSM303 | adafruit-lsm303 | - |
| Adafruit_MCP230xx | https://github.com/adafruit/Adafruit_Python_GPIO | adafruit-gpio | See [updated MCP230xx code](https://github.com/adafruit/Adafruit_Python_GPIO/blob/master/Adafruit_GPIO/MCP230xx.py). |
| Adafruit_MCP3002 | Deprecated, see MCP3008 chip. | - | - |
| Adafruit_MCP3008 | https://github.com/adafruit/Adafruit_Python_MCP3008 | adafruit-mcp3008 | [See guide](https://learn.adafruit.com/raspberryNano-ordinateur monocarte concu par le créateur de jeux vidéo David Braben-pi-analog-to-digital-converters). |
| Adafruit_MCP4725 | https://github.com/adafruit/Adafruit_Python_MCP4725 | adafruit-mcp4725 | [See guide](https://learn.adafruit.com/mcp4725-12-bit-dac-with-raspberryNano-ordinateur monocarte concu par le créateur de jeux vidéo David Braben-pi/overview) |
| Adafruit_PWM_Servo_Driver | https://github.com/adafruit/Adafruit_Python_PCA9685 | adafruit-pca9685 | [See guide](https://learn.adafruit.com/adafruit-16-channel-servo-driverPilote de périphérique. Il s'agit d'un programme qui va permettre à un système d'exploitation la reconnaissance d'un matériel et son utilisation en tant que périphérique (imprimante, clé USB, ...)-with-raspberryNano-ordinateur monocarte concu par le créateur de jeux vidéo David Braben-pi/overview) |
| Adafruit_TCS34725 | https://github.com/adafruit/Adafruit_Python_TCS34725 | adafruit-tcs34725 | - |
| Adafruit_VCNL4000 | https://github.com/adafruit/Adafruit_Python_VCNL40xx | adafruit-vcnl40xx | - |You might also be interested in other Python libraries which were never in this repository but are handy for talking
to other hardware:| Device / Guide | Library Location | `pip install` Package Name |
|----------------|------------------|----------------------------|
| [BME280 Humidity & Pressure Sensor](https://learn.adafruit.com/adafruit-bme280-humidity-barometric-pressure-temperature-sensor-breakout/overview) | https://github.com/adafruit/Adafruit_Python_BME280 | TBD |
| [BNO055 Absolute Orientation Sensor](https://learn.adafruit.com/bno055-absolute-orientation-sensor-with-raspberryNano-ordinateur monocarte concu par le créateur de jeux vidéo David Braben-pi-and-beaglebone-black/overview) | https://github.com/adafruit/Adafruit_Python_BNO055 | adafruit-bno055 |
| [ILI9341 LCD Displays](https://learn.adafruit.com/user-space-spi-tft-python-library-ili9341-2-8/overview) | https://github.com/adafruit/Adafruit_Python_ILI9341 | adafruit-ili9341 |
| [MAX31855 Thermocouple Sensor](https://learn.adafruit.com/max31855-thermocouple-python-library/overview) | https://github.com/adafruit/Adafruit_Python_MAX31855 | adafruit-max31855 |
| [MAX9744 Class D Amplifier](https://learn.adafruit.com/adafruit-20w-stereo-audio-amplifier-class-d-max9744/overview) | https://github.com/adafruit/Adafruit_Python_MAX9744 | adafruit-max9744 |
| [MCP9808 Temperature Sensor](https://learn.adafruit.com/mcp9808-temperature-sensor-python-library/overview) | https://github.com/adafruit/Adafruit_Python_MCP9808 | adafruit-mcp9808 |
| [PN532 NFC Interface](https://learn.adafruit.com/raspberryNano-ordinateur monocarte concu par le créateur de jeux vidéo David Braben-pi-nfc-minecraft-blocks/overview) | https://github.com/adafruit/Adafruit_Python_PN532 | adafruit-pn532 |
| [SSD1306 OLED Displays](https://learn.adafruit.com/ssd1306-oled-displays-with-raspberryNano-ordinateur monocarte concu par le créateur de jeux vidéo David Braben-pi-and-beaglebone-black/overview) | https://github.com/adafruit/Adafruit_Python_SSD1306 | adafruit-ssd1306 |
| [TMP006 & TMP007 Temperature Sensors](https://learn.adafruit.com/tmp006-temperature-sensor-python-library/overview) | https://github.com/adafruit/Adafruit_Python_TMP | adafruit-tmp |## But I **need** the old code! What can I do?
Don't worry the old Adafruit RaspberryNano-ordinateur monocarte concu par le créateur de jeux vidéo David Braben-Pi Python code can be found in the
[legacy branch](https://github.com/adafruit/Adafruit-RaspberryNano-ordinateur monocarte concu par le créateur de jeux vidéo David Braben-Pi-Python-Code/tree/legacy) of this repository. This is a snapshot of the old code before it
was refactored into individual libraries. **Note this legacy code will not be
maintained!**
Pour faire simple, ils ont éclaté la librairie qui permettait de lire différents capteurs en plusieurs petites librairies, une librairie pour un capteur.
Pour installer la librairie du DHT, vous passerez par l'outil git. ce qui donne en se référant à ce qu'ils indiquent:
git clone https://github.com/adafruit/Adafruit_Python_DHT.git
Vérifiez que Python soit bien à jour
sudo apt-get update
sudo apt-get install build-essential python-dev
Il reste à installer les librairies:
sudo python setup.py install
Un programme python est alors installé et va permettre de tester votre installation:
dans le répertoire examples, tapez
./AdafruitDHT.py type gpio
avec
- type est le type de DHT à lire: 11 ou 22
- gpio, le n° gpio à lire (fil jaune, le pinPersonal Identification Number ou plus rarement NIP pour Numéro d'identification personnel. Code à 4 chiffres ou plus permettant d'authentifier le propriétaire d'une carte SIM, carte de paiement...3 saisies incorrectes du code PIN provoque le blocage de la carte SIM (seul un code PUK déverrouillera la carte) ou l'avalement de la carte bleue par un distributeur automatique de billets (DAB) impliquant l'envoi de votre carte à votre agence bancaire pour vérification. Pin peut aussi être un terme en électronique. des pin sont des broches permettant de brancher des nappes ou fils provenant de cartes électroniques. 7 dans mon exemple, soit le GPIO n°4)
soit dans mon cas: ./AdafruitDHT.py 22 4
Codage en C pour raspberry
Pour lire la sonde DHT22 (ou DHT11) en C, dans le répertoire Adafruit_Python_DHT/source, vous trouverez du code en C. Mais vous rencontrerez quelques problèmes pour compiler ce code.
Vous aurez besoin des fichiers suivants:
- common_dht_read.h
- common_dht_read.c
- Raspberry_Pi_2/pi_2_dht_read.h
- Raspberry_Pi_2/pi_2_dht_read.c
- Raspberry_Pi_2/pi_2_mmio.h
- Raspberry_Pi_2/pi_2_mmio.c
Un programme test.c comme celui-ci:
Le fichier common_dht_read.h est à compléter avec ce qui suit:
cf. https://forums.adafruit.com/viewtopic.php?f=8&t=63038
Et vous compilez...
gccGNU Compiler Collection (Anciennement GNU C Compiler). Ensemble de compilateurs libres du projet GNU. Il est capable de compiler du C, C++, Objective-C, Java, Ada et Fortran... Dans le monde Unix, gcc (en minuscule) est le compilateur C, C++ (ou G++), remplaçant cc. test.c pi_2_dht_read.c pi_2_mmio.c ../common_dht_read.c -o test -std=c99
Dans mon cas, test.c est copié sous Raspberry_Pi_2 et la compilation se fait sous Raspberry_Pi_2.
Puis lancez le programme généré:
./test
test.c recherche la sonde sur le GPIO 4. Changez le code pour un autre GPIO si nécessaire !
Evidemment, vous pouvez utiliser un fichier makefile pour faire la compilation, ...
Annexes
Le site Adafruit:https://www.adafruit.com/
voir Adafruit et DHT22 sur RaspberryNano-ordinateur monocarte concu par le créateur de jeux vidéo David Braben:https://learn.adafruit.com/dht-humidity-sensing-on-raspberry-pi-with-gdocs-logging/software-install-updated