Just a quick house temp monitor setup

About This Project

With the latest weather changes (midwest winter) I thought I’d throw out a few sensors to see what the actual room temps were vs. thermostat setting (located in the main living room)

What’s Connected

ESP8266 dev boards- communitcation
DS18B20’s- tempurature
PIR motion sensors- is anyone actually in the room

Triggers & Alerts

Triggers to be set to turn on/off the red and blue led’s that are onboard the ESP units. Indicating warmer/cooler than thermostat set point

Scheduling

24/7 monitoring

Dashboard Screenshots

Photos of the Project

6 Likes

Hi
Interesting project.
You can share the code please?

 #include "CayenneDefines.h"
 #include "BlynkSimpleEsp8266.h"
 #include "CayenneWiFiClient.h"
 #include "ESP8266WiFi.h"
 #include < OneWire.h >
 #include < DallasTemperature.h >

 #define VIRTUAL_PIN3 V3

const int motionSensorPin = D7;
const int tmpPin = D3;

OneWire oneWire(tmpPin);
DallasTemperature sensors(&oneWire);

// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = "YOURTOKEN";
char ssid[] = "YOURSSID";
char password[] = "YOURPW";

void setup()
{
  pinMode(D0, OUTPUT);
  pinMode(D4, OUTPUT);
  Cayenne.begin(token, ssid, password);
  sensors.begin();
}

void loop()
{
  Cayenne.run();
  sensors.requestTemperatures();
  
  checkSensor();
}

int previousState = -1;
int currentState = -1;
unsigned long previousMillis = 0;

void checkSensor()
{
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= 250) {
    currentState = digitalRead(motionSensorPin);
    if (currentState != previousState) {
      Cayenne.virtualWrite(VIRTUAL_PIN3, currentState);
      previousState = currentState;
    }
        previousMillis = currentMillis;
  }
}

CAYENNE_OUT(V0)
{
  CAYENNE_LOG("Data requested for Virtual Pin %d", V0);
  Cayenne.virtualWrite(V0, sensors.getTempFByIndex(0) );
}

CAYENNE_IN(V1)
{
  CAYENNE_LOG("Got a value: %s", getValue.asStr());
  int i = getValue.asInt();
  
  if (i == 0)
  {
    digitalWrite(D0, LOW);
  }
  else
  {
    digitalWrite(D0, HIGH);
  }  
}
CAYENNE_IN(V2)
{
  CAYENNE_LOG("Got a value: %s", getValue.asStr());
  int i = getValue.asInt();
  
  if (i == 0)
  {
    digitalWrite(D4, LOW);
  }
  else
  {
    digitalWrite(D4, HIGH);
  }  
}

Have not been active in the community for awhile due to work constraints, but here is the latest rendition of my household units…testing out the added OLED units added. Bringing the total to LDR, PIR, ds18b20, and now OLED.

2 Likes

Thanks for the update! How do you decide what to place on the display, or does it cycle through each of the temperature values from your dashboard?

Currently it just cycles between deg f & deg c.
The goal is to tie the PIR in with the OLED and have it only light up and display current room temp / outside temp when the PIR sees motion, otherwise blacked out. My code is a bit buggy and slow in it’s current state.
:thumbsup:

1 Like