Created
June 18, 2017 00:54
-
-
Save kLOsk/1ea357c9620f11ba7c6c7caa4aa5688f to your computer and use it in GitHub Desktop.
Arduino Curing Fridge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Libraries | |
#include <DHT.h>; //need for temp/hum sensor | |
//#include <Time.h> //need for timer | |
//#include <TimeLib.h> //need for timer | |
//#include <SPI.h>//not sure | |
#include <Wire.h>//not sure | |
#include "RTClib.h" //need for clock | |
#include <Adafruit_SSD1306.h> //need for display | |
//#include <Adafruit_GFX.h> //maybe not needed | |
//#include <gfxfont.h> // maybe not needed | |
//Constants | |
#define RELAY1 7 //Relay is connected to digipin 7 | |
#define DHT1PIN 3 // what pin we're connected to | |
#define DHT2PIN 4 // what pin we're connected to | |
#define DHTTYPE DHT22 // DHT 22 (AM2302) | |
DHT dht1(DHT1PIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino | |
DHT dht2(DHT2PIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino | |
#define OLED_RESET 4 | |
Adafruit_SSD1306 display(OLED_RESET); | |
RTC_DS3231 rtc; | |
//Variables | |
int chk; | |
int hum1; //Stores humidity value | |
float temp1; //Stores temperature value | |
int hum2; //Stores humidity value | |
float temp2; //Stores temperature value | |
void setup() | |
{ | |
pinMode(7,OUTPUT); //Pin for SSR Relay needs to be output | |
Serial.begin(9600); | |
dht1.begin(); | |
dht2.begin(); | |
if (rtc.lostPower()) { | |
Serial.println("RTC lost power, lets set the time!"); | |
// following line sets the RTC to the date & time this sketch was compiled | |
rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); | |
// This line sets the RTC with an explicit date & time, for example to set | |
// January 21, 2014 at 3am you would call: | |
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0)); | |
} | |
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64) | |
display.display(); | |
delay(1000); | |
// Clear the buffer. | |
display.clearDisplay(); | |
// text display tests | |
display.setTextSize(1); | |
display.setTextColor(WHITE); | |
//display.setTextSize(1); | |
//display.setTextColor(WHITE); | |
//display.setCursor(0,0); | |
/* display.println("Hello, world!"); | |
display.setTextColor(BLACK, WHITE); // 'inverted' text | |
display.println(3.141592); | |
display.setTextSize(2); | |
display.setTextColor(WHITE); | |
display.print("0x"); display.println(0xDEADBEEF, HEX); | |
display.display(); | |
delay(2000); | |
display.clearDisplay();*/ | |
} | |
void loop() | |
{ | |
//Read data and store it to variables hum and temp | |
hum1 = dht1.readHumidity(); | |
temp1 = dht1.readTemperature(); | |
hum2 = dht2.readHumidity(); | |
temp2 = dht2.readTemperature(); | |
DateTime now = rtc.now(); | |
// text display tests | |
display.setCursor(0,0); | |
//Print temp and humidity values to display | |
display.print("H1: "); | |
display.print(hum1); | |
display.print("% T1: "); | |
display.print(temp1); | |
display.println(" C"); | |
display.print("H2: "); | |
display.print(hum2); | |
display.print("% T2: "); | |
display.print(temp2); | |
display.println(" C"); | |
display.print(now.hour(), DEC); | |
display.print(':'); | |
display.print(now.minute(), DEC); | |
display.print(':'); | |
display.print(now.second(), DEC); | |
display.println(); | |
display.display(); | |
display.clearDisplay(); | |
//Serial.println(month()); | |
//digitalWrite(RELAY1,LOW); // Turns ON Relays 1 | |
//Serial.println("Light ON"); | |
delay(100); // Wait 2 seconds | |
//digitalWrite(RELAY1,HIGH); // Turns Relay Off | |
//Serial.println("Light OFF"); | |
//delay(2000); | |
//while ((hum1 = dht1.readHumidity() ) > 80) { //using hum1 } | |
/* if (hum1 > 80) { | |
Serial.print("high hum!"); | |
} */ | |
//delay(2000); //Delay 2 sec. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment