Cameron KlovstadRyan Williams
Published © GPL3+

IOT Project: Text Theft Alarm with Light Sensing

This IOT project is used to collect data and notify the user when a safe or lockbox has been opened.

BeginnerFull instructions provided1 hour174
IOT Project: Text Theft Alarm with Light Sensing

Things used in this project

Hardware components

Argon
Particle Argon
×2
Photo resistor
Photo resistor
×1
Resistor 220 ohm
Resistor 220 ohm
×1

Software apps and online services

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

Story

Read more

Schematics

Particle Argon with Photoresistor and Resistor

Particle Photon is used in the schematic, but the pins are in different locations on the Particle Argon

Argons 1 and 2

Thingspeak Chart

Code

Publishing Light Level Status

C/C++
#define LIGHT_PIN A0 // Replace A0 with your pin
#define LIGHT_LEVEL_THRESHOLD 300  // Replace with your own light level
#define THRESHOLD_SENSITIVITY 100 // higher number = lower sensitivity, lower number = higher sensitivity
#define publish_delay 15000
unsigned int lastPublish = 0;
int lightlevelchanged49;
TCPClient client;
void setup() {
Particle.variable("lightlevelchanged49",&lightlevelchanged49,INT);
Particle.subscribe("subscription_recieved49", myHandler);
}
void loop() {
   int darkness = analogRead(LIGHT_PIN);
   Particle.publish("ThingSpeakWrite_", "{ \"1\": \"" + String(darkness) + "\", \"k\": \"Y6SKGBD57EBDOT63\" }", 60, PRIVATE);
   if (darkness >= LIGHT_LEVEL_THRESHOLD) {
       Particle.publish("lightlevelchanged49", "light");
   }
      delay (3000);
   }
void myHandler(const char *lightlevelchanged49, const char *data)
{
    digitalWrite(D7,HIGH);
    delay(200);
    digitalWrite(D7,LOW);
}

Receiving Light Status

C/C++
int ledpin = D7;
void setup() {
int subscription_recieved49;
pinMode(ledpin,OUTPUT);
Particle.subscribe("lightlevelchanged49", myHandler1);
}
void myHandler1(const char *lightlevelchanged49, const char *data)
{
    digitalWrite(ledpin,HIGH);
    delay(500);
    digitalWrite(ledpin,LOW);
    delay(500);
    Particle.publish("subscription_recieved49");
}

Credits

Cameron Klovstad

Cameron Klovstad

1 project • 1 follower
Ryan Williams

Ryan Williams

1 project • 0 followers

Comments

Add projectSign up / Login