/* MY_INFO.ino 11/28/2018 rev 2 using the MEGA 328 controller Using DS1307 RTC from Adafruit now with temp and humid from DHT11 from Adafruit set for A1 5volt and A2 8volt switch (sw1) set for break which will display the voltages when program is running LCD Display on Arduino 328-2560 S100 CPU Board Use sections of RTC_RD_LCD.ino for the reading and writing to the LCD (downloaded from web) Use the main code from the example LCD_328.ino added offset -1.5 for DHT11 to match other readings */ // Libraries #include // contains headers for 2 wire (I2C) communication #include // contains headers for the control of the LCD #include #include #include // required for Arduino >= 1.5.4 #include // download from Aeduino and keep in library #include // download from Arduino or Adafruit keep in library // added for rtc readout on serial using RealTimeClockDS1307 library #define DHTPIN A0 // input used for DHT11 #define DHTTYPE DHT11 // we are using the DHT11 sensor #define ANALOG_INPUT 59 // Analog A5 (pin1 P33) to Switches on the S100_MEGA board (if MEGA 328 is used) #define Display_Clock_Every_N_Seconds 1 // RTC updated every second // define print format for date and time on serial (if used) char formatted[] = "00-00-00 00:00:00x"; // Needed in the LCD libraries to define pin setup with the Arduino // the pin settings are for the S100_MEGA, not the Arduino UNO // CPU pins 14, 15, 6, 11, 12, 13 (PB0, PB1, PD7, PD6, PD5, PD4 of CPU) // PL7, PL2, PL3, PL4, PL5, PL6 on schematic with P51 jumpers LiquidCrystal lcd(8, 9, 7, 6, 5, 4); // Pin that will receive clock pulse from RTC int clockPin = 0; // Time and date variables byte second; byte minute; byte hour; byte day; byte date; byte month; byte year; DHT dht(DHTPIN, DHTTYPE); // need this for DHT11 choice int sensorPin = A1; // select the input pin for the voltage measurement of system 5V int sensorPin2 = A2; // select the input pin for the voltage measurement of system 8V int sensorValue = 0; // variable to store the value coming from the sensorPin1 int sensorValue2 = 0; // variable to store the value coming from the sensorPin2 int AnalogIn; // measure switch voltage void setup() { // Wire.begin() Serial.begin(9600); // If you want to send data to terminal // configure DHT11 for (int DigitalPin = 7; DigitalPin <= 9; DigitalPin++) { pinMode(DigitalPin, OUTPUT); } dht.begin(); // start DHT11 // Configure LCD Display 16 columns, 2 rows 0,1 lcd.begin(16,2); lcd.clear(); lcd.setCursor(0,0); lcd.print("****MY_INFO*****"); lcd.setCursor(0,1); lcd.print("Updated 11/28/18"); delay(5000); // Keep on display for 5 seconds } // the loop function runs over and over again forever void loop() { lcd.clear(); //setup for next display // read the input on analog pin 1 for 5 volt int sensorValue = analogRead(A1); // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V): // I used a 2:1 voltage divider and then adjusted to match my DVM, i.e 10.3 instead of 5 float voltage = sensorValue * (10.3 / 1023.0); // print out the value you read: lcd.setCursor(0,0); lcd.print("V+5 = "); lcd.setCursor(6,0); lcd.print(voltage); // read the input on analog pin 2: for 8 volt int sensorValue2 = analogRead(A2); // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V) // I used a 2:1 voltage divider and then adjusted to match my DVM, i.e 10.3 instead of 5.0 float voltage2 = sensorValue2 * (10.3 / 1023.0); // print out the value you read: lcd.setCursor(0,1); lcd.print("V+8 = "); lcd.setCursor(6,1); lcd.print(voltage2); delay(5000); // read time and date delay(4000); // not too fast RTC.readClock(); // Keeps running while clockPin is high while (digitalRead(clockPin)) { // start the I2C transmission, at address 0x68 Wire.beginTransmission(0x68); // Start at address 0 Wire.write(0); // Close transmission Wire.endTransmission(); // Start to read the 7 binary data from 0x68 Wire.requestFrom(0x68, 7); second = Wire.read(); minute = Wire.read(); hour = Wire.read(); day = Wire.read(); date = Wire.read(); month = Wire.read(); year = Wire.read(); // Formatting and displaying time lcd.setCursor(0,0); if (hour < 10) lcd.print("0"); lcd.print(hour, HEX); lcd.print(":"); if (minute < 10) lcd.print("0"); lcd.print(minute, HEX); lcd.print(":"); if (second < 10) lcd.print("0"); lcd.print(second, HEX); lcd.print(" "); //fill line // Formatting and displaying date lcd.setCursor(0,1); if (month < 10) lcd.print("0"); lcd.print(month, HEX); lcd.print("/"); if (date < 10) lcd.print("0"); lcd.print(date, HEX); lcd.print("/"); lcd.print(year, HEX); lcd.print(" "); //fill line // Reading temperature or humidity takes about 250 milliseconds! float h = dht.readHumidity(); float t = dht.readTemperature(); // Read temperature as Celsius (the default) float tf = dht.convertCtoF(t) -1.5; // convert temp from C to F with -1.5 degree offset // to match readings from other temperature monitors lcd.setCursor(10,0); lcd.print(tf); //printing temperature to the LCD display lcd.print("F"); lcd.setCursor(9,1); lcd.print(" "); lcd.print(h); //printing humidity to the LCD display lcd.print("%"); //the 3-led setup process if (t<=22) { digitalWrite(7, HIGH); digitalWrite(8, LOW); digitalWrite(9, LOW); } else if (t>22) { digitalWrite(8, HIGH); digitalWrite(7, LOW); digitalWrite(9, LOW); } else if (t>=35) { digitalWrite(9, HIGH); digitalWrite(7, LOW); digitalWrite(8, LOW); } // check for a sw1 closure AnalogIn = analogRead(ANALOG_INPUT); if(AnalogIn < 896) // voltage below 4.4 volts { break; // force to top of loop() and print voltages } // end while } }