-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArduino.ino
executable file
·51 lines (40 loc) · 1.11 KB
/
Arduino.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <DHT.h>
#include <DHT_U.h>
#define DHTPIN 2
#define DHTTYPE DHT11
int capteur_lum = 5;
DHT dht(DHTPIN, DHTTYPE);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
dht.begin();
}
void loop() {
// put your main code here, to run repeatedly:
delay(1000);
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
if(isnan(h) || isnan(t) || isnan(f)){
Serial.println("Echec de lecture !");
return;
}
float hi = dht.computeHeatIndex(f,h);
//Serial.print("Humidite: ");
Serial.print(h);
Serial.print("%\t");
//Serial.print("Temperature : ");
Serial.print(t);
Serial.print("%\t");
/*analog_lum = analogRead(capteur_lum);
Serial.print("Valeur luminosité = ");
Serial.print(analog_lum);
Serial.print("%\t");*/
int rawValue = analogRead(capteur_lum);
float voltage = rawValue * (5.0/1023)*1000;
float resistance = 10000 * (voltage/(5000.0-voltage));
Serial.print(voltage);
Serial.print("%\t");
Serial.print(resistance);
Serial.println("%\t");
}