This project uses a PIR motion sensor in order to detect if there is a person in the room that it's in. If it doesn't detect movement for 15 minutes, it will trigger the photoresistor to check the light levels in that room. If the lights are on, it will send trigger a webhook to send a text message using pushcut informing the owner that the lights are on.
HowItWorks
When the device is on, the PIR motion sensor will be constantly scanning the room for motion using an infrared sensor. If it detects motion, it will reset the timer and display that there's motion and the light level in the room on a serial port, which you can check here if you want, (Spacehuhn Serial Terminal). If, in 15 minutes it doesn't detect motion, it will have the photoresistor check the amount of light in the room. If the lights are off, it will mention that in the serial port, then the PIR sensor will continue scanning. If the lights are on, then it will trigger a webhook in particle which will trigger an app called pushover to send you a notification that the lights are on.
CircuitDiagram
https://app.cirkitdesigner.com/project/dba2b47c-a2d9-4979-b482-e99df9e10aa6
PIRSensor
Use the male to female wires to connect the power prong to 3v3, output to D6, and the ground to GND, like in the diagram.
Turn both dials fully counterclockwise.
CodingGo to the Particle Web IDE, and create an app called motionsensor. Copy and paste the code into the app.
Webhook
Go to Particle Console | Build your connected product, click on add new integration, and scroll down to create a custom webhook. Then, download the App Pushcut on the Appstore. When you go into the app, you should see a plus sign in the corner to create a new notification. Create a notification called "Lights On", and when you click on it to edit it, you should see a URL on the 3rd row from the top. Take this URL and paste it into the URL section of your webhook. Name your webhook "PushCut", the event name "Lights", request type "POST", request format "Web Form", and Device as "any". From there, click on Extra Settings and scroll down to "Form Fields", which should be the first option. Turn it to custom, type "APP_TOKEN" into the key. Go back to Pushcut, go to account, then create an API Key (Don't share this or your URL with anyone, or they might be able to send you notifications). Take the API Key and then paste it in the Value section of form fields.


















Comments