Double Temperature, rain, humidity on LCD with ESP8266


#1

About This Project

Hello, this is my first finished cayenne project. It works perfect im using it everyday. It have two DHT22 sensors one for inside temp second for outside temp and hum. I added rain sensor so i know when its raining outside. One of biggest reasons for creating this project was my problem with too high humidity inside my appartment so LED indicate me when its too high so i can open windows for lower it.
I used RGB LED … one color for high inside humidity, second color for rain, third color for both of them in same time.
Cutout for LCD is made by CNC…but to be honest i measure bad thick of that box so cut is wrong as you can see on photos…my bad :slight_smile: (sorry for my bad english)

What’s Connected

  • ESP8266
  • 2x DHT22
  • rain sensor
  • RGB LED
  • LCD 5110
  • box from china, 2x3.5mm jack(M/F),hot glue,cables

Triggers & Alerts

  • i use to try rain alert by email but i was constantly spammed whole time when there was raining so i turn it off. If anyone have solution for this let me know, im ok if it notifi me once per hour for example. :slight_smile:

Scheduling

no scheduling

Dashboard Screenshots

Photos of the Project

action!)


Code

#include "CayenneDefines.h"                   //wifi
#include "BlynkSimpleEsp8266.h"
#include "CayenneWiFiClient.h"
#include <SPI.h>                              //LCD
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
char token[] = "6cghdqvbxf";
char ssid[] = "SSID";
char password[] = "password";
#include <DHT.h>                              //senzor
#define DHTPIN 4
#define DHTPINB 0
#define DHTTYPE DHT22 
Adafruit_PCD8544 display = Adafruit_PCD8544(15, 13, 12, 5, 16);    //LCD
DHT dht(DHTPIN, DHTTYPE);    
DHT dhtb(DHTPINB, DHTTYPE);  

int led = 2; 
int sensorPin = A0; 
int sensorValue = 0;
      
float hum, temp;
float humB, tempB;

void setup(void)
{ 
  Serial.begin(115200);                       
  display.begin();
  display.clearDisplay();   // clears the screen and buffer
  display.display();           
  dht.begin();   
  Cayenne.begin(token, ssid, password);       //Cayenne 
  pinMode(led, OUTPUT);;
 }
void loop(){
  Cayenne.run();
  display.clearDisplay();  
  display.setContrast(40);
 {
  display.setCursor(0, 0);
  display.setTextSize(2);
  display.println(temp, 1);
 }
 {
  display.setTextSize(1);
  display.setCursor(48, -2);
  display.print((char)111);
 }
  {
  display.setTextSize(2);
  display.setCursor(58, 0);
  display.println(hum, 0);
 }
 {
  display.setCursor(0, 20);
  display.setTextSize(2);
  display.println(tempB, 1);
 }
 {
  display.setTextSize(1);
  display.setCursor(48, 18);
  display.print((char)111);
 }
  {
  display.setCursor(58, 20);
  display.setTextSize(2);
  display.println(humB, 0);
 }
  {
  display.setCursor(0, 40);
  display.setTextSize(1);
  display.println(analogRead(A0*100/1024), 1);
 }
  {
  display.setCursor(20, 40);
  display.setTextSize(1);
  display.println("% dážď");
 }
// display.command( PCD8544_FUNCTIONSET | PCD8544_POWERDOWN);
  hum = dht.readHumidity();
  temp = dht.readTemperature();
  humB = dhtb.readHumidity();
  tempB = dhtb.readTemperature();
  
delay(500);
  if (hum > 50){                  //ledka svieti ked je +50% hum1
  digitalWrite(led, HIGH);
    }
  else {
  digitalWrite(led, LOW);
    }
 }
 
CAYENNE_OUT(V0)
{
  Cayenne.virtualWrite(V0, dht.readTemperature(true));
}
CAYENNE_OUT(V1)
{
  Cayenne.virtualWrite(V1, dht.readHumidity());
}
CAYENNE_OUT(V2)
{
  Cayenne.virtualWrite(V2, dhtb.readTemperature(true));
}
CAYENNE_OUT(V3)
{
  Cayenne.virtualWrite(V3, dhtb.readHumidity());
}
CAYENNE_OUT(V5)
{
  int sensorValue = analogRead(A0);          //svetelny LDR    
  Cayenne.virtualWrite(V5, sensorValue); 
}

Thermostat w1209
#2

Hello Sir,
VERY good project! Congratulations.

Do you have something in mind to post the source code also? Thank you!


#3

I’d also be interested to see the code :slight_smile: Cool project, and thank you so much for sharing with us! It keeps Cayenne team motivated.

-B


#4

code added. sorry for messy code im not so much in to coding …but it working :slight_smile:


#5

Nice project! I like that LCD, might need to get me one of those…


#6

Very nice project! I liked that you used those headphone style plugins for your sensor hookup!, great idea.

Did you have any issues running the Adafruit_GFX.h library on the ESP?


#7

no problem with Adafruit_GFX.h library at least i dont see any :wink:


#8

Great work Micho. Thanks for sharing!


#9

You should submit this to the contest!

Definitely a contender for some of the awesome prizes :slight_smile:

~Benny


#10

nice project!