Temp (C) or (F)

The Code

//
// AUTHOR: Rob Tillaart, Terry King, David Loveridge
// VERSION:
// PURPOSE: DHT, RTC and LCD display Arduino
//     URL:
// Three examples brought together to create a temp / humidity and time display on a 20/4 LCD.
// RTC and LCD use i2c port (i2c Gnd 5V and pins a4 sda, a5 scl) DHT-11 BRICK unit uses Gnd 5V and pin 2
// Released to the public domain
//
/*-----( Import needed libraries )-----*/
#include <Wire.h>              // In standard library
#include <dht.h>               // https://arduino-info.wikispaces.com/TemperatureHumidity
#include <LiquidCrystal_I2C.h> // https://arduino-info.wikispaces.com/LCD-Blue-I2C
#include "RTClib.h"            // https://arduino-info.wikispaces.com/DS1307_RealTime_Clock_Brick
/*-----( Declare Constants )-----*/

/*-----( Declare objects )-----*/
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address Ox3F (Check yours)
RTC_DS1307 rtc;    // Create a RealTimeClock object (I set the time in another sketch)
/*-----( Declare Variables )-----*/
dht DHT;
#define DHT11_PIN 4 // use pin 2 on UNO to sample data from DHT module
const int relay1 = 2; //Digital pin that the Relay is connected
const int relay2 = 5; //Digital pin that the Relay is connected
const int relay3 = 6; //Digital pin that the Relay is connected

const int OnHour1 = 10;
const int OnMin1 = 23;
const int OffHour1 = 10;
const int OffMin1 = 24;

const int OnHour2 = 10;
const int OnMin2 = 23;
const int OffHour2 = 10;
const int OffMin2 = 24;

const int OnHour3 = 10;
const int OnMin3 = 23;
const int OffHour3 = 10;
const int OffMin3 = 24;

void setup()
{
  Serial.begin(9600);
  Serial.println("DHT TEST PROGRAM ");
  Serial.print("DHT LIBRARY VERSION: ");
  Serial.println(DHT_LIB_VERSION);
  Serial.println();
  Serial.println("Humidity % \tTemperature (C) \tTime \tDate");
  lcd.begin(20, 4); // defines it is a 20 character four line display
  rtc.begin(); // Start the RTC library code
}

void loop()
{
  // READ DATA
  DateTime now = rtc.now();
  int chk = DHT.read11(DHT11_PIN);
  Serial.print(DHT.humidity, 1);
  Serial.print(",\t");
  Serial.print("\t");
  Serial.print(DHT.temperature, 1);
  Serial.print(",\t");
  Serial.print("\t");
  Serial.print("\t");
  Serial.print(now.hour(), DEC);
  Serial.print(':');
  Serial.print(now.minute(), DEC);
  Serial.print(':');
  Serial.print(now.second(), DEC);
  Serial.print(' ');
  Serial.print(now.day(), DEC);
  Serial.print('/');
  Serial.print(now.month(), DEC);
  Serial.print('/');
  Serial.println(now.year(), DEC);
  lcd.setCursor(0, 0); // start postion of Humidity text on LCD
  lcd.print(DHT.humidity, 0); // 0 creates whole number, 1 two decimal
  lcd.print("% Humidity ");
  lcd.setCursor(14, 0); // start postion of temperature text on LCD
  lcd.print(DHT.temperature * 1.8 + 32, 0); //Farhenheit conversion
  lcd.setCursor(17, 0);
  [b]//lcd.print(”F“);
  //lcd.print(DHT.temperature, 0);
  //lcd.print(" C");[/b]
  lcd.setCursor(0, 1); // start postion of time text on LCD
  lcd.print(now.hour(), DEC);
  lcd.print(':');
  lcd.print(now.minute(), DEC);
  lcd.print('.');
  lcd.print(now.second(), DEC);
  lcd.print('.');
  lcd.print(now.year(), DEC);
  lcd.print('/');
  lcd.print(now.month(), DEC);
  lcd.print('/');
  lcd.print(now.day(), DEC);
  lcd.print(' ');
  lcd.setCursor(0, 2); // start postion of time text on LCD
  lcd.print("ZONE-1 " "ZONE-2 "  "ZONE-3");
  //lcd.print(now.second(), DEC);
  // You can display in lcd by changing Serial to lcd I have only used time above not date
  //lcd.print(now.year(), DEC);
  //lcd.print('/');
  //lcd.print(now.month(), DEC);
  //lcd.print('/');
  //lcd.print(now.day(), DEC);
  //lcd.print(' ');
  //lcd.print(now.hour(), DEC);
  //lcd.print(':');
  //lcd.print(now.minute(), DEC);
  //lcd.print(':');
  //lcd.print(now.second(), DEC);
  //lcd.println();
  delay(1000); // screen - sample & LCD refresh time 1 second although DHT say min 2 seconds but works ok.

  if ((now.hour() == OnHour1) && (now.minute() == OnMin1)) {
    digitalWrite (relay1, LOW);
  }
  else if ((now.hour() == OffHour1) && (now.minute() == OffMin1)) {
    digitalWrite (relay1, HIGH);
  }

  if ((now.hour() == OnHour2) && (now.minute() == OnMin2)) {
    digitalWrite (relay2, LOW);
  }
  else if ((now.hour() == OffHour2) && (now.minute() == OffMin2)) {
    digitalWrite (relay2, HIGH);
  }

  if ((now.hour() == OnHour3) && (now.minute() == OnMin3)) {
    digitalWrite (relay2, LOW);
  }
  else if ((now.hour() == OffHour3) && (now.minute() == OffMin3)) {
    digitalWrite (relay2, HIGH);
  }
}

//
// END OF FILE
//

I have try to get rid of the (c) and change it to (F) with no luck writing to my lcd. When I do change it to read (F) I get the following error. Why can I not print a (F) on my lcd. “UGH”

Arduino: 1.8.5 (Windows 10), Board: “Arduino/Genuino Uno”

Build options changed, rebuilding all
plant_water:83: error: stray ‘\342’ in program

lcd.print(�F“);

^

plant_water:83: error: stray ‘\200’ in program

plant_water:83: error: stray ‘\235’ in program

plant_water:83: error: stray ‘\342’ in program

plant_water:83: error: stray ‘\200’ in program

plant_water:83: error: stray ‘\234’ in program

C:\Users\Documents\Arduino\plant_water\plant_water.ino: In function ‘void loop()’:

plant_water:83: error: ‘F’ was not declared in this scope

lcd.print(�F“);

^

exit status 1
stray ‘\342’ in program

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

'Stray' errors indicate that you copied from a webpage. One way that usually solves it is to copy the code that you posted above and paste it into your current sketch (overwriting it completely).

Thank You :slight_smile: :slight_smile: :slight_smile: :slight_smile: :slight_smile: :slight_smile: