-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathzews_master.ino
131 lines (75 loc) · 3.1 KB
/
zews_master.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
Copyright (C) 2018 Moisi Xhaferaj
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Code for the OSWS Arduino UNO Master
These function calls have the purpose of reading the output of the sensors
connected through the I2C bus or direvtly to the Arduino Uno master.
Created by Moisi Xhaferaj, 05/03/2018.
Part of the original code from:
SFE_BMP180 library example sketch
V10 Mike Grusin, SparkFun Electronics 10/24/2013
V1.1.2 Updates for Arduino 1.6.4 5/2015
*/
#include <Wire.h>
#include <LMsensorquery.h>
#include <DHTsensorquery.h>
#include <SFE_BMP180.h>
#include <dht.h>
#include <AT85sensorquery.h>
#include <BMP180sensorquery.h>
#define DHT11_PIN 7
int tempPin = 1;
#define I2C_SLAVE1 0x13 //luminance level 10 bit
#define I2C_SLAVE2 0x08 //radiated powerlevel
// You will need to create an SFE_BMP180 object, here called "pressure":
SFE_BMP180 pressure;
void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial for output
Serial.println("REBOOT");
// Initialize the sensor (it is important to get calibration values stored on the device).
if (pressure.begin())
Serial.println("BMP180 init success");
else
{
// Oops, something went wrong, this is usually a connection problem,
// see the comments at the top of this sketch for the proper connections.
Serial.println("BMP180 init fail\n\n");
while(1); // Pause forever.
}
}
void loop()
{
float lm35temp=0;
float dht11temp=0;
float dht11hum=0;
unsigned int luminance=0, irradiatedpower=0, WindSpeed=0, WindDir=0;
float bmp180abspress=0;
float bmp180relpress=0;
float bmp180temp=0;
float bmp180altitude=103;
AT85sensorquery(I2C_SLAVE1, 2000, luminance);
AT85sensorquery(I2C_SLAVE2, 2000, irradiatedpower);
DHTsensorquery(DHT11_PIN, 3000, dht11hum, dht11temp);
LMsensorquery(tempPin, 3000, lm35temp);
BMP180sensorquery(pressure, 2000, bmp180altitude, bmp180abspress, bmp180relpress, bmp180temp);
String stringColumns = "TemperatureLM35, TemperatureDHT11, TemperatureBMP180, HumidityDHT11, PessureBMP180abs, PessureBMP180rel, WindSpeed, WindDir, Luminance, IrradiatedPower; ";
String stringOut = "*";
stringOut = stringOut + lm35temp + "," + dht11temp + "," + bmp180temp + "," + dht11hum + "," + bmp180abspress + "," + bmp180relpress + "," + WindSpeed + "," + WindDir + "," + luminance + "," + irradiatedpower + ";";
Serial.println();
Serial.print(stringColumns);
Serial.println();
Serial.print(stringOut);
Serial.println();
delay(1000); // Pause for 1 seconds.
}