-
Notifications
You must be signed in to change notification settings - Fork 0
/
meteostanice_RS485_pouze_odesilani.ino
76 lines (57 loc) · 1.61 KB
/
meteostanice_RS485_pouze_odesilani.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <DHT.h>
#include <Wire.h>
#include <Adafruit_BMP085.h>
#define DHTPIN 7
#define DHTTYPE DHT22 // DHT 22 (AM2302)
#define FW 100 // verze firmware
DHT dht(DHTPIN, DHTTYPE); // DHT22 - vlhkost
Adafruit_BMP085 bmp; // BMP085 - tlak
long interval = 10; // interval mereni [s]
uint32_t timer;
unsigned long count;
void setup () {
Serial.begin(9600);
/* ####### BMP085 ####### */
if (!bmp.begin()) {
Serial.println("Could not find a valid BMP085 sensor, check wiring!");
while (1) {}
}
/* ####### BMP085 ####### */
}
void loop () {
if (millis() > timer) {
timer = millis() + (interval * 1000);
merit();
}
}
void merit() {
Serial.print(F("Mereni c. "));
Serial.print(count);
Serial.println(F(""));
/* ####### DHT22 ####### */
dht.begin();
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
float t = dht.readTemperature();
// check if returns are valid, if they are NaN (not a number) then something went wrong!
if (isnan(t) || isnan(h)) {
Serial.println(F("DHT22_read_fail"));
} else {
Serial.print(F("DHT22 "));
Serial.print(t);
Serial.print(F("C; "));
Serial.print(h);
Serial.println(F("%"));
}
/* ####### DHT22 ####### */
/* ####### BMP085 ####### */
Serial.print(F("BMP085 "));
Serial.print(bmp.readTemperature());
Serial.print(F("C; "));
Serial.print(bmp.readPressure());
Serial.println(F("Pa"));
/* ####### BMP085 ####### */
Serial.println(F(""));
count++;
}