Components and supplies
Graphic OLED, 128 x 128
Resistor 4.75k ohm
Voltmeter analog
Resistor 220 ohm
Grove - Air quality sensor v1.3
Resistor 10k ohm
DS18B20 Programmable Resolution 1-Wire Digital Thermometer
DHT22 Temperature Sensor
Arduino Mega 2560
Tools and machines
3D Printer (generic)
Soldering iron (generic)
Laser cutter (generic)
Apps and platforms
Arduino IDE
Project description
Code
Air Quality - arduino code
arduino
1/* Air quality sensor 2 by smi1100 - 06/16/2022 3 My third project. The following components are needed: 4 - Arduino Mega 5 - OLED display (in my case waveshare - 128x128, General 1.5inch OLED display module) 6 - two RGB-LED and 6 220 Ohm resistors 7 - 2 Voltmeter (in my case 5 Volt Voltmeter 85C1) 8 - 1 push button momentary 9 - air quality sensor (in my case Grove - Air Quality Sensor v1.3) 10 - DS3231 real time clock 11 - DHT22 sensor (measuring humidity) 12 - DS18B20 sensor (measuring temperature) and a resistor 4,7K Ohm 13 - bread board 14 - casing 15*/ 16 17/* module 0 - Arduino Mega --------------------------------------------------------------------- */ 18 19 #include <Arduino.h> 20 #include <SPI.h> // library for the serial bus 21 22/* module 1 - OLED Display ---------------------------------------------------------------- 23 24 List of fonds https://github.com/olikraus/u8g2/wiki/fntlist8x8 */ 25 26 #include <U8x8lib.h> // library necessary to display text on the oled display 27 U8X8_SSD1327_WS_128X128_4W_SW_SPI u8x8(/* clock=*/ 32, /* data=*/ 34, /* cs=*/ 30, /* dc=*/ 28, /* reset=*/ 26); 28 29 // change the pages of the OLED display without using delay 30 31 int Seite = 0; 32 int Zeit_auf_Seite = 7000; 33 unsigned long aktuelleZeit; 34 unsigned long letzterZustandsWechsel; 35 36 /* description of the variables 37 Seite - pagenumber of the oled-display 38 Zeit_auf_Seite - time to change to the next page on the oled display 39 wait without using delay 40 aktuelleZeit 41 letzterZustandswechsel 42 */ 43 44// module 2 - real time clock --------------------------------------------------------------------- 45 46 #include "RTClib.h" // library for the real time clock (RTC) 47 RTC_DS3231 rtc; // RTC - from left to right - GND, VCC, SDA (Mega - 20, Uno - A4), SCL (Mega - 21, Uno - A5) - input voltage of the RTC - 3.3 or 5V 48 char daysOfTheWeek[7][12] = {"Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerst.", "Freitag", "Samstag"}; 49 // in english char weekday[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; 50 51 String day, month, hour, minute; 52 String weekday; 53 54// module 3 - DS18B20 sensor ----------------------------------------------------------------- 55 56 #include <OneWire.h> // library for the 1-wire 57 #include <DallasTemperature.h> // digital, serial bus from the manufacturer Maxim (former Dallas) 58 59 #define ONE_WIRE_BUS 22 // connection to digital PIN 22 - input voltage of the sensor - 3.3 or 5V 60 61 OneWire oneWire(ONE_WIRE_BUS); 62 DallasTemperature sensor(&oneWire); 63 64// module 4 - air quality sensor ------------------------------------------------------------ 65 66 #include "Air_Quality_Sensor.h" 67 AirQualitySensor sensore(A0); // connection to analog PIN A0 - - input voltage of the sensor - 3.3 or 5V 68 69// module 5 - EEPROM Arduino -------------------------------------------------------------- 70 71 #include <EEPROM.h> 72 73 float t = 20; // current temperature - when switching on set to 20 C 74 float t_diff; // difference between t and t_vorher 75 String positiv = "+"; // If the difference is positive, a "+" sign is added 76 77 // save the data after turning on 78 79 float t_vorher = 15; // temperature - in this example - 1 hour ago (change with variable Bezugsgre) 80 int t_vorher_adress = 280; 81 float bezugsgroesse = 3600000; // Bezugsgre in milli seconds -> 1000 milliseconds * 60 sek * 60 min = 3.600.000 msek (1 hour) 82 unsigned long letzterZustandsWechselA; 83 unsigned long aktuelleZeitA; 84 85 // initial values of Tmax and Tmin are chosen so that they are overwritten on the first run 86 87 float t_max = 10.99; 88 float t_min = 39.99; 89 90 int t_max_adress = 0; 91 int t_min_adress = 50; 92 93 // save that time with T maximun 94 95 String t_max_hour = "12"; 96 int t_max_hour_adress = 100; 97 String t_max_minute = "12"; 98 int t_max_minute_adress = 120; 99 String t_max_day = "12"; 100 int t_max_day_adress = 140; 101 String t_max_month = "12"; 102 int t_max_month_adress = 160; 103 104 // save that time with T minimum 105 106 String t_min_hour = "12"; 107 int t_min_hour_adress = 180; 108 String t_min_minute = "12"; 109 int t_min_minute_adress = 200; 110 String t_min_day = "12"; 111 int t_min_day_adress = 220; 112 String t_min_month = "12"; 113 int t_min_month_adress = 240; 114 115// module 6 - Voltmeter temperature -------------------------------------------------------- 116 117 int Voltmeter_Temp_PIN = 2; //PWM PIN 118 int MIN_TEMP = 20; 119 int MAX_TEMP = 35; 120 int RANGE_TEMP = MAX_TEMP - MIN_TEMP; 121 int voltage_temp; // 0 - 255 -> variable for the both voltmeter 122 int temp; // temp = 100 * t 123 124// module 7 - RGB LED Voltmeter ------------------------------------------------------------- 125 // Do not connect the GND of the LED to the same GND of the voltmeter -> changes the values on the voltmeter 126 127 int ledrot_temp=4; //PWM PIN 128 int ledblau_temp=5; //PWM PIN 129 int ledgruen_temp=6; //PWM PIN 130 131// module 8 - DHT 22 ------------------------------------------------------------------------ 132 133 #include "DHT.h" 134 135 #define DHT22PIN 24 // connection to digital PIN 24 - input voltage of the sensor - 3.3 or 5V 136 #define DHT22TYPE DHT22 137 138 DHT dht22(DHT22PIN, DHT22TYPE); 139 140 float humidity; 141 float temperature_dht22; // compare values with DS18B20 142 143// module 9 - Voltmeter hygrometer ----------------------------------------------------------------- 144 145 int Voltmeter_Hygro_PIN = 3; //PWM PIN 146 int MIN_Hygro = 20; 147 int MAX_Hygro = 35; 148 int RANGE_Hygro = MAX_Hygro - MIN_Hygro; 149 int voltage_Hygro; 150 151// module 10 - RGB LED Voltmeter 152 // Do not connect the GND of the LED to the same GND of the voltmeter -> changes the values on the voltmeter 153 154 int ledrot_hygro=7; //PWM PIN 155 int ledblau_hygro=8; //PWM PIN 156 int ledgruen_hygro=9; //PWM PIN 157 158// module 11 - momentary button display 159 160 const int buttonPin = 36; 161 int buttonState = 0; 162 163 164void setup() 165{ 166 Serial.begin(9600); 167 Serial.println("+++++++++++++++++++ SETUP +++++++++++++++++++");Serial.println(""); 168 169 // OLED Display -------------------------------------------------------------- 170 171 u8x8.begin(); // input voltage of the display - 3.3 or 5V 172 Serial.println("OLED Display ready");Serial.println(""); 173 174 // real time clock ------------------------------------------------------------------- 175 176 if (! rtc.begin()) // Check if RTC is connected correctly: 177 { 178 Serial.println("Couldn't find RTC"); 179 while (1); 180 } 181 182 if (rtc.lostPower()) // Check if the RTC lost power and if so, set the time: 183 { 184 Serial.println("RTC lost power, lets set the time!"); 185 // The following line sets the RTC to the date & time this sketch was compiled: 186 rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); 187 // This line sets the RTC with an explicit date & time, for example to set 188 // January 21, 2014 at 3am you would call: 189 //rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0)); 190 } 191 192 Serial.println("RTC ready"); Serial.println(""); 193 194 // Temp. sensor -------------------------------------------------------------- 195 196 sensor.begin(); 197 Serial.print("Temperatursensor - DS 18B20 - Anzahl Sensoren: "); 198 Serial.println(sensor.getDeviceCount()); 199 Serial.println("Sensor DS 18B20 ready"); Serial.println(""); 200 201// Air quality sensor ------------------------------------------------------------ 202 203 while (!Serial); 204 205 u8x8.clear(); 206 u8x8.setFont(u8x8_font_7x14_1x2_r); 207 208 u8x8.setCursor(3,6); 209 u8x8.print("Booting ..."); 210 211 Serial.println("Luftgtesensor - Waiting sensor to init (10 sek)..."); 212 delay(10000); 213 214 if (sensore.init()) 215 { 216 Serial.println("Sensor Luftgte ready"); 217 Serial.println(""); 218 } 219 else 220 { 221 Serial.println("Sensor Luftgte ERROR!"); 222 Serial.println(""); 223 } 224 225 // EEPROM -------------------------------------------------------------------- 226 227 EEPROM.put(t_min_adress, t_min); 228 Serial.print("MIN Initial aus EEPROM (adress - value): "); Serial.print(t_min_adress); Serial.print(" - "); Serial.println(t_min); 229 EEPROM.put(t_max_adress, t_max); 230 Serial.print("MAX Initial aus EEPROM (adress - value): "); Serial.print(t_max_adress); Serial.print(" - "); Serial.println(t_max);Serial.println(""); 231 232 // VOLTMETER temperature und humidity ----------------------------------------------------------------- 233 234 // Test accuracy of voltmeter - calibrate with adjusting screw if necessary 235 236 int MIN = 0; 237 int MAX = 255; 238 239 analogWrite(Voltmeter_Temp_PIN, MIN); 240 analogWrite(Voltmeter_Hygro_PIN, MIN); 241 Serial.println("Voltmeter Teilstrich 0"); 242 delay(2000); 243 244 analogWrite(Voltmeter_Temp_PIN, MAX*1/5); 245 analogWrite(Voltmeter_Hygro_PIN, MAX*1/5); 246 Serial.println("Voltmeter Teilstrich 1"); 247 delay(2000); 248 249 analogWrite(Voltmeter_Temp_PIN, MAX*2/5); 250 analogWrite(Voltmeter_Hygro_PIN, MAX*2/5); 251 Serial.println("Voltmeter Teilstrich 2"); 252 delay(2000); 253 254 analogWrite(Voltmeter_Temp_PIN, MAX*3/5); 255 analogWrite(Voltmeter_Hygro_PIN, MAX*3/5); 256 Serial.println("Voltmeter Teilstrich 3"); 257 delay(2000); 258 259 analogWrite(Voltmeter_Temp_PIN, MAX*4/5); 260 analogWrite(Voltmeter_Hygro_PIN, MAX*4/5); 261 Serial.println("Voltmeter Teilstrich 4"); 262 delay(2000); 263 264 analogWrite(Voltmeter_Temp_PIN, MAX*5/5); 265 analogWrite(Voltmeter_Hygro_PIN, MAX*5/5); 266 Serial.println("Voltmeter Teilstrich 5"); 267 delay(2000); 268 269 analogWrite(Voltmeter_Temp_PIN, MIN); 270 analogWrite(Voltmeter_Hygro_PIN, MIN); 271 Serial.println("Voltmeter Teilstrich 0");Serial.println(""); 272 273 Serial.println("Voltmeter ready");Serial.println(""); 274 275 // RGB LED ------------------------------------------------------------------------ 276 277 analogWrite(ledrot_temp,255);analogWrite(ledrot_hygro,255); 278 analogWrite(ledblau_temp,0);analogWrite(ledblau_hygro,0); 279 analogWrite(ledgruen_temp,0);analogWrite(ledgruen_hygro,0); 280 Serial.println("LED Farbe rot"); 281 delay (2000); 282 283 analogWrite(ledrot_temp,0);analogWrite(ledrot_hygro,0); 284 analogWrite(ledblau_temp,255);analogWrite(ledblau_hygro,255); 285 analogWrite(ledgruen_temp,0);analogWrite(ledgruen_hygro,0); 286 Serial.println("LED Farbe blau"); 287 delay (2000); 288 289 analogWrite(ledrot_temp,0);analogWrite(ledrot_hygro,0); 290 analogWrite(ledblau_temp,0);analogWrite(ledblau_hygro,0); 291 analogWrite(ledgruen_temp,255);analogWrite(ledgruen_hygro,255); 292 Serial.println("LED Farbe grn"); 293 delay (2000); 294 295 analogWrite(ledrot_temp,0);analogWrite(ledrot_hygro,0); 296 analogWrite(ledblau_temp,0);analogWrite(ledblau_hygro,0); 297 analogWrite(ledgruen_temp,0);analogWrite(ledgruen_hygro,0); 298 delay (2000); 299 Serial.println("LED ready");Serial.println(""); 300 301 302 // Hygrometer ------------------------------------------------------------------------ 303 304 dht22.begin(); 305 Serial.println("DHT22 ready");Serial.println(""); 306 307 // Taster ---------------------------------------------------------------------------- 308 309 pinMode(buttonPin, INPUT_PULLUP); 310 311} 312 313void loop() 314{ 315 316 // Display 317 318 buttonState = digitalRead(buttonPin); 319 if (buttonState == LOW) 320 { 321 //Serial.println("Display Schalter ON"); 322 u8x8.setPowerSave(0); 323 } 324 else 325 { 326 //Serial.println("Display Schalter OFF"); 327 u8x8.setPowerSave(1); 328 } 329 330 aktuelleZeit = millis(); 331 332 if(aktuelleZeit - letzterZustandsWechsel > Zeit_auf_Seite) 333 { 334 letzterZustandsWechsel = aktuelleZeit; 335 switch (Seite) 336 { 337 case 0: page1();break; 338 case 1: page2();break; 339 case 2: page3();break; 340 case 3: page4();break; 341 case 4: page5();break; 342 case 5: page6();break; 343 } 344 Seite++; 345 if (Seite>5) {Seite = 0; } 346 } 347} 348 349void page1() 350{ 351 352 // OLED Display - date and weekday 353 Serial.println(""); 354 Serial.println("Page 1 - Datum und Wochentag"); 355 356 DateTime now = rtc.now(); // Get current date and time: 357 358 if (now.day() < 10) {day = String(0) + String(now.day());} else {day = now.day();} 359 if (now.month() < 10) {month = String("0") + String(now.month());} else {month = now.month();} 360 weekday = String(daysOfTheWeek[now.dayOfTheWeek()]); 361 362 Serial.print("Datum: "); Serial.print(day); Serial.print("."); Serial.println(month); 363 364 u8x8.clear(); 365 u8x8.setFont(u8x8_font_profont29_2x3_f); 366 367 u8x8.setCursor(3,6); 368 u8x8.print(day); 369 u8x8.drawString(7,6,"."); 370 u8x8.setCursor(9,6); 371 u8x8.print(month); 372 373 u8x8.setCursor(4,11); 374 u8x8.setFont(u8x8_font_7x14_1x2_r); 375 u8x8.print(weekday); 376} 377 378void page2 () 379{ 380 381 // OLED display - time 382 Serial.println(""); 383 Serial.println("Page 2 - Uhrzeit"); 384 385 DateTime now = rtc.now(); // Get current date and time: 386 387 if (now.hour() < 10) {hour = String("0") + String(now.hour());} else {hour = now.hour();} 388 if (now.minute() < 10) {minute = String("0") + String(now.minute()); }else {minute = now.minute();} 389 390 Serial.print("Zeit: "); Serial.print(hour); Serial.print(":"); Serial.println(minute); 391 392 u8x8.clear(); 393 u8x8.setFont(u8x8_font_profont29_2x3_f); 394 395 u8x8.setCursor(3,7); 396 u8x8.print(hour); 397 u8x8.drawString(7,7,":"); 398 u8x8.setCursor(9,7); 399 u8x8.print(minute); 400 401} 402 403void page3() 404{ 405 // OLED display - temperature difference 406 407 Serial.println(""); 408 Serial.println("Page 3 - Temperaturdifferenz"); 409 410 // save status before 411 412 aktuelleZeitA = millis(); 413 Serial.print("aktuelle Zeit = "); Serial.print(aktuelleZeitA/1000/60); Serial.print(" min. - "); 414 Serial.print("neuer Bezugszeitraum nach = X * "); Serial.print(bezugsgroesse/1000/60); Serial.println(" min."); 415 416 if(aktuelleZeitA - letzterZustandsWechselA > bezugsgroesse) 417 { 418 letzterZustandsWechselA = aktuelleZeitA; 419 Serial.println("********** Temp vor einer Stunde NEUER WERT **********"); 420 t_vorher = sensor.getTempCByIndex(0); 421 EEPROM.put(t_vorher_adress, t_vorher); 422 Serial.print("Temp vor einer Stunde NEU: "); Serial.print(t_vorher_adress); Serial.print(" - "); Serial.print(t_vorher);Serial.println(" C");Serial.println(""); 423 } 424 425 // compare two sensors (DHT22 <> DS18B20) 426 427 sensor.requestTemperatures(); 428 t = sensor.getTempCByIndex(0); 429 temperature_dht22 = dht22.readTemperature(); 430 Serial.print("Differenz = DS18B20: ");Serial.print(t); Serial.print(" C <> DHT22: "); Serial.print(temperature_dht22); Serial.print(" C = "); Serial.print(t-temperature_dht22); Serial.println(" C "); 431 432 // Tem. sensor DS18B20 -------------------------------------------------------------- 433 434 Serial.print("DS18B20 - Temp.: "); Serial.print(t);Serial.print(" C");Serial.print(" -> "); 435 436 // Voltmeter Temp ---------------------------------------------------------------------- 437 438 if (t <= 20) 439 { 440 voltage_temp = 0; 441 analogWrite(Voltmeter_Temp_PIN,voltage_temp); 442 Serial.println("Temperatur <= 20 C --> Farbe blau"); 443 444 analogWrite(ledrot_temp,0); 445 analogWrite(ledblau_temp,255); 446 analogWrite(ledgruen_temp,0); 447 } 448 449 if (t > 20 && t < 28) 450 { 451 temp = 100 * t; 452 voltage_temp = (temp-(MIN_TEMP*100))/RANGE_TEMP*255/100; 453 analogWrite(Voltmeter_Temp_PIN,voltage_temp); 454 Serial.println("Temperatur > 20 C & < 28 C --> keine Farbe"); 455 analogWrite(ledrot_temp,0); 456 analogWrite(ledblau_temp,0); 457 analogWrite(ledgruen_temp,0); 458 } 459 460 if (t > 28 && t < 35) 461 { 462 temp = 100 * t; 463 voltage_temp = (temp-(MIN_TEMP*100))/RANGE_TEMP*255/100; 464 analogWrite(Voltmeter_Temp_PIN,voltage_temp); 465 Serial.println("Temperatur > 28 C & <= 35C --> Farbe rot"); 466 analogWrite(ledrot_temp,255); 467 analogWrite(ledblau_temp,0); 468 analogWrite(ledgruen_temp,0); 469 } 470 471 if (t > 35) 472 { 473 voltage_temp = 255; 474 analogWrite(Voltmeter_Temp_PIN,voltage_temp); 475 Serial.println("Temperatur > 35 C --> Farbe rot"); 476 analogWrite(ledrot_temp,255); 477 analogWrite(ledblau_temp,0); 478 analogWrite(ledgruen_temp,0); 479 } 480 481 // OLED Display - temperature 482 483 u8x8.clear(); 484 t_vorher = EEPROM.put(t_vorher_adress, t_vorher); // LSCHEN 485 t_diff = t - t_vorher; 486 Serial.print("Temp.differenz: "); Serial.print(t_diff);Serial.print(" = "); Serial.print(t);Serial.print(" - "); Serial.println(t_vorher); 487 488 if (t_diff >= 0) 489 { 490 u8x8.setFont(u8x8_font_7x14_1x2_r); 491 u8x8.setCursor(3,10); 492 u8x8.print(positiv); 493 Serial.print("Vorzeichen= "); Serial.println(positiv); 494 } 495 else 496 { 497 Serial.print("Vorzeichen= "); Serial.println("negativ"); 498 } 499 500 u8x8.setFont(u8x8_font_profont29_2x3_f); 501 u8x8.setCursor(2,4); 502 u8x8.print(t); 503 u8x8.drawString(10,4," C"); 504 505 u8x8.setFont(u8x8_font_7x14_1x2_r); 506 u8x8.setCursor(5,10); 507 u8x8.print(t_diff); 508 u8x8.drawString(9,10," C"); 509 u8x8.drawString(0,13,"gg. Stunde davor"); 510 511} 512 513void page4() 514{ 515 Serial.println(""); 516 Serial.println("Page 4 - Temp. MAX und MIN"); 517 518 // OLED Display - temperature MAX, MIN 519 520 if (t > (EEPROM.get(t_max_adress, t_max))) 521 { 522 Serial.println ("********** EEPROM-Wert MAX Korrektur **********"); 523 Serial.print ("alter EEPROM-Wert MAX: "); Serial.println(EEPROM.get(t_max_adress, t_max)); 524 t_max = t; 525 EEPROM.put(t_max_adress, t_max); 526 Serial.print ("neuer EEPROM-Wert MAX: "); Serial.println(EEPROM.get(t_max_adress, t_max)); 527 t_max_hour = hour; 528 EEPROM.put(t_max_hour_adress, t_max_hour); 529 t_max_minute = minute; 530 EEPROM.put(t_max_minute_adress, t_max_minute); 531 t_max_day = day; 532 EEPROM.put(t_max_day_adress, t_max_day); 533 t_max_month = month; 534 EEPROM.put(t_max_month_adress, t_max_month); 535 Serial.print ("neuer EEPROM-Wert MAX_Time: "); 536 Serial.print(EEPROM.get(t_max_day_adress, t_max_day)); 537 Serial.print("."); 538 Serial.print(EEPROM.get(t_max_month_adress, t_max_month)); 539 Serial.print(" "); 540 Serial.print(EEPROM.get(t_max_hour_adress, t_max_hour)); 541 Serial.print(":"); 542 Serial.println(EEPROM.get(t_max_minute_adress, t_max_minute)); 543 } 544 else 545 { 546 Serial.println ("kein neuer EEPROM-Wert MAX_Time"); 547 } 548 549 if (t < (EEPROM.get(t_min_adress, t_min)) && t > 1) // Avoid measuring errors (-127 C) of the sensor when displaying the minimum temperature 550 { 551 Serial.println ("********** EEPROM-Wert MIN Korrektur **********"); 552 Serial.print ("alter EEPROM-Wert MIN: "); Serial.println(EEPROM.get(t_min_adress, t_min)); 553 t_min = t; 554 EEPROM.put(t_min_adress, t_min); 555 Serial.print ("neuer EEPROM-Wert MIN: "); Serial.println(EEPROM.get(t_min_adress, t_min)); 556 t_min_hour = hour; 557 EEPROM.put(t_min_hour_adress, t_min_hour); 558 t_min_minute = minute; 559 EEPROM.put(t_min_minute_adress, t_min_minute); 560 t_min_day = day; 561 EEPROM.put(t_min_day_adress, t_min_day); 562 t_min_month = month; 563 EEPROM.put(t_min_month_adress, t_min_month); 564 Serial.print ("neuer EEPROM-Wert MIN_Time: "); 565 Serial.print(EEPROM.get(t_min_day_adress, t_min_day)); 566 Serial.print("."); 567 Serial.print(EEPROM.get(t_min_month_adress, t_min_month)); 568 Serial.print(" "); 569 Serial.print(EEPROM.get(t_min_hour_adress, t_min_hour)); 570 Serial.print(":"); 571 Serial.println(EEPROM.get(t_min_minute_adress, t_min_minute)); 572 } 573 else 574 { 575 Serial.println ("kein neuer EEPROM-Wert MIN_Time"); 576 } 577 578 u8x8.clear(); 579 u8x8.setFont(u8x8_font_7x14_1x2_r); 580 581 u8x8.drawString(0,2,"Temp.MAX"); 582 583 u8x8.setCursor(2,4); u8x8.print(EEPROM.get(t_max_adress, t_max)); u8x8.drawString(6,4," C"); 584 585 u8x8.setCursor(2,6); u8x8.print(EEPROM.get(t_max_day_adress, t_max_day)); 586 u8x8.drawString(4,6,"."); 587 588 u8x8.setCursor(5,6); u8x8.print(EEPROM.get(t_max_month_adress, t_max_month)); 589 u8x8.drawString(7,6," "); 590 591 u8x8.setCursor(8,6); u8x8.print(EEPROM.get(t_max_hour_adress, t_max_hour)); 592 u8x8.drawString(10,6,":"); 593 594 u8x8.setCursor(11,6); u8x8.print(EEPROM.get(t_max_minute_adress, t_max_minute)); 595 596 597 u8x8.drawString(0,9,"Temp.MIN"); 598 599 u8x8.setCursor(2,11); u8x8.print(EEPROM.get(t_min_adress, t_min)); u8x8.drawString(6,11," C"); 600 601 u8x8.setCursor(2,13); u8x8.print(EEPROM.get(t_min_day_adress, t_min_day)); 602 u8x8.drawString(4,13,"."); 603 604 u8x8.setCursor(5,13); u8x8.print(EEPROM.get(t_min_month_adress, t_min_month)); 605 u8x8.drawString(7,13," "); 606 607 u8x8.setCursor(8,13); u8x8.print(EEPROM.get(t_min_hour_adress, t_min_hour)); 608 u8x8.drawString(10,13,":"); 609 610 u8x8.setCursor(11,13); u8x8.print(EEPROM.get(t_min_minute_adress, t_min_minute)); 611 612} 613 614void page5() 615{ 616 Serial.println(""); 617 Serial.println("Page 5 - Luftfeuchte"); 618 619 // Voltmeter Hygrometer 620 621 humidity = dht22.readHumidity(); 622 Serial.print("DHT22 - Feuchtigkeit: "); Serial.print(humidity);Serial.print(" % - "); 623 624 voltage_Hygro = humidity*255/100; 625 analogWrite(Voltmeter_Hygro_PIN,voltage_Hygro); 626 627 if (humidity >80 || humidity <20) 628 { 629 Serial.println("Feuchtigkeit <20 oder >80 --> rot"); 630 analogWrite(ledrot_hygro,255); 631 analogWrite(ledblau_hygro,0); 632 analogWrite(ledgruen_hygro,0); 633 } 634 635 if (humidity <80 || humidity >20) 636 { 637 Serial.println("Feuchtigkeit zw. 20 und 80 --> keine Farbe"); 638 analogWrite(ledrot_hygro,0); 639 analogWrite(ledblau_hygro,0); 640 analogWrite(ledgruen_hygro,0); 641 } 642 643 644 // Display Hygrometer 645 646 u8x8.clear(); 647 u8x8.setFont(u8x8_font_7x14_1x2_r); 648 649 u8x8.drawString(3,2,"Luftfeuchte"); 650 651 u8x8.setCursor(5,5); u8x8.print(humidity); 652 u8x8.drawString(11,5,"%"); 653 654 u8x8.setCursor(4,8); u8x8.print("zu feucht"); 655 u8x8.setCursor(4,10); u8x8.print("normal"); 656 u8x8.setCursor(4,12); u8x8.print("zu trocken"); 657 658 int x = 8; 659 660 if (humidity > 65) 661 { 662 x = x+0; 663 } 664 else if (humidity > 40 && humidity < 65) 665 { 666 x = x+2; 667 } 668 else if (humidity < 40) 669 { 670 x = x+4; 671 } 672 673 u8x8.setCursor(2,x); u8x8.print("X"); 674} 675 676 677void page6() 678{ 679 Serial.println(""); 680 Serial.println("Page 6 - Luftqualitt"); 681 682 // air quality 683 684 Serial.print("Grove Air quality - Luftguete: "); 685 Serial.println(sensore.slope()); 686 687 u8x8.clear(); 688 u8x8.setFont(u8x8_font_7x14_1x2_r); 689 690 u8x8.drawString(3,2,"Luftguete"); 691 692 u8x8.setCursor(4,6); u8x8.print("ALARM!"); 693 u8x8.setCursor(4,8); u8x8.print("Schlecht"); 694 u8x8.setCursor(4,10); u8x8.print("Mittel"); 695 u8x8.setCursor(4,12); u8x8.print("Frischluft"); 696 697 int x = 6; 698 699 if (sensore.slope() == 0) 700 { 701 x = x+0; 702 Serial.println("Air Quality: ALARM!"); 703 } 704 else if (sensore.slope() == 1) 705 { 706 x = x+2; 707 Serial.println("Air Quality: Schlecht"); 708 } 709 else if (sensore.slope() == 2) 710 { 711 x = x+4; 712 Serial.println("Air Quality: Mittel"); 713 } 714 else if (sensore.slope() == 3) 715 { 716 x = x+6; 717 Serial.println("Air Quality: Frischluft"); 718 } 719 720 u8x8.setCursor(2,x); u8x8.print("X"); 721} 722
Downloadable files
PCB
PCB
Documentation
backside
backside
front side
front side
display voltmeter
display voltmeter
Comments
Only logged in users can leave comments