-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrhvWeatherSketch
More file actions
723 lines (632 loc) · 20.3 KB
/
rhvWeatherSketch
File metadata and controls
723 lines (632 loc) · 20.3 KB
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
/*
RHV 0.2 edit 4
Sensor data collection and display
Polls the weather sensor and other sensors, calculate totals and averages,
wind gust speed, wind direction.
Pushes data to Smart Object Observable Property resource
*/
#include <PString.h> // for printing to a buffer
#include <SPI.h>
#include <Ethernet.h>
#include <Wire.h>
#define uint unsigned int
#define ulong unsigned long
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x75, 0xF3 };
byte ip[] = { 10,0,0,244 };
byte gateway[] = {10,0,0,1};
byte subnet[] = {255, 255, 255, 0 };
// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
//Server server(80);
// setup the server address, port, and path
byte objectServer[] = {10,0,0,14};
char serverName[] = "smartobjectservice.com";
unsigned serverPort = 8000;
char *serverPath = "/sensors/rhvWeather-01/";
EthernetClient client;
boolean lastConnected = false; // state of the connection last time through the main loop
//BMP085 stuff
#define BMP085_ADDRESS 0x77 // I2C address of BMP085
const unsigned char OSS = 0; // Oversampling Setting
// Calibration values
int ac1;
int ac2;
int ac3;
unsigned int ac4;
unsigned int ac5;
unsigned int ac6;
int b1;
int b2;
int mb;
int mc;
int md;
// b5 is calculated in bmp085GetTemperature(...), this variable is also used in bmp085GetPressure(...)
// so ...Temperature(...) must be called before ...Pressure(...).
long b5;
short raw_temperature;
long raw_pressure;
float indoor_temperature = 0.0;
float indoor_pressure = 0.0;
float sealevel_pressure = 0.0;
float indoor_humidity = 0.0;
float pressure = 0.0;
float temperature = 0.0;
float humidity = 0.0;
//SHT15 stuff
int temperatureCommand = B00000011; // command used to read temperature
int humidityCommand = B00000101; // command used to read humidity
int clockPin = 6; // pin used for clock
int dataPin = 7; // pin used for data
int ack; // track acknowledgment for errors
int val;
float outside_temperature = 0.0;
float outside_humidity = 0.0;
//weather sensor stuff
#define PIN_ANEMOMETER 2 // Digital 2
#define PIN_RAINGAUGE 3 // Digital 3
#define PIN_VANE 1 // Analog 5
// How often we want poll the sensors and push data to the backend
#define MSECS_POLL_INTERVAL 5000 // poll the sensors every 5 second
#define MSECS_PUSH_INTERVAL 1000 // push one data point each time
#define MSECS_PER_HOUR 3600000
volatile int numRevsAnemometer = 0; // Incremented in the interrupt
volatile int numTipsRain = 0; // Incremented in the interrupt
volatile unsigned long lastTip = millis(); // for debounce of the rain gauge
ulong nextPoll; // When we next poll sensors
ulong nextPush; // When we next push data to the backend
ulong time; // Millis() at each start of loop().
ulong lastMillis = 0;
ulong elapsedMillis = 0;
int hour = 0;
int lastHour = 0;
float windSpeed = 0;
float windGust = 0;
float dailyRain = 0;
float currRain = 0;
float hourlyRain[24] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
// ADC readings:
#define NUMDIRS 8
ulong adc[NUMDIRS] = {26, 45, 77, 118, 161, 196, 220, 256};
// These directions match 1-for-1 with the values in adc, but
// will have to be adjusted as noted above. Modify 'dirOffset'
// to which direction is 'away' (it's West here).
//char *strVals[NUMDIRS] = {" W "," NW"," N "," SW"," NE"," S "," SE"," E "};
char *strVals[NUMDIRS] = {"270","315","0","225","45","180","135","90"};
char *windDirection = "0";
byte dirOffset=0;
int nextPushPoint=0;
char objectBuffer[20];
void setup()
{
// start the Ethernet connection and the server:
// Ethernet.begin(mac, ip);
// Ethernet.begin(mac, ip);
Ethernet.begin(mac);
Serial.print("My IP address: ");
for (byte thisByte = 0; thisByte < 4; thisByte++) {
// print the value of each byte of the IP address:
Serial.print(Ethernet.localIP()[thisByte], DEC);
Serial.print(".");
}
Serial.println();
// server.begin();
Serial.begin(9600);
Serial.println("Starting Weather Sensor");
Wire.begin();
bmp085Calibration();
pinMode(PIN_ANEMOMETER, INPUT);
digitalWrite(PIN_ANEMOMETER, HIGH);
pinMode(PIN_RAINGAUGE, INPUT);
digitalWrite(PIN_RAINGAUGE, HIGH);
attachInterrupt(0, countAnemometer, FALLING);
attachInterrupt(1, countRainGauge, RISING);
nextPoll = millis() + MSECS_POLL_INTERVAL;
nextPush = millis() + MSECS_PUSH_INTERVAL;
}
void loop()
{
// poll interval check and poll
time = millis();
if (time >= nextPoll) {
nextPoll = time + MSECS_POLL_INTERVAL;
pollSensors();
}
// if there's incoming data from the net connection.
// send it out the serial port.
if (client.available()) {
char c = client.read();
Serial.print(c);
}
// if there's no net connection, but there was one last time
// through the loop, then stop the client:
if (!client.connected() && lastConnected) {
Serial.println();
Serial.println("disconnect");
client.stop();
}
if( !client.connected() && time >= nextPush ) {
nextPush = time + MSECS_PUSH_INTERVAL;
pushData();
}
lastConnected = client.connected();
}
void pollSensors()
{
// read weather sensors
calcWindSpeed();
calcWindDir();
calcRainFall();
// read the BMP085 barometric sensor
raw_temperature = bmp085GetTemperature(bmp085ReadUT());
raw_pressure = bmp085GetPressure(bmp085ReadUP());
indoor_temperature = (9.0/5.0 * (float(raw_temperature/10.0))) + 32.0;
temperature = indoor_temperature;
pressure = float(raw_pressure)/100.0;
sealevel_pressure = float(raw_pressure)/100.0;
// read the SHT015 humidity and temp sensor
//sendCommandSHT(temperatureCommand, dataPin, clockPin);
//waitForResultSHT(dataPin);
//val = getData16SHT(dataPin, clockPin);
//skipCrcSHT(dataPin, clockPin);
//outside_temperature = 9.0/5.0 * ((float)val * 0.01 - 40) + 32;
// read the humidity
//sendCommandSHT(humidityCommand, dataPin, clockPin);
//waitForResultSHT(dataPin);
//val = getData16SHT(dataPin, clockPin);
//skipCrcSHT(dataPin, clockPin);
//outside_humidity = -4.0 + 0.0405 * val + -0.0000028 * val * val;
//outside_humidity = -2.0468 + 0.0367 * val + -0.0000015955 * val * val;
// read the analog indoor humidity sensor and scale
indoor_humidity = ((analogRead(0)*5000.0/1024.0)-958.0)/30.68;
humidity = indoor_humidity;
}
void pushData()
{
for (byte thisByte = 0; thisByte < 4; thisByte++) {
// print the value of each byte of the IP address:
Serial.print(Ethernet.localIP()[thisByte], DEC);
Serial.print(".");
}
Serial.println();
if(client.connect(objectServer,serverPort)) {
Serial.println("connect OK");
PString jsonObject(objectBuffer, sizeof(objectBuffer));
if(nextPushPoint==0) {
nextPushPoint=1;
jsonObject.println(outside_temperature,1);
client.print("PUT ");
client.print(serverPath);
client.print("outdoor_temperature");
client.println(" HTTP/1.1");
client.println("Content-Type: application/json");
client.print("Content-Length: ");
client.println(jsonObject.length()-2);
client.println("Connection: close");
client.println();
client.println(jsonObject);
}
else if(nextPushPoint==1) {
nextPushPoint=2;
jsonObject.println(outside_humidity,1);
client.print("PUT ");
client.print(serverPath);
client.print("outdoor_humidity");
client.println(" HTTP/1.1");
client.println("Content-Type: application/json");
client.print("Content-Length: ");
client.println(jsonObject.length()-2);
client.println("Connection: close");
client.println();
client.println(jsonObject);
}
else if(nextPushPoint==2) {
nextPushPoint=3;
jsonObject.println(sealevel_pressure,1);
client.print("PUT ");
client.print(serverPath);
client.print("sealevel_pressure");
client.println(" HTTP/1.1");
client.println("Content-Type: application/json");
client.print("Content-Length: ");
client.println(jsonObject.length()-2);
client.println("Connection: close");
client.println();
client.println(jsonObject);
}
else if(nextPushPoint==3) {
nextPushPoint=4;
jsonObject.println(indoor_temperature,1);
client.print("PUT ");
client.print(serverPath);
client.print("indoor_temperature");
client.println(" HTTP/1.1");
client.println("Content-Type: application/json");
client.print("Content-Length: ");
client.println(jsonObject.length()-2);
client.println("Connection: close");
client.println();
client.println(jsonObject);
}
else if(nextPushPoint==4) {
nextPushPoint=5;
jsonObject.println(indoor_humidity,1);
client.print("PUT ");
client.print(serverPath);
client.print("indoor_humidity");
client.println(" HTTP/1.1");
client.println("Content-Type: application/json");
client.print("Content-Length: ");
client.println(jsonObject.length()-2);
client.println("Connection: close");
client.println();
client.println(jsonObject);
}
else if(nextPushPoint==5) {
nextPushPoint=6;
jsonObject.println(windGust,1);
windGust=0;
client.print("PUT ");
client.print(serverPath);
client.print("wind_gust");
client.println(" HTTP/1.1");
client.println("Content-Type: application/json");
client.print("Content-Length: ");
client.println(jsonObject.length()-2);
client.println("Connection: close");
client.println();
client.println(jsonObject);
}
else if(nextPushPoint==6) {
nextPushPoint=7;
jsonObject.println(windSpeed,1);
client.print("PUT ");
client.print(serverPath);
client.print("wind_speed");
client.println(" HTTP/1.1");
client.println("Content-Type: application/json");
client.print("Content-Length: ");
client.println(jsonObject.length()-2);
client.println("Connection: close");
client.println();
client.println(jsonObject);
}
else if(nextPushPoint==7) {
nextPushPoint=8;
jsonObject.println(windDirection);
client.print("PUT ");
client.print(serverPath);
client.print("wind_direction");
client.println(" HTTP/1.1");
client.println("Content-Type: application/json");
client.print("Content-Length: ");
client.println(jsonObject.length()-2);
client.println("Connection: close");
client.println();
client.println(jsonObject);
}
else if(nextPushPoint==8) {
nextPushPoint=9;
jsonObject.println(currRain,1);
client.print("PUT ");
client.print(serverPath);
client.print("current_rain");
client.println(" HTTP/1.1");
client.println("Content-Type: application/json");
client.print("Content-Length: ");
client.println(jsonObject.length()-2);
client.println("Connection: close");
client.println();
client.println(jsonObject);
}
else if(nextPushPoint==9) {
nextPushPoint=10;
jsonObject.println(hourlyRain[lastHour]);
client.print("PUT ");
client.print(serverPath);
client.print("hourly_rain");
client.println(" HTTP/1.1");
client.println("Content-Type: application/json");
client.print("Content-Length: ");
client.println(jsonObject.length()-2);
client.println("Connection: close");
client.println();
client.println(jsonObject);
}
else if(nextPushPoint==10) {
nextPushPoint=0;
jsonObject.println(dailyRain,1);
client.print("PUT ");
client.print(serverPath);
client.print("daily_rain");
client.println(" HTTP/1.1");
client.println("Content-Type: application/json");
client.print("Content-Length: ");
client.println(jsonObject.length()-2);
client.println("Connection: close");
client.println();
client.println(jsonObject);
}
}
else {
Serial.println("connect to server failed");
client.stop();
}
}
// Stores all of the bmp085's calibration values into global variables
// Calibration values are required to calculate temp and pressure
// This function should be called at the beginning of the program
void bmp085Calibration()
{
ac1 = bmp085ReadInt(0xAA);
ac2 = bmp085ReadInt(0xAC);
ac3 = bmp085ReadInt(0xAE);
ac4 = bmp085ReadInt(0xB0);
ac5 = bmp085ReadInt(0xB2);
ac6 = bmp085ReadInt(0xB4);
b1 = bmp085ReadInt(0xB6);
b2 = bmp085ReadInt(0xB8);
mb = bmp085ReadInt(0xBA);
mc = bmp085ReadInt(0xBC);
md = bmp085ReadInt(0xBE);
}
// Calculate temperature given ut.
// Value returned will be in units of 0.1 deg C
short bmp085GetTemperature(unsigned int ut)
{
long x1, x2;
x1 = (((long)ut - (long)ac6)*(long)ac5) >> 15;
x2 = ((long)mc << 11)/(x1 + md);
b5 = x1 + x2;
return ((b5 + 8)>>4);
}
// Calculate pressure given up
// calibration values must be known
// b5 is also required so bmp085GetTemperature(...) must be called first.
// Value returned will be pressure in units of Pa.
long bmp085GetPressure(unsigned long up)
{
long x1, x2, x3, b3, b6, p;
unsigned long b4, b7;
b6 = b5 - 4000;
// Calculate B3
x1 = (b2 * (b6 * b6)>>12)>>11;
x2 = (ac2 * b6)>>11;
x3 = x1 + x2;
b3 = (((((long)ac1)*4 + x3)<<OSS) + 2)>>2;
// Calculate B4
x1 = (ac3 * b6)>>13;
x2 = (b1 * ((b6 * b6)>>12))>>16;
x3 = ((x1 + x2) + 2)>>2;
b4 = (ac4 * (unsigned long)(x3 + 32768))>>15;
b7 = ((unsigned long)(up - b3) * (50000>>OSS));
if (b7 < 0x80000000)
p = (b7<<1)/b4;
else
p = (b7/b4)<<1;
x1 = (p>>8) * (p>>8);
x1 = (x1 * 3038)>>16;
x2 = (-7357 * p)>>16;
p += (x1 + x2 + 3791)>>4;
return p;
}
// Read 1 byte from the BMP085 at 'address'
char bmp085Read(unsigned char address)
{
unsigned char data;
Wire.beginTransmission(BMP085_ADDRESS);
Wire.write(address);
Wire.endTransmission();
Wire.requestFrom(BMP085_ADDRESS, 1);
while(!Wire.available())
;
return Wire.read();
}
// Read 2 bytes from the BMP085
// First byte will be from 'address'
// Second byte will be from 'address'+1
int bmp085ReadInt(unsigned char address)
{
unsigned char msb, lsb;
Wire.beginTransmission(BMP085_ADDRESS);
Wire.write(address);
Wire.endTransmission();
Wire.requestFrom(BMP085_ADDRESS, 2);
while(Wire.available()<2)
;
msb = Wire.read();
lsb = Wire.read();
return (int) msb<<8 | lsb;
}
// Read the uncompensated temperature value
unsigned int bmp085ReadUT()
{
unsigned int ut;
// Write 0x2E into Register 0xF4
// This requests a temperature reading
Wire.beginTransmission(BMP085_ADDRESS);
Wire.write(0xF4);
Wire.write(0x2E);
Wire.endTransmission();
// Wait at least 4.5ms
delay(5);
// Read two bytes from registers 0xF6 and 0xF7
ut = bmp085ReadInt(0xF6);
return ut;
}
// Read the uncompensated pressure value
unsigned long bmp085ReadUP()
{
unsigned char msb, lsb, xlsb;
unsigned long up = 0;
// Write 0x34+(OSS<<6) into register 0xF4
// Request a pressure reading w/ oversampling setting
Wire.beginTransmission(BMP085_ADDRESS);
Wire.write(0xF4);
Wire.write(0x34 + (OSS<<6));
Wire.endTransmission();
// Wait for conversion, delay time dependent on OSS
delay(2 + (3<<OSS));
// Read register 0xF6 (MSB), 0xF7 (LSB), and 0xF8 (XLSB)
Wire.beginTransmission(BMP085_ADDRESS);
Wire.write(0xF6);
Wire.endTransmission();
Wire.requestFrom(BMP085_ADDRESS, 3);
// Wait for data to become available
while(Wire.available() < 3)
;
msb = Wire.read();
lsb = Wire.read();
xlsb = Wire.read();
up = (((unsigned long) msb << 16) | ((unsigned long) lsb << 8) | (unsigned long) xlsb) >> (8-OSS);
return up;
}
//SHT015 functions
// commands for reading/sending data to a SHTx sensor
// send a command to the SHTx sensor
void sendCommandSHT(int command, int dataPin, int clockPin) {
int ack;
// transmission start
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
digitalWrite(dataPin, HIGH);
digitalWrite(clockPin, HIGH);
digitalWrite(dataPin, LOW);
digitalWrite(clockPin, LOW);
digitalWrite(clockPin, HIGH);
digitalWrite(dataPin, HIGH);
digitalWrite(clockPin, LOW);
// shift out the command (the 3 MSB are address and must be 000, the last 5 bits are the command)
shiftOut(dataPin, clockPin, MSBFIRST, command);
// verify we get the right ACK
digitalWrite(clockPin, HIGH);
pinMode(dataPin, INPUT);
ack = digitalRead(dataPin);
if (ack != LOW);
// Serial.println("ACK error 0");
digitalWrite(clockPin, LOW);
ack = digitalRead(dataPin);
if (ack != HIGH);
// Serial.println("ACK error 1");
}
// wait for the SHTx answer
void waitForResultSHT(int dataPin) {
int ack;
pinMode(dataPin, INPUT);
for (int i=0; i<100; ++i) {
delay(20);
ack = digitalRead(dataPin);
if (ack == LOW)
break;
}
if (ack == HIGH);
// Serial.println("ACK error 2");
}
// get data from the SHTx sensor
int getData16SHT(int dataPin, int clockPin) {
int val;
// get the MSB (most significant bits)
pinMode(dataPin, INPUT);
pinMode(clockPin, OUTPUT);
val = shiftIn(dataPin, clockPin, MSBFIRST);
val *= 256; // this is equivalent to val << 8;
// send the required ACK
pinMode(dataPin, OUTPUT);
digitalWrite(dataPin, HIGH);
digitalWrite(dataPin, LOW);
digitalWrite(clockPin, HIGH);
digitalWrite(clockPin, LOW);
// get the LSB (less significant bits)
pinMode(dataPin, INPUT);
val |= shiftIn(dataPin, clockPin, MSBFIRST);
return val;
}
// skip CRC data from the SHTx sensor
void skipCrcSHT(int dataPin, int clockPin) {
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
digitalWrite(dataPin, HIGH);
digitalWrite(clockPin, HIGH);
digitalWrite(clockPin, LOW);
}
//=======================================================
// Interrupt handler for anemometer. Called each time the reed
// switch triggers (one revolution).
//=======================================================
void countAnemometer() {
numRevsAnemometer++;
}
//=======================================================
// Interrupt handler for rain gauge. Called each time the reed
// switch triggers (.011 inches). Most Arduino boards have two external interrupts: numbers 0 (on digital pin 2) and 1 (on digital pin 3).
//=======================================================
void countRainGauge() {
if(millis() - lastTip > 100)
{
numTipsRain++;
lastTip = millis();
}
}
//=======================================================
// Find vane direction.
//=======================================================
void calcWindDir() {
int val;
byte x, reading;
val = analogRead(PIN_VANE);
val >>=2; // Shift to 255 range
reading = val;
// Look the reading up in directions table. Find the first value
// that's >= to what we got.
for (x=0; x<NUMDIRS; x++) {
if (adc[x] >= reading)
break;
}
//Serial.println(reading, DEC);
x = (x + dirOffset) % 8; // Adjust for orientation
// Serial.print(" Dir: ");
// Serial.println(strVals[x]);
windDirection = strVals[x];
}
//=======================================================
// Calculate the wind speed, and display it (or log it, whatever).
// 1 rev/sec = 1.492 mph
//=======================================================
void calcWindSpeed() {
windSpeed = float(numRevsAnemometer) / float(MSECS_POLL_INTERVAL) * 1492.0;
if(windSpeed > windGust) windGust = windSpeed;
// Serial.print("Wind speed: ");
// Serial.print(windSpeed,1);
numRevsAnemometer = 0; // Reset counter
}
void calcRainFall() {
//Each interrupt represents.011 inches of rain, according to the docs.
currRain = currRain + (numTipsRain*.011);
numTipsRain = 0;
elapsedMillis = millis() - lastMillis;
if ( elapsedMillis >= MSECS_PER_HOUR ) // calc 1 hour of rain and keep in array hour[23].
{
hourlyRain[hour] = currRain;
currRain=0;
lastMillis= millis();
lastHour = hour;
hour++;
if (hour>23)
{
hour=0;
}
}
dailyRain=0;
for (int hourz = 0; hourz < 23; hourz++) // add up last 24 hours of rain
{
dailyRain = dailyRain + hourlyRain[hourz];
}
// Serial.print("this hour rainfall = ");
// Serial.println(currRain,2);
// Serial.print("previous hour of rain = ");
// Serial.println(hourlyRain[lastHour],2);
// Serial.print("Last 24 hrs of rain = ");
// Serial.println(dailyRain,2);
}