Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Brandon GoldbergIsaac OtwellIan Eikelberry
Published

Turtle Point Smart Home Monitoring System 3171 Project

Monitor the status of you home, in or out of your home!

IntermediateShowcase (no instructions)147
Turtle Point Smart Home Monitoring System 3171 Project

Things used in this project

Hardware components

Photon 2
Particle Photon 2
×3
ELEGOO Upgraded 37 in 1 Sensor Modules Kit V2.0
ELEGOO Upgraded 37 in 1 Sensor Modules Kit V2.0
Sensors/Components Used from this kit: -1x Flame Sensor -1x Button -2x RGB LED -1x 2 Color LED -1x Active Buzzer -1x Digital Temperature Sensor -1x Magnetic Spring
×2
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×4
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×3
Rechargeable Battery, Lithium Ion
Rechargeable Battery, Lithium Ion
×3
Gorilla Mounting Putty
×1
Magnet
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
ThingSpeak API
ThingSpeak API

Hand tools and fabrication machines

Wire Stripper & Cutter, 32-20 AWG / 0.05-0.5mm² Solid & Stranded Wires
Wire Stripper & Cutter, 32-20 AWG / 0.05-0.5mm² Solid & Stranded Wires
Multitool, Screwdriver
Multitool, Screwdriver

Story

Read more

Code

Flame and Temp Sensor

C/C++
#include <cmath>
int sensorPin = A0;   
int sensorValue = 0;  
int b = 3950; //value given in elegoo guide
int r0 = 9590; //resistance of thermistor
int c = 2100; //max voltage on a0 pin from particle data
double t0 = 298.15; //initial value
float res1 = 0.0; //initial value
float res2 = 0.0; //initial value
int rseries=10000; //value given in elegoo guide   
int temperaturek = 0; //temperature in kelvin
float logg = 0.0; //initial value
int tempf = 0; //initial temp in f for output
float x = 0.0; //initial value
int analogPin = A1; //initial value
int fireSensor; //initial value
int armed = 0; //initial value

void setup()
  {
  Particle.subscribe("Armed", myHandler);
  }

void myHandler(const char *event, const char *data)
{
    armed = atoi(data); //local variable from global
    if (armed != 0)
    {
        armed = 1;
    }
    else
    {
        armed = 0;
    }
}

void loop() 
{
    while(armed == 1)
    {
    sensorValue = analogRead(sensorPin); //temperature sensor
    res1 = (2100.0/sensorValue)-1; //beginning of b formula from elegoo document
    res2 = (rseries/res1)/r0;
    logg = log (res2);
    x = logg/b;
    temperaturek = 1/((1/t0)+x); //derivation of b formula in elegoo document
    tempf = ((temperaturek-273.15)*1.8)+32; //conversion to degrees f
    Particle.publish("tempf", String(tempf));
    fireSensor = analogRead(analogPin); //flame sensor
        if(fireSensor < 1000) //flame sensor
            {
        Particle.publish("FireDetected", String(fireSensor));
            }
        else
            {
            }
        if (armed != 1)
            {
        break;
            }
    delay(5000); //incremental delay
    }
}

Door Sensor

C/C++
int DoorSensorOut;
int DoorSensorIn = A0; //pin for Reed Sensor
int buzzer = D16; //Output pin for Buzzer
int armed = 0; //initial value
int doorsensor;
int data;

void setup() 
{  
  Particle.subscribe("Armed", myHandler); //grabbing global variable
  pinMode(buzzer, OUTPUT);
}

void myHandler(const char *event, const char *data)
{
    armed = atoi(data); //this sets armed as local variable alternating between 1 and 0
    if (armed != 0)
    {
        armed = 1;
    }
    else
    {
        armed = 0;
    }
}

void myHandler3(const char *event, const char *data) {}

void loop ()
{
    while(armed == 1)
    {
  DoorSensorOut = analogRead(DoorSensorIn);
  if(DoorSensorOut > 2000)
  {
    Particle.publish("DoorOpen", String(DoorSensorOut));
    String data = String(1);
    Particle.publish("doorsensor", data, PRIVATE);
  }
  else
  {
    String data = String(0);
    Particle.publish("doorsensor", data, PRIVATE);
  }
  delay(2000);
if (DoorSensorOut > 2000) 
{
  digitalWrite (buzzer, HIGH);
  delay (2000);
  digitalWrite (buzzer, LOW);
  delay (500);
}
}
}

Status Bar Code

C/C++
int button = D11;
int buttonOut;
int counter = 0;
int armed;
int redpin_right = D1;
int redpin_center = D15;
int redpin_left = D13;
int buzzerPin = D16;
bool FireDetected = true;
float fireSensor;
float DoorSensorOut;
bool DoorOpen = true;
// reflash - 

void setup()
{
pinMode(button, INPUT);
pinMode(redpin_right, OUTPUT);
pinMode(redpin_left, OUTPUT);
pinMode(buzzerPin, OUTPUT);
pinMode(redpin_center, OUTPUT);
Particle.subscribe("FireDetected", myHandler);
Particle.subscribe("DoorOpen", myHandler2);
}

void loop()
{
buttonOut = analogRead(button);
if (buttonOut < 100)
{
    Particle.publish("ButtonPushed", String(buttonOut));
    counter = counter + 1;
}
if (counter % 2 == 0)
{
    armed = 0; 
    Particle.publish("Armed", String(armed));
}
else
{
armed = 1;
Particle.publish("Armed", String(armed));
}
if (armed == 1)
{
    analogWrite(D1, 255);
}
else
{
    analogWrite(D1, 0);
}
delay(2000);
}

void myHandler(const char *event, const char *data)
{
    int fireSensor = atoi(data);
    analogWrite(D13, 255);
    
while (FireDetected != false)
{
  digitalWrite (buzzerPin, HIGH);
  delay (100);
  digitalWrite (buzzerPin, LOW);
  delay (100);
}
}

void myHandler2(const char *event, const char *data)
{
    int DoorSensorOut = atoi(data);
    if (DoorOpen != false)
    {
    analogWrite(D15, 255);
    }
}

Credits

Brandon Goldberg
1 project • 2 followers
Contact
Isaac Otwell
1 project • 1 follower
Contact
Ian Eikelberry
1 project • 2 followers
Contact

Comments

Please log in or sign up to comment.