I started this project with an esp8266 12e. Then went to an esp32. The first part was a lcd i2c with an rtc i2c. I work trying to put the twn together on digital pins forever. Until I went to the Arduino Uno analog pins did I get it to work. So I went ahead using the Uno wrote the code. I have been running this code for a few days and everything seems to be solid.
[
code]// RTC and LCD use i2c port (i2c Gnd 5V and pins a4 sda, a5 scl) DHT-11 BRICK unit uses Gnd 5V and pin 4
// 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 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 OnMin1 = 46;
const int OnHour1[]= {17,18,19,20};//Array multi hour
const int OnDay1 = 16;
const int OnMonth1 = 12;
const int OnYear1 = 2017;
const int OffMin1 = 47;
const int OffHour1 = 17;
const int OffDay1 = 16;
const int OffMonth1 = 12;
const int OffYear1 = 2017;
const int OnMin2 = 42;
const int OnHour2 = 17;
const int OnDay2 = 16;
const int OnMonth2 = 12;
const int OnYear2 = 2017;
const int OffMin2 = 43;
const int OffHour2 = 17;
const int OffDay2 = 16;
const int OffMonth2 = 12;
const int OffYear2 = 2017;
const int OnMin3 = 17;
const int OnHour3 = 16;
const int OnDay3 = 16;
const int OnMonth3 = 17;
const int OnYear3 = 2017;
const int OffMin3 = 17;
const int OffHour3 = 16;
const int OffDay3 = 16;
const int OffMonth3 = 17;
const int OffYear3 = 2017;
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);
lcd.print("F");
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, 3); // start postion of time text on LCD
lcd.print("ZONE-1 " "ZONE-2 " "ZONE-3");
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) && (now.day() == OnDay1) && (now.month() == OnMonth1)) {
digitalWrite (relay1, LOW);
lcd.setCursor(1, 2);
lcd.print("ON");
}
else if ((now.hour() == OffHour1) && (now.minute() == OffMin1) && (now.day() == OffDay1) && (now.month() == OffMonth1)) {
digitalWrite (relay1, HIGH);
lcd.setCursor(1, 2);
lcd.print("OFF");
}
if ((now.hour() == OnHour2) && (now.minute() == OnMin2) && (now.day() == OnDay2) && (now.month() == OnMonth2)) {
digitalWrite (relay2, LOW);
lcd.setCursor(8, 2);
lcd.print("ON");
}
else if ((now.hour() == OffHour2) && (now.minute() == OffMin2) && (now.day() == OffDay2) && (now.month() == OffMonth2)) {
digitalWrite (relay2, HIGH);
lcd.setCursor(8, 2);
lcd.print("OFF");
}
if ((now.hour() == OnHour3) && (now.minute() == OnMin3) && (now.day() == OnDay3) && (now.month() == OnMonth3)) {
digitalWrite (relay3, LOW);
lcd.setCursor(15, 2);
lcd.print("ON");
}
else if ((now.hour() == OffHour3) && (now.minute() == OffMin3) && (now.day() == OffDay3) && (now.month() == OffMonth3)) {
digitalWrite (relay3, HIGH);
lcd.setCursor(15, 2);
lcd.print("OFF");
}
}
//
// END OF FILE
//
Now I have been wanting to add wifi just to keep track of the relays. I also want to add a flow device.
With the esp8266 01 today I had one working with AT commands and then switch it to mode 3 and it work great. So I push my luck and put another one on the breakout board. AT = error. I decided to switch back to make sure the other one is still working and I got the old AT = error on that device. To say the esp8266-01 is challenging to me is an understatement. I have order some new boards
I have done a small project with the esp8266 12e with three soil sensor connected to a iot. Work great.
I was looking for information on hooking up an wemos mini with the uno. I have not found direction for it. I have not seen anyone use the mini that way. Probably a good reason why