-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv24.ino
More file actions
1470 lines (1174 loc) · 41.3 KB
/
v24.ino
File metadata and controls
1470 lines (1174 loc) · 41.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
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//Arduino 1.5.6
//Wetterdisplay mit Uhrzeit
#include <Wire.h>
#include <UTFT.h>
#include <UTFT_DLB.h>
#include <RTClib.h>
#include "Adafruit_SHT31.h" //SHT 31 Außensensor
#include <SHT2x.h> //SHT21 Innensensor
#include <Adafruit_BMP085.h> //BMP085/BMP180
#include <SPI.h>
#include <SdFat.h>
#include <UTFT_SdRaw.h>
#include "sunrise.h" //library for sunrise/sunset calculations
#include <OneWire.h>
#include <DallasTemperature.h>
#include <DS1307.h>
#include <URTouch.h>
//RTC_DS1307 rtc;
RTC_DS3231 rtc;
// BMP085/BMP180
Adafruit_BMP085 bmp;
//SHT31
Adafruit_SHT31 sht31 = Adafruit_SHT31();
char Zeit[10];
char Datum[10];
char str[10];
char sunbuf[61]; // variable for output formatting
//DS18B20
//digitalWrite(pin,HIGH);
// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 43
//define TEMPERATURE_PRECISION 12
//#define TEMPERATURE_PRECISION 11
#define TEMPERATURE_PRECISION 10
//#define TEMPERATURE_PRECISION 9
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
//DeviceAdressen der einzelnen ds1820 Temperatursensoren angeben.
DeviceAddress temp1 = { 0x28, 0xD0, 0xC1, 0xD0, 0x04, 0x00, 0x00, 0xAA };
DeviceAddress temp2 = { 0x28, 0xC4, 0x6C, 0xD0, 0x04, 0x00, 0x00, 0xF2 };
DeviceAddress temp3 = { 0x28, 0xA4, 0x7A, 0xD0, 0x04, 0x00, 0x00, 0xD1 };
DeviceAddress temp4 = { 0x28, 0x5E, 0xD4, 0xD0, 0x04, 0x00, 0x00, 0xFD };
DeviceAddress temp5 = { 0x28, 0xAD, 0x0F, 0xE1, 0x04, 0x00, 0x00, 0x3F };
DeviceAddress temp6 = { 0x28, 0x17, 0xE5, 0x34, 0x05, 0x00, 0x00, 0xBB };
//SD Karte
#define SD_CHIP_SELECT 53 // SD chip select pin
// file system object
SdFat sd;
//For Sunrise and Sunset
#define LAT 48.61 // latitude in degrees, south is negative (used in sun calculation)
#define LON 9.54 // longitude in degrees, west is negative (used in sun calculation)
// Zeitintervalle setzen
int TeilerSeriell = 1; // Serielle Ausgabe alle 1 min
int TeilerTendenz = 15;
int TeilerDisplay = 1; // Serielle Ausgabe alle 1 min
// Timer setzen
unsigned long currentMillis;
unsigned long backlightMillis;
unsigned long SeriellMillis;
long SeriellIntervall = 1000;
unsigned long DisplayMillis;
long DisplayIntervall = 1000;
unsigned long TendenzMillis;
long TendenzIntervall = 1000;
// Variablen für Werteerfassung und Umrechnung deklarieren
int altitude = 385; // Höhe des Sensorstandortes ueber dem Meeresspiegel
float MaxTemp = -1000;
float MinTemp = 1000;
int lastDay;
float MaxTemp_Aussen = -1000;
float MinTemp_Aussen = 1000;
float MaxTemp_Innen = -1000;
float MinTemp_Innen = 1000;
float MaxHum_Aussen= -1000;
float MinHum_Aussen = 1000;
float MaxHum_Innen = -1000;
float MinHum_Innen = 1000;
float MaxLuftdruckWGT = -1000;
float MinLuftdruckWGT = 1000000;
float Temp_Aussen;
float Temp_Innen;
float Hum_Aussen;
float Hum_Innen;
float Temperatur;
float Luftdruck;
float LuftdruckWGT;
float humidex;
float dewpoint;
float atemp1;
float atemp2;
float atemp3;
float atemp4;
float atemp5;
float atemp6;
String Wetterstatus = "leer";
String Tendenz = "leer";
String Humidex_Message = "leer";
String nfm = "leer"; // days to next full moon
byte lastMinute; // To know if we have a new hour and new day in this reading.
byte currentMinute = 0; // Value to store the current hour
//**************************************************************************************************** -TEMP-GRAPH Variable Innen
int t1dp0y1,t1dp1y1,t1dp2y1,t1dp3y1,t1dp4y1,t1dp5y1,t1dp6y1,t1dp7y1,t1dp8y1, t1dp9y1,t1dp10y1,t1dp11y1;
int t1dp12y1,t1dp13y1,t1dp14y1,t1dp15y1,t1dp16y1,t1dp17y1,t1dp18y1,t1dp19y1,t1dp20y1,t1dp21y1,t1dp22y1,t1dp23y1;
int t1p0y1=187; int t1p1y1=187; int t1p2y1=187; int t1p3y1=187; int t1p4y1=187; int t1p5y1=187; int t1p6y1=187; int t1p7y1=187;
int t1p8y1=187; int t1p9y1=187; int t1p10y1=187; int t1p11y1=187; int t1p12y1=187; int t1p13y1=187; int t1p14y1=187; int t1p15y1=187;
int t1p16y1=187; int t1p17y1=187; int t1p18y1=187; int t1p19y1=187; int t1p20y1=187; int t1p21y1=187; int t1p22y1=187; int t1p23y1=187;
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Backlight und Näherungssensor
const int backlight_pin = 44; // ON CTE SHIELD JP5 Closed/Soldered. JP3 and JP4 open.
const int backlight_on = 255;
const int backlight_off = 0;
const int STATE = 49; // sets pin 49 for sensor reading
int r_state = 0; // reset to zero the variable used to read the state of the OUT pin of the sensor
// Declare which fonts we will be using
extern uint8_t SmallFont[];
//extern uint8_t BigFont[];
//extern uint8_t SevenSegNumFont[];
//extern uint8_t DejaVuSans18[];
//extern uint8_t DejaVuSans24[];
//extern uint8_t meteocons38[];
extern uint8_t BVS_9[];
extern uint8_t BVS_7[];
extern uint8_t BVS_11[];
extern uint8_t BVS_13[];
extern uint8_t BVS_15[];
extern uint8_t BVS_19[];
extern uint8_t BVS_22[];
extern uint8_t BVS_28[];
extern uint8_t BVS_34[];
extern uint8_t BVS_43[];
// Using Arduino Mega and 7 TFT LCD SSD1963 800x480 Display
//UTFT myGLCD(CTE70,38,39,40,41);
UTFT_DLB myGLCD(CTE70,38,39,40,41);
//Touch
URTouch myTouch(6,5,4,3,2);
//Variable für Zeitstellmenue
Time t;
DS1307 rtc2(20, 21);
// Variablen für Tendenz P-Zeit in Minuten
float Pnow;
float P15;
float P30;
float P45;
float P60; //1h
float P75;
float P90;
float P105;
float P120; //2h
float P135;
float P150;
float P165;
float P180; //3h
// Color set
#define BLACK 0x0000
#define RED 0xF800
#define GREEN 0x07E0
#define BLUE 0x001F
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define ORANGE 0xFD20
#define GREENa 0xAFE5
#define DARKGREEN 0x03E0
#define WHITE 0xFFFF
#define TUERKIS 0x14d3
#define GRUEN 0x2e63
#define BLAU 0x1b37
//touch reads
int x; int y;
//Buttons
int x21=7; int y21=297; int x22=105; int y22=325; // Menu 1
int x31=7; int y31=y22+10; int x32=105; int y32=y31+28; // Menu 2
int x41=7; int y41=y32+10; int x42=105; int y42=y41+28; // Menu 3
int x51=7; int y51=y42+10; int x52=105; int y52=y51+28; // Menu 4
int x61=7; int y61=y52+10; int x62=105; int y62=y61+28; // Menu 5
//Variablen für Graphen
int historyTempInnen[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int historyTempAussen[] = {-15,-15,-15,-15,-15,-15,-15,-15,-15,-15,-15,-15,-15,-15,-15,-15,-15,-15,-15,-15,-15,-15,-15,-15};
int historyHumInnen[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int historyHumAussen[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
UTFT_SdRaw myFiles(&myGLCD);
void setup()
{
Serial.begin(9600);
rtc.begin(); //RTC starten
Wire.begin();
bmp.begin(); // BMP starten
sht31.begin(0x44); // SHT31 starten
sensors.begin(); // DS18B20 starten
rtc2.begin(); //RTC Menue
// Set the clock to run-mode
rtc2.halt(false); //RTC Menue
sensors.setResolution(temp1, TEMPERATURE_PRECISION);
sensors.setResolution(temp2, TEMPERATURE_PRECISION);
sensors.setResolution(temp3, TEMPERATURE_PRECISION);
sensors.setResolution(temp4, TEMPERATURE_PRECISION);
sensors.setResolution(temp5, TEMPERATURE_PRECISION);
sensors.setResolution(temp6, TEMPERATURE_PRECISION);
pinMode (backlight_pin, OUTPUT); // sets pin 44 as analog output
pinMode (STATE, INPUT); // sets pin 49 as digital input
Serial.println(F("Initialising SD card..."));
bool mysd = 0;
// see if the card is present and can be initialized:
while (!mysd)
{
if (!sd.begin(SD_CHIP_SELECT, SPI_FULL_SPEED)) {
Serial.println(F("Card failed, or not present"));
Serial.println(F("Retrying...."));
}
else
{
mysd = 1;
Serial.println(F("Card initialised."));
}
}
initLCD();
initGraphics();
//rtc.adjust(DateTime(__DATE__, __TIME__)); // EINMALIG: kalibrieren der Uhr mit PC
// Druck für Tendenz Startwert in alle Variablen schreiben
Luftdruck = bmp.readPressure(); // Erfasse Luftdruck
LuftdruckWGT = bmp.readSealevelPressure(altitude)/100.0F;
Pnow = LuftdruckWGT;
P15 = LuftdruckWGT;
P30 = LuftdruckWGT;
P45 = LuftdruckWGT;
P60 = LuftdruckWGT; //1h
P75 = LuftdruckWGT;
P90 = LuftdruckWGT;
P105 = LuftdruckWGT;
P120 = LuftdruckWGT; //2h
P135 = LuftdruckWGT;
P150 = LuftdruckWGT;
P165 = LuftdruckWGT;
P180 = LuftdruckWGT; //3h
Tendenz = "Erhebe Daten";
}
void loop()
{
//Menue für Uhrzeit
t = rtc2.getTime();
//Seite Menue
if (myTouch.dataAvailable())
{
myTouch.read();
x=myTouch.getX();
y=myTouch.getY();
// Menu 1
if ((y>=y21) && (y<=y22))
{
if ((x>=x21) && (x<=x22))
{
Redbox(x21,y21,x22,y22);
bargraph_verlauf();
}
}
//End Menu 1
// Menu 2
if ((y>=y31) && (y<=y32))
{
if ((x>=x31) && (x<=x32))
{
Redbox(x31,y31,x32,y32);
kurve_verlauf();
}
}
//End Menu 2
// Menu 3
if ((y>=y41) && (y<=y42))
{
if ((x>=x41) && (x<=x42))
{
Redbox(x41,y41,x42,y42);
bargraph_verlauf();
}
}
//End Menu 3
// Menu 4
if ((y>=y51) && (y<=y52))
{
if ((x>=x51) && (x<=x52))
{
Redbox(x51,y51,x52,y52);
bargraph_verlauf();
}
}
//End Menu 4
// Menu 5
if ((y>=y61) && (y<=y62))
{
if ((x>=x61) && (x<=x62))
{
Redbox(x61,y61,x62,y62);
setClock();
}
}
//End Menu 5
}
// Teil 1 Berechnung aller Werte...
//
Luftdruck = bmp.readPressure(); // Erfasse Luftdruck
//Temperatur = bmp.readTemperature(); // Erfasse Temperatur
Temp_Aussen = sht31.readTemperature();
Temp_Innen = SHT2x.GetTemperature();
Hum_Aussen = sht31.readHumidity();
Hum_Innen = SHT2x.GetHumidity();
LuftdruckWGT = bmp.readSealevelPressure(altitude)/100.0F;
humidex = calculate_humidex (Temp_Aussen, Hum_Aussen); //Aussensensor
dewpoint = dewPoint(Temp_Innen, Hum_Innen); //Innensensor
// themperatures from all sensors DS18B20
sensors.requestTemperatures();
// save themperatures to values DS18B20
atemp1 = sensors.getTempC(temp1);
atemp2 = sensors.getTempC(temp2);
atemp3 = sensors.getTempC(temp3);
atemp4 = sensors.getTempC(temp4);
atemp5 = sensors.getTempC(temp5);
atemp6 = sensors.getTempC(temp6);
if(Temp_Aussen < MinTemp_Aussen) {MinTemp_Aussen = Temp_Aussen;}
if(Temp_Aussen > MaxTemp_Aussen) {MaxTemp_Aussen = Temp_Aussen;}
if(Temp_Innen < MinTemp_Innen) {MinTemp_Innen = Temp_Innen;}
if(Temp_Innen > MaxTemp_Innen) {MaxTemp_Innen = Temp_Innen;}
if(Hum_Aussen < MinHum_Aussen) {MinHum_Aussen = Hum_Aussen;}
if(Hum_Aussen > MaxHum_Aussen) {MaxHum_Aussen = Hum_Aussen;}
if(Hum_Innen < MinHum_Innen) {MinHum_Innen = Hum_Innen;}
if(Hum_Innen > MaxHum_Innen) {MaxHum_Innen = Hum_Innen;}
if(LuftdruckWGT < MinLuftdruckWGT) {MinLuftdruckWGT = LuftdruckWGT;}
if(LuftdruckWGT > MaxLuftdruckWGT) {MaxLuftdruckWGT = LuftdruckWGT;}
// WetterAktuell:
if ((LuftdruckWGT <= 980)&& (Temp_Aussen >= 0)){Wetterstatus = "Sturm, Regen";}
if ((LuftdruckWGT <= 980)&& (Temp_Aussen < 0)){Wetterstatus = "Sturm, Schnee";}
if ((LuftdruckWGT > 980) && (LuftdruckWGT <= 1000) && (Temp_Aussen >= 0)) {Wetterstatus = "Regnerisch";}
if ((LuftdruckWGT > 980) && (LuftdruckWGT <= 1000) && (Temp_Aussen < 0)) {Wetterstatus = "Schneeschauer";}
if ((LuftdruckWGT > 1000) && (LuftdruckWGT <= 1020)){Wetterstatus = "Wechselhaft";}
if ((LuftdruckWGT > 1020) && (LuftdruckWGT <= 1040)){Wetterstatus = "Sonnig,bestaendig";}
if (LuftdruckWGT > 1040){Wetterstatus = "Trocken,Gewitter";}
//Alternative Werte
//970 bis 987, Sturm
//988 bis 1001, Regen
//1002 bis 1026, wechselhaft
//1027 bis 1042, schön
//1043 bis 1060, trocken
currentMillis = millis(); // Timer für jeden Durchgang setzten.
//Serial.println(currentMillis);
DateTime aktuell = rtc.now();
// Teil 2 Tendenzen berechen..
//
if ((aktuell.second() >= 0 ) && (aktuell.second() <= 3 ) && (aktuell.minute()%TeilerTendenz == 0)) // Wenn die aktuelle Minute durch 15 teilbar ist, dann....
{
if(currentMillis - TendenzMillis > TendenzIntervall)
{
// Register eins weiterschieben
Serial.println("Register eins weiterschieben");
P180 = P165;
P165 = P150;
P150 = P135;
P135 = P120;
P120 = P105;
P105 = P90;
P90 = P75;
P75 = P60;
P60 = P45;
P45 = P30;
P30 = P15;
P15 = Pnow;
Pnow = LuftdruckWGT;
// Tendenz berechnen
if( Pnow-P180 <= -8 ){Tendenz ="Sturm mit Hagel"; }
if((Pnow-P180 <= -5 ) && (Pnow-P180 > -8 )){Tendenz ="Regen/Unwetter";}
if((Pnow-P180 <= -3 ) && (Pnow-P180 > -5 )){Tendenz ="Regnerisch";}
if((Pnow-P180 <= -1.3) && (Pnow-P180 > -3 )){Tendenz ="baldiger Regen";}
if((Pnow-P180 <= 1.3 ) && (Pnow-P180 > -1.3)){Tendenz ="gleichbleibend";}
if((Pnow-P180 <= 3 ) && (Pnow-P180 >= 1.3)){Tendenz ="lange Schoen";}
if((Pnow-P180 <= 5 ) && (Pnow-P180 >= 3 )){Tendenz ="Schoen & labil";}
if( Pnow-P180 > 5 ){Tendenz = "Sturmwarnung";}
// Tendenz Alternativ berechnen
//if( Pnow-P180 <= -8 ){Tendenz ="Sturm mit Hagel";}
//if((Pnow-P180 <= -5 ) && (Pnow-P180 > -8 )){Tendenz ="Regen/Unwetter";}
//if((Pnow-P180 <= -3 ) && (Pnow-P180 > -5 )){Tendenz ="Regnerisch";}
//if((Pnow-P180 <= -0.5) && (Pnow-P180 > -3 )){Tendenz ="baldiger Regen";}
//if((Pnow-P180 <= 0.5 ) && (Pnow-P180 > -0.5)){Tendenz ="gleichbleibend";}
//if((Pnow-P180 <= 3 ) && (Pnow-P180 >= 0.5)){Tendenz ="lange Schoen";}
//if((Pnow-P180 <= 5 ) && (Pnow-P180 >= 3 )){Tendenz ="Schoen & labil";}
//if( Pnow-P180 > 5 ){Tendenz = "Sturmwarnung";}
TendenzMillis = currentMillis;
//Serial.println(TendenzMillis);
}
}
// Teil 3 Humudex_Meldung
if ((humidex >= 21 )&&(humidex < 27))
{
Humidex_Message= "Angenehm"; //No discomfort
}
if ((humidex >= 27 )&&(humidex < 35))
{
Humidex_Message= "Leichtes Unbehagen"; //Some discomfort
}
if ((humidex >= 35 )&&(humidex < 40))
{
Humidex_Message= "Starkes Unbehagen"; //Great discomfort
}
if ((humidex >= 40 )&&(humidex < 46))
{
Humidex_Message= "Gesundheitsgefahr"; //Health risk
}
if ((humidex >= 46 )&&(humidex < 54))
{
Humidex_Message= "Große Gesundheitsgefahr"; //Great health risk
}
if ((humidex >= 54 ))
{
Humidex_Message= "Hitzschlagsgefahr"; //Heat stroke danger
}
// Teil 4 Ausgabe Serielle Schnittstelle
if ((aktuell.second() >= 0 ) && (aktuell.second() <= 3 ) && (aktuell.minute()%TeilerSeriell == 0))
{
if(currentMillis - SeriellMillis > SeriellIntervall)
{
if (aktuell.day() < 10){Serial.print(F("0"));} // EXCEL DATUM: "TT.MM.JJJJ HH:MM:SS"
Serial.print(aktuell.day());
Serial.print(F("."));
if (aktuell.month() < 10){Serial.print(F("0"));}
Serial.print(aktuell.month());
Serial.print(F("."));
Serial.print(aktuell.year());
Serial.print(F(" "));
if (aktuell.hour() < 10){Serial.print(F("0"));}
Serial.print(aktuell.hour());
Serial.print(F(":"));
if (aktuell.minute() < 10){Serial.print(F("0"));}
Serial.print(aktuell.minute());
Serial.print(F(":"));
if (aktuell.second() < 10){Serial.print(F("0"));}
Serial.print(aktuell.second());
Serial.println(F(" "));
Serial.print(F("Luftdruck"));
Serial.print(F(" "));
Serial.println(LuftdruckWGT);
Serial.print(F("Delta 3h"));
Serial.print(F(" "));
Serial.println(Pnow-P180);
Serial.print(F("Delta 1h"));
Serial.print(F(" "));
Serial.println(Pnow-P90);
Serial.print(F("Wetterstatus"));
Serial.print(F(" "));
Serial.println(Wetterstatus);
Serial.print(F("Tendenz"));
Serial.print(F(" "));
Serial.println(Tendenz); // println für neue Zeile
Serial.print(F("Temp_Aussen"));
Serial.print(F(" "));
Serial.println(Temp_Aussen);
Serial.print(F("Temp_Innen"));
Serial.print(F(" "));
Serial.println(Temp_Innen);
Serial.print(F("Hum_Aussen"));
Serial.print(F(" "));
Serial.println(Hum_Aussen);
Serial.print(F("Hum_Innen"));
Serial.print(F(" "));
Serial.println(Hum_Innen);
Serial.print(F("Humidex Aussen"));
Serial.print(F(" "));
Serial.println(humidex);
Serial.print(F("Taupunkt Innen"));
Serial.print(F(" "));
Serial.println(dewpoint);
Serial.print(F("Humidex"));
Serial.print(F(" "));
Serial.println(Humidex_Message);
Serial.print(F("MinTemp_Aussen"));
Serial.print(F(" "));
Serial.println(MinTemp_Aussen);
Serial.print(F("MaxTemp_Aussen"));
Serial.print(F(" "));
Serial.println(MaxTemp_Aussen);
Serial.print(F("MinTemp_Innen"));
Serial.print(F(" "));
Serial.println(MinTemp_Innen);
Serial.print(F("MaxTemp_Innen"));
Serial.print(F(" "));
Serial.println(MaxTemp_Innen);
Serial.print(F("MinHum_Aussen"));
Serial.print(F(" "));
Serial.println(MinHum_Aussen);
Serial.print(F("MaxHum_Aussen"));
Serial.print(F(" "));
Serial.println(MaxHum_Aussen);
Serial.print(F("MinHum_Innen"));
Serial.print(F(" "));
Serial.println(MinHum_Innen);
Serial.print(F("MaxHum_Innen"));
Serial.print(F(" "));
Serial.println(MaxHum_Innen);
Serial.print(F("MinLuftdruckWGT"));
Serial.print(F(" "));
Serial.println(MinLuftdruckWGT);
Serial.print(F("MaxLuftdruckWGT"));
Serial.print(F(" "));
Serial.println(MaxLuftdruckWGT);
Serial.print(F("1-Wire Nr. 1"));
Serial.print(F(" "));
Serial.println(atemp1);
Serial.print(F("1-Wire Nr. 2"));
Serial.print(F(" "));
Serial.println(atemp2);
Serial.print(F("1-Wire Nr. 3"));
Serial.print(F(" "));
Serial.println(atemp3);
Serial.print(F("1-Wire Nr. 4"));
Serial.print(F(" "));
Serial.println(atemp4);
Serial.print(F("1-Wire Nr. 5"));
Serial.print(F(" "));
Serial.println(atemp5);
Serial.print(F("1-Wire Nr. 6"));
Serial.print(F(" "));
Serial.println(atemp6);
SeriellMillis = currentMillis;
//Serial.println(SeriellMillis);
}
}
// Teil 5 Reset Min/Max
//Min-Max Werte alle 24 Stunden um Mitternacht resetten
//DateTime now;
//Lets see what time the RTC is set at! -- If RTC is used
DateTime reset = rtc.now();
//Serial.println(reset.day());
//Serial.println(lastDay);
//if (now.day() != lastDay) // this happens exactly once a day.
if(reset.day() != lastDay)
{
MaxTemp_Aussen = Temp_Aussen;
MinTemp_Aussen = Temp_Aussen;
MaxTemp_Innen = Temp_Innen;
MinTemp_Innen = Temp_Innen;
MaxHum_Aussen= Hum_Aussen;
MinHum_Aussen = Hum_Aussen;
MaxHum_Innen = Hum_Innen;
MinHum_Innen = Hum_Innen;
MaxLuftdruckWGT = LuftdruckWGT;
MinLuftdruckWGT = LuftdruckWGT;
lastDay = reset.day(); }
//Serial.println(lastDay);
//Alternative:
// int last_hour = hour;
// hour = now.hour();
// minute = now.minute();
// if (last_hour == 23 && hour == 00)
// {
// int i;
// genkwh1 = 0;
// genkwh2 = 0;
// usekwh = 0;
// mintemp = inttemp;
// maxtemp = inttemp;
// }
// Teil 6 Display Ausgabe
//Evtl. über uhr nur jede minute aktualisieren lassen wie bei Druckmessung
myGLCD.setColor(0, 0, 0);
myGLCD.fillRect(0, 14, 799, 14); // Datum
renderDatum();
if ((aktuell.second() >= 0 ) && (aktuell.second() <= 3 ) && (aktuell.minute()%TeilerDisplay == 0))
{
if(currentMillis - DisplayMillis > DisplayIntervall)
{
allesleeren();
renderTempInnen();
renderTempAussen();
renderBarometer();
rendertaupunkt();
renderhumidex();
renderaktuell();
renderforecast();
rendermoon();
rendermoondays();
rendersonne();
renderheizung();
DisplayMillis = currentMillis;
//Serial.println(SeriellMillis);
}
}
//Bargraphen
//addHistoryValueBaro(LuftdruckWGT);
//addHistoryTempInnen(Temp_Innen);
//addHistoryTempAussen(Temp_Aussen);
//addHistoryHumInnen(Hum_Innen);
//addHistoryHumAussen(Hum_Aussen);
DateTime Bargraph = rtc.now();
currentMinute = Bargraph.minute();
if (currentMinute == 0 && lastMinute == 59)
{ //means currentMinute = 0 and lastMinute = 59
addHistoryTempInnen(Temp_Innen);
addHistoryTempAussen(Temp_Aussen);
addHistoryHumInnen(Hum_Innen);
addHistoryHumAussen(Hum_Aussen);
addHistoryValueBaro(LuftdruckWGT);
}
lastMinute = currentMinute;
// Backlight Steuerung mit SHARP GP2Y0D810Z0F
r_state = digitalRead(STATE); // reads the status of the sensor
if(r_state == 0) // if is there an obstacle (OUT = 0)
{ analogWrite(backlight_pin, backlight_on); // turn on the LCD
backlightMillis = currentMillis;}
if(currentMillis - backlightMillis > 60000) // 60 Sekunden
{ analogWrite(backlight_pin, backlight_off); // turn off the LCD}
}
//Line Graphen Updaten
Update_Line_Graph();
} //ENDE LOOP
//******************* GRAPHICS INIT ***************************
void initLCD() {
analogWrite(backlight_pin, backlight_on);
myGLCD.InitLCD();
myGLCD.setFont(SmallFont);
myTouch.InitTouch();
//myTouch.setPrecision(PREC_LOW);
//myTouch.setPrecision(PREC_MEDIUM);
myTouch.setPrecision(PREC_HI);
//myTouch.setPrecision(PREC_EXTREME);
//myGLCD.fillScr(0,0,0);
//myGLCD.setBackColor(240,240,240);
//myGLCD.setColor(0, 255, 0);
}
void initGraphics() {
myGLCD.clrScr();
//Beschriftung und Linien hinzufügen
myGLCD.setBackColor(0, 0, 0);
myGLCD.setColor(255, 255, 255);
myGLCD.drawLine(0, 15, 799, 15);
myGLCD.drawLine(410, 15, 410, 480);
myGLCD.drawLine(0, 290, 410, 290);
myGLCD.drawLine(200, 15, 200, 480);
myGLCD.drawLine(410, 215, 799, 215);
myGLCD.drawLine(600, 335, 600, 480);
myGLCD.drawLine(410, 335, 600, 335);
myGLCD.drawLine(120, 290, 120, 480);
myGLCD.setFont(BVS_15);
myGLCD.print("Innen - Klima", 50, 30, 0);
myGLCD.print("Grad C", 70, 105, 0);
myGLCD.print("Feuchte %", 50, 185, 0);
myGLCD.print("Aussen - Klima", 250, 30, 0);
myGLCD.print("Grad C", 270, 105, 0);
myGLCD.print("Feuchte %", 250, 185, 0);
myGLCD.print("Barometer", 550, 230, 0);
myGLCD.print("hPa", 660, 305, 0);
myGLCD.setFont(BVS_9);
myGLCD.print("Tendenz hPa 1-Std", 650, 385, 0);
myGLCD.print("Tendenz hPa 3-Std", 650, 455, 0);
myGLCD.setFont(BVS_15);
myGLCD.print("Taupunkt", 48, 265, 0);
myGLCD.print("Aktuell:", 480, 30, 0);
myGLCD.print("Vorhersage:", 645, 30, 0);
myGLCD.print("Mondphase", 255, 310, 0);
myGLCD.print("Heizung", 475, 350, 0);
myGLCD.setFont(BVS_9);
myGLCD.print("Puffer oben", 420, 380, 0);
myGLCD.print("Puffer mitte", 420, 395, 0);
myGLCD.print("Vorlauf", 420, 410, 0);
myGLCD.print("Ruecklauf", 420, 425, 0);
myGLCD.print("Kessel", 420, 440, 0);
myGLCD.print("Schlafzimmer", 420, 455, 0);
myGLCD.print(":", 520, 380, 0);
myGLCD.print(":", 520, 395, 0);
myGLCD.print(":", 520, 410, 0);
myGLCD.print(":", 520, 425, 0);
myGLCD.print(":", 520, 440, 0);
myGLCD.print(":", 520, 455, 0);
myGLCD.setFont(BVS_9);
myGLCD.setColor(BLAU); button(x21,y21,x22,y22);
myGLCD.setBackColor(BLAU); myGLCD.setColor(WHITE); myGLCD.print("BARGRAPH",x21+21,y21+10);
myGLCD.setColor(GRUEN); button(x31,y31,x32,y32);
myGLCD.setBackColor(GRUEN); myGLCD.setColor(BLACK); myGLCD.print("KURVENGRAPH",x31+10,y31+10);
myGLCD.setColor(RED); button(x41,y41,x42,y42);
myGLCD.setBackColor(RED); myGLCD.setColor(WHITE); myGLCD.print("BAROMETER",x41+16,y41+10);
myGLCD.setColor(ORANGE); button(x51,y51,x52,y52);
myGLCD.setBackColor(ORANGE); myGLCD.setColor(WHITE); myGLCD.print("HEIZUNG",x51+26,y51+10);
myGLCD.setColor(TUERKIS ); button(x61,y61,x62,y62);
myGLCD.setBackColor(TUERKIS ); myGLCD.setColor(WHITE); myGLCD.print("UHR",x61+38,y61+10);
}
//Clear all
void allesleeren() {
myGLCD.setColor(0, 0, 0);
myGLCD.fillRect(0, 50, 190, 100); // Innen
myGLCD.fillRect(0, 120, 190, 184); // Innen
myGLCD.fillRect(0, 200, 190, 264); // Innen
myGLCD.fillRect(205, 50, 408, 100); // Aussen
myGLCD.fillRect(205, 120, 408, 184); // Aussen
myGLCD.fillRect(578, 255, 799, 302); // Barometer
myGLCD.fillRect(620, 345, 770, 384); // Barometer
myGLCD.fillRect(620, 415, 770, 454); // Barometer
myGLCD.fillRect(0, 200, 150, 264); // Taupunkt
myGLCD.fillRect(205, 200, 408, 280); // Humidex
myGLCD.fillRect(412, 50, 604, 210); // Vorhersage
myGLCD.fillRect(605, 50, 799, 210); // Wetter aktuell
myGLCD.fillRect(205, 430, 408, 460); // Mond
myGLCD.fillRect(335, 340, 370, 370); // Mond
myGLCD.fillRect(132, 300, 190, 325); // Sonne
myGLCD.fillRect(132, 390, 190, 420); // Sonne
myGLCD.fillRect(525, 375, 590, 470); // Heizung
}
void renderDatum() {
DateTime render = rtc.now();
myGLCD.setBackColor(0,0,0);
myGLCD.setColor(255, 255, 255);
myGLCD.setFont(SmallFont);
//Uhrzeit
sprintf(Zeit,"%02d:%02d:%02d",render.hour(),render.minute(),render.second());
myGLCD.print((Zeit), 730, 1, 0);
//Datum
sprintf(Datum,"%02d.%02d.%d",render.day(),render.month(),render.year());
myGLCD.print((Datum), 20, 1, 0); }
void renderTempInnen() {
//Innen
myGLCD.setColor(255, 255, 255);
myGLCD.setBackColor(0,0,0);
myGLCD.setFont(BVS_43);
myGLCD.print(dtostrf(Temp_Innen, 5, 1, str), 20, 60, 0);
myGLCD.print(dtostrf(Hum_Innen, 5, 1, str), 20, 140, 0);
myGLCD.setFont(BVS_13);
myGLCD.setColor(255, 0, 0);
myGLCD.print(dtostrf(MaxTemp_Innen, 5, 1, str), 135, 60, 0);
myGLCD.print(dtostrf(MaxHum_Innen, 5, 1, str), 135, 140, 0);
myGLCD.setColor(0, 0, 255);
myGLCD.print(dtostrf(MinTemp_Innen, 5, 1, str), 135, 82, 0);
myGLCD.print(dtostrf(MinHum_Innen, 5, 1, str), 135, 162, 0);
}
void renderTempAussen() {
//Aussen
myGLCD.setFont(BVS_43);
myGLCD.setColor(255, 255, 255);
myGLCD.print(dtostrf(Temp_Aussen, 5, 1, str), 230, 60, 0);
myGLCD.print(dtostrf(Hum_Aussen, 5, 1, str), 230, 140, 0);
myGLCD.setFont(BVS_13);
myGLCD.setColor(255, 0, 0);
myGLCD.print(dtostrf(MaxTemp_Aussen, 5, 1, str), 345, 60, 0);
myGLCD.print(dtostrf(MaxHum_Aussen, 5, 1, str), 345, 140, 0);
myGLCD.setColor(0, 0, 255);
myGLCD.print(dtostrf(MinTemp_Aussen, 5, 1, str), 345, 82, 0);
myGLCD.print(dtostrf(MinHum_Aussen, 5, 1, str), 345, 162, 0);
}
void renderBarometer() {
//Barometer
myGLCD.setFont(BVS_43);
myGLCD.setColor(255, 255, 255);
myGLCD.print(dtostrf(LuftdruckWGT, 5, 1, str), 580, 260, 0);
myGLCD.setFont(BVS_13);
myGLCD.setColor(255, 0, 0);
myGLCD.print(dtostrf(MaxLuftdruckWGT, 5, 1, str), 745, 260, 0);
myGLCD.setColor(0, 0, 255);
myGLCD.print(dtostrf(MinLuftdruckWGT, 5, 1, str), 745, 282, 0);
myGLCD.setFont(BVS_43);
myGLCD.setColor(255, 255, 255);
myGLCD.setFont(BVS_34);
myGLCD.print(dtostrf(Pnow-P90, 5, 1, str), 650, 350, 0);
myGLCD.print(dtostrf(Pnow-P180, 5, 1, str), 650, 420, 0);
}
void rendertaupunkt() {
//Taupunkt
myGLCD.setFont(BVS_43);
myGLCD.setColor(255, 255, 255);
myGLCD.print(dtostrf(dewpoint, 5, 1, str), 20, 220, 0);
}
void renderhumidex() {
//Humidex mit Message
myGLCD.setFont(BVS_43);
myGLCD.setColor(255, 255, 255);
myGLCD.print(dtostrf(humidex, 5, 1, str), 230, 220, 0);
myGLCD.setFont(BVS_15);
if ((humidex >= 21 )&&(humidex < 27))
{ myGLCD.setColor(0, 255, 0);
myGLCD.print("Angenehm", 250, 265, 0); //No discomfort
}
if ((humidex >= 27 )&&(humidex < 35))
{ myGLCD.setColor(255, 192, 64);
myGLCD.print("Leichtes Unbehagen", 220, 265, 0); //Some discomfort
}
if ((humidex >= 35 )&&(humidex < 40))
{ myGLCD.setColor(255, 64, 0);
myGLCD.print("Starkes Unbehagen", 215, 265, 0); //Great discomfort
}
if ((humidex >= 40 )&&(humidex < 46))
{ myGLCD.setColor(255, 0, 0);
myGLCD.print("Gesundheitsgefahr", 215, 265, 0); //Health risk
}
if ((humidex >= 46 )&&(humidex < 54))
{ myGLCD.setColor(255, 0, 0);
myGLCD.print("Gr. Gesundheitsgefahr", 210, 265, 0); //Great health risk
}
if ((humidex >= 54 ))
{ myGLCD.setColor(255, 0, 0);
myGLCD.print("Hitzschlagsgefahr", 225, 265, 0); //Heat stroke danger
}
}
void renderforecast() {
// Wettertendenz/Wettervorhersage ausgeben
if( Pnow-P180 <= -8 ){ myGLCD.setColor(255, 0, 0);
myFiles.load(625, 48, 140, 140, "tstorms.raw", 1 , 0); //t-Storms
myGLCD.print("Sturm mit Hagel", 625, 190, 0);
}
if((Pnow-P180 <= -5 ) && (Pnow-P180 > -8 )){ myGLCD.setColor(0, 255, 0);
myFiles.load(625, 48, 140, 140, "rain_with_wind.raw", 1 , 0); //Rain with wind
myGLCD.print("Regen/Unwetter", 625, 190, 0);
}
if((Pnow-P180 <= -3 ) && (Pnow-P180 > -5 )){ myGLCD.setColor(0, 255, 0);
myFiles.load(625, 48, 140, 140, "rain.raw", 1 , 0); //rain
myGLCD.print("regnerisch", 650, 190, 0);
}