bonjour,
les propositions fusent a ce que je vois :grin:
je viens de recevoir un dht21 et il est déjà monté avec un shield ethernet tant qu' a faire MDR
j'ai comparé avec ma station météo pro et ca peut aller niveau T° et Hum.
montage d'une led pour tester si la temp est en dessous d'une certaine valeur, je pense que je vais attaquer sérieux dans la journée si tout mon taf avance vite.
un petit bout de code pour ceux que ca pourrait intéresser
le seul petit problème, les couleurs mal gérées à part le background
//projet couveuse infobarquee
//temp et humidex avec lampe temoin V1.0
#include
#include
#include "DHT.h"
#define DHTPIN 2
int led1 = 9; // led
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 2, 177 }; // ip in lan
byte gateway[] = { 192, 168, 2, 2 }; // the IP of the router or acsesspoint
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask (i dont think this is neccesary
Server server(80); // server port (change this if you are having a local webserver else than the arduino)
// Uncomment whatever type you're using!
//#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302)
#define DHTTYPE DHT21 // DHT 21 (AM2301)
DHT dht(DHTPIN, DHTTYPE);
void setup()
{
Serial.begin(9600); //enable serial datada print
Ethernet.begin(mac, ip, gateway, subnet); //start Ethernet
pinMode(led1, OUTPUT);
Serial.println("DHTxx test!");
dht.begin();
}
void loop(){
Client client = server.available(); // Create a client connection
if (client) {
while (client.connected()) {
if (client.available()) {
float h = dht.readHumidity();
float t = dht.readTemperature();
if (t < 20){analogWrite(led1,255);}else{analogWrite(led1,0);}
if (isnan(t) || isnan(h)) {
Serial.println("Failed to read from DHT");
} else {
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" *C");
}
//Web page
client.println("HTTP/1.1 200 OK"); //output HTML data starting with standart header
client.println("Content-Type: text/html");
client.println();
client.print (""); //set background to white
client.print("");
client.println("Arduino control Temperature And Humidex
");//send first heading
client.println("Refresh every 5s
");//send first heading
client.println("By Infobarquee
");//send first heading
client.print("Humidity: ");
client.print(h);
client.println(" %\t");
client.print("Temperature: ");
client.print(t);
client.println(" *C");
client.println("
");
client.println("