Dylan CollinsColin Shinn
Published

Room Monitor Sensor

Have you wondered what the specific temperature of a room is and if someone goes into said room. This product helps with that.

IntermediateFull instructions provided78
Room Monitor Sensor

Things used in this project

Hardware components

Argon
Particle Argon
×2
DHT11 Temperature & Humidity Sensor (3 pins)
DHT11 Temperature & Humidity Sensor (3 pins)
×1
Active Buzzer
×1
HC SR501 PIR Motion Sensor
×1
LCD 1602 Module
×1
Breadboard (generic)
Breadboard (generic)
×2
Single Turn Potentiometer- 10k ohms
Single Turn Potentiometer- 10k ohms
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
Maker service
IFTTT Maker service
TinkerCAD

Story

Read more

Schematics

Motion Sensor Graph

This graph represents every time the motion sensor detected motion. In this graph, when the y value is 1 this is when motion is detected and when it is 0 this is when there is no motion. Each reading is also taken in intervals of every 2 seconds.

Temperature Sensor Graph

This graph represents the change in temperature over 2 second intervals. Every time the temperature value is above room temperature, the red LED would come on and when the temperature dropped below room temperature the blue LED came on.

Code

Temperature and Motion Code

C/C++
All notes are contained within the code file.
// C++ code
//

//set all pin names
int tempSensor = A5;
int redLED = D2;
int blueLED = D7;
int pirSensor = D0;
int buzzer = D3;
int voltage = 0;
int temp = 0;

void setup()
{

  //set the variables to be sent to other argon
  Particle.variable("temp", temp);


  //Set all the pinmodes
  pinMode(tempSensor, INPUT);
  pinMode(blueLED, OUTPUT);
  pinMode(redLED, OUTPUT);
  pinMode(pirSensor, INPUT);
  pinMode(buzzer, OUTPUT);
  Serial.begin(9600);
}

void loop()
{
  //make sure buzzer is turned off 
  digitalWrite(buzzer, LOW);

  //read the voltage from the temp sensor
  voltage = analogRead(tempSensor);

  //convert the voltage to temp 
  temp = (voltage *-.08099688473520249+82.99688473520249);

  //send the temp to other argon
  Particle.publish("TempIOT042", String(temp), ALL_DEVICES);

  //print out the date 
  Serial.print(temp); // display temperature value
  Serial.print("'");

  //if temp is high show red
  if (temp > 73) {
    digitalWrite(redLED, HIGH);
    digitalWrite(blueLED, LOW);
  }

  //if temp is low show blue
  else if (temp <= 73) {
    digitalWrite(blueLED, HIGH);
    digitalWrite(redLED, LOW);
  }

  //if temp is not reading show nothing
  else {
    digitalWrite(blueLED, LOW);
    digitalWrite(redLED, LOW);
  }

  //read motion sensor
  int pirRead=digitalRead(pirSensor);

  //print out motion data
  Serial.print(pirRead); 
  Serial.print("'");

  //if motion is detected sturn on buzzer for 1 second then turn off
  if (pirRead == HIGH) {
    digitalWrite(buzzer,HIGH);
    delay(1000);
    digitalWrite(buzzer,LOW);
  }




  delay(2000); // Wait for 2000 millisecond(s)
} 

LCD Display Code

C/C++
All comments are inside the code file.
// This #include statement was automatically added by the Particle IDE.
#include <LiquidCrystal_I2C_Spark.h>

// This #include statement was automatically added by the Particle IDE.
#include <LiquidCrystal.h>

#include "application.h"

/*
  LiquidCrystal Library 
  The circuit:
 * LCD RS pin to digital pin D0
 * LCD EN pin to digital pin D1
 * LCD D4 pin to digital pin D2
 * LCD D5 pin to digital pin D3
 * LCD D6 pin to digital pin D4
 * LCD D7 pin to digital pin D5
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)
 * connect R/W (pin 5) to ground

 /


//pinout on LCD [RS, EN, D4, D5, D6, D7];
// pin nums LCD  [ 4,  6, 11, 12, 13, 14];
// Shield Shield [RS, EN, D4, D5, D6, D7];
// Spark Core    [D3, D5, D2, D4, D7, D8];
LiquidCrystal lcd(D0, D1, D2, D3, D4, D5);

//method for getting temp from other argon
int temperature;
void temper(const charevent, const char *data )
{
    String pew = data;
    temperature = pew.toInt();
}



void setup() {

  //Subscribe to other argon for temperature
  Particle.subscribe("TempIOT042", temper, ALL_DEVICES);

  // set up the LCD's number of columns and rows: 
  lcd.begin(16,2);

  // Print a message to the LCD.
  lcd.print("Temperature: ");

}

void loop() {

  //print out data for csv
  Serial.print("Temperature: "); // display temperature value
  Serial.print(temperature); // display temperature value

  //set lcd to second line
  lcd.setCursor(0, 1);
  // print the temperature
  lcd.print(temperature);
  lcd.print("' Farenheit");

  //add small delay
  delay (2000);

  }

Credits

Dylan Collins

Dylan Collins

0 projects • 0 followers
Colin Shinn

Colin Shinn

0 projects • 0 followers

Comments

Add projectSign up / Login