Nicholas BlackMichael Ledermann
Published

IOT Project Apartment responsibility "Encouragement" System

Helps everyone keep track of some basic responsibilities in an apartment. Keeping track of the little things makes everyone's life easier!

BeginnerFull instructions provided2 hours150
IOT Project Apartment responsibility "Encouragement" System

Things used in this project

Hardware components

Argon
Particle Argon
×3
Jumper wires (generic)
Jumper wires (generic)
×1
ELEGOO 37-in-1 Sensor Module Kit V1.0
ELEGOO 37-in-1 Sensor Module Kit V1.0
×1
Perma-Proto Breadboard Half Size
Perma-Proto Breadboard Half Size
×3

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
Used to code the Argon's.
ThingSpeak API
ThingSpeak API
Fritzing
Used to create the circuit diagrams attached in the project.

Story

Read more

Schematics

Temperature Sensor

Senses and graphs temperature

Code

Temperature Graphing Code

C/C++
This code uses the Argon and a digital sensor to measure temperature over time, in real time using thingspeak.
// This #include statement was automatically added by the Particle IDE.
#include <ThingSpeak.h>



int analogvalue = 0;
int temp_f;
TCPClient client;

unsigned long myChannelNumber = 1900285;
const char * myWriteAPIKey = "FZLVJWZORYJ4WDEL";

void setup(){

  ThingSpeak.begin(client);
 
  Particle.variable("analogvalue", analogvalue);
  Particle.variable("temp_f", temp_f);
 
Serial.begin(9600);

  pinMode(A0, INPUT);
}

void loop()
{
    delay(1500);
  // Read the analog value of the sensor (TMP36)
  analogvalue = analogRead(A0);
  //Convert the reading into degree 
  temp_f = (analogvalue*-.08099688473520249+151.99688473520249); //To be accurate
  //temp = 69;
  
  Particle.publish("temperature",String (temp_f), ALL_DEVICES);// sends data to cloud
  ThingSpeak.setField(1,temp_f);
  Serial.print(temp_f);
  Serial.println("temp_f");
  ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
  delay(20000);
  
}

Motion and Light Sensor

C/C++
Sets off an LED that uploads an event to the cloud that will trigger an LED in other rooms when motion is detected.
int inputPin = D4;              
int ledPin = D7;                
int pirState = LOW;             
int val = 0;
int ledout = D6;
int calibrateTime = 20000;      

void setup()
    {
        pinMode( ledPin, OUTPUT );
        pinMode(inputPin, INPUT);   
        pinMode(ledout, OUTPUT);
        digitalWrite(ledout, LOW);
        Particle.subscribe("LEDSignal", myHandler, "e00fce68e9c9f8320591605b");
    }

void loop()
    {
        if ( calibrated() )
            {
               readTheSensor();
               reportTheData();
            }
    }

void readTheSensor() 
    {
        val = digitalRead(inputPin);
    }

bool calibrated() 
    {
        return millis() - calibrateTime > 0;
    }

void reportTheData() 
    {
        delay(20000);
        if (val == HIGH) 
            {
                Particle.publish("LEDSignal", "1"); 
                pirState = HIGH;
                setLED( pirState );
                delay(20000);
            } 
            
        else 
            {   Particle.publish("LEDSignal","0");
                pirState = LOW;
                setLED( pirState );
                delay(20000);
            }
    }

void setLED( int state )
    {
        digitalWrite( ledPin, state );
    }

void myHandler(const char *event, const char *data)
    {
        digitalWrite(ledout, HIGH);
        delay(20000);
        digitalWrite(ledout, LOW);
    }

LEDsignal

C/C++
This checks the cloud to see if the Motion Sensor's LED has gone off, if it detects it has this LED will also activate.
int led = D6;



void setup() {

pinMode(led, OUTPUT);
digitalWrite(led, LOW);

Particle.subscribe("LEDSignal", myHandler, "e00fce68e9c9f8320591605b");


}

void myHandler(const char *event, const char *data)
{
if (strcmp(data,"1")==0) {
  digitalWrite(led, HIGH);
  Particle.publish("LEDSignal","1");
  delay(20000);

  }else if (strcmp(data,"0")==0) {
      digitalWrite(led, LOW);
  delay(20000);
}}

Credits

Nicholas Black
2 projects • 2 followers
Contact
Michael Ledermann
0 projects • 1 follower
Contact
Thanks to Nathan Porter.

Comments

Please log in or sign up to comment.