Skip to content

Instantly share code, notes, and snippets.

@Franck1333
Created March 3, 2020 10:45
Show Gist options
  • Save Franck1333/063e2c717409e2c0556b0722606d6c73 to your computer and use it in GitHub Desktop.
Save Franck1333/063e2c717409e2c0556b0722606d6c73 to your computer and use it in GitHub Desktop.
Temp/Humidity Sensor DHT11 on Arduino (Nano in this case).
//AIDES: https://www.circuitbasics.com/how-to-set-up-the-dht11-humidity-sensor-on-an-arduino/
#include <dht.h>
dht DHT;
#define DHT11_PIN 7
void setup(){
Serial.begin(9600);
}
void loop()
{
temp_Hum(2048);
}
float temp_Hum(int delay_rafraichissement)
{
int chk = DHT.read11(DHT11_PIN); //Init
float temperature = DHT.temperature; //Obtention de la valeur de Temperature en provenance du capteur
float humidite = DHT.humidity; //Obtention de la valeur d'Humidite en provenance du capteur
Serial.print("Température (°C) = "); //Affichage Console
Serial.println(temperature); //Affichage de la temperature
Serial.print("Humidité (%) = "); //Affichage Console
Serial.println(humidite); //Affichage de l'humidite
delay(delay_rafraichissement); //Delay de 1 Seconde et 24 centieme
return temperature,humidite; //On retourne les valeurs pour une utilisation ulterieur
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment