Mozzi ADSR
[mirrors/Programs.git] / arduino / MeteoStenice2 / MeteoStenice2.ino
CommitLineData
3a2579cc
TM
1#include "Wire.h"
2#include "Adafruit_BMP085.h"
3#include <dht.h>
4
5//#define EOL ";"
6
7Adafruit_BMP085 bmp;
8dht DHT;
9#define DHT11PIN 2
10
11// delta max = 0.6544 wrt dewPoint()
12// 5x faster than dewPoint()
13// reference: http://en.wikipedia.org/wiki/Dew_point
14double dewPointFast(double celsius, double humidity)
15{
16 double a = 17.271;
17 double b = 237.7;
18 double temp = (a * celsius) / (b + celsius) + log(humidity/100);
19 double Td = (b * temp) / (a - temp);
20 return Td;
21}
22
23void setup() {
24 Serial.begin(9600);
25 bmp.begin();
26
27 Serial.println("\n");
28}
29
30void loop() {
31 int chk = DHT.read11(DHT11PIN);
32 if(chk != DHTLIB_OK) Serial.println("DHTLIB ERROR!");
33
34 Serial.print("{");
35 Serial.print("\"config\":{");
36 Serial.print("\"airquality\":{\"label\":\"Air Quality\",\"unit\":\"Relative\"},");
37 Serial.print("\"temp\":{\"label\":\"Temperature\",\"unit\":\"°C\"},");
38 Serial.print("\"pressure\":{\"label\":\"Pressure\",\"unit\":\"Pa\"},");
39 Serial.print("\"humidity\":{\"label\":\"Humidity\",\"unit\":\"% RH\"},");
40 Serial.print("\"analog\":{\"label\":\"ADC\",\"unit\":\"Relative\"}");
41 Serial.print("},");
42 Serial.print("\"data\":{");
43
44 Serial.print("\"airquality\":[");
45
46 Serial.print("{\"label\":\"Air polution (MQ-2)\",\"value\":\"");
47 Serial.print(analogRead(A1));
48 Serial.print("\"}");
49
50 Serial.print("],");
51
52
53/*
54 Serial.print("\"analog\":[");
55
56 Serial.print("{\"label\":\"ADC A0 (antenna?)\",\"value\":\"");
57 Serial.print(analogRead(A0));
58 Serial.print("\"}");
59
60 Serial.print(",{\"label\":\"ADC A2 (phototransistor?)\",\"value\":\"");
61 Serial.print(analogRead(A2));
62 Serial.print("\"}");
63
64 Serial.print("],");
65*/
66
67 Serial.print("\"temp\":[");
68
69 Serial.print("{\"label\":\"BMP085 Temperature\",\"value\":\"");
70 Serial.print(bmp.readTemperature());
71 Serial.print("\"}");
72
73 Serial.print(",{\"label\":\"DHT11 Temperature\",\"value\":\"");
74 Serial.print((float)DHT.temperature);
75 Serial.print("\"}");
76
77 Serial.print("],");
78
79
80 Serial.print("\"pressure\":[");
81
82 Serial.print("{\"label\":\"BMP085 Pressure\",\"value\":\"");
83 Serial.print(bmp.readPressure());
84 Serial.print("\"}");
85
86 Serial.print("],");
87
88
89 Serial.print("\"humidity\":[");
90
91 Serial.print("{\"label\":\"DHT11 Humidity\",\"value\":\"");
92 Serial.print((float)DHT.humidity);
93 Serial.print("\"}");
94
95 Serial.print("]");
96
97 Serial.print("}");
98 Serial.print("}\n");
99 delay(2000);
100}
This page took 0.654216 seconds and 4 git commands to generate.