Home Control With Cayenne

Home Control With Cayenne © LGPL

This Project is used to Make our home secure and reduce theft with the help of Motion sensor and Cayenne App.

  • 3,256 views
  • 1 comment
  • 11 respects

Components and supplies

Apps and online services

About this project

This Project is used to Make our home secure and reduce theft with the help of Motion sensor and Cayenne App. PIR sensors allow you to sense motion, almost always used to detect whether a human has moved in or out of the sensors range. They are small, inexpensive, low-power, easy to use and don't wear out. For that reason they are commonly found in appliances and gadgets used in homes or businesses:

Materials which I have used to give alert, Interfaced PIR Sensor and buzzer with Arduino microcontroller.

Circuit diagram for connecting sensors for my project.

Code

Home Control With CayenneC/C++
#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space
#include <CayenneEthernet.h>

// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = "AuthenticationToken";

// Virtual Pin of the Digital Motion Sensor widget.
#define VIRTUAL_PIN V1

// Digital pin the motion sensor is connected to. Do not use digital pins 0 or 1 since those conflict with the use of Serial.
const int motionSensorPin = 4;

void setup()
{
	Serial.begin(9600);
	Cayenne.begin(token);
}

void loop()
{
	Cayenne.run();
	checkSensor();
}

int previousState = -1;
int currentState = -1;
unsigned long previousMillis = 0;

void checkSensor()
{
	unsigned long currentMillis = millis();
	// Check sensor data every 250 milliseconds
	if (currentMillis - previousMillis >= 250) {
		// Check the sensor state and send data when it changes.
		currentState = digitalRead(motionSensorPin);
		if (currentState != previousState) {
			Cayenne.virtualWrite(VIRTUAL_PIN, currentState);
			previousState = currentState;
		}
	}
}

Comments

Similar projects you might like

Servo Control with TV Remote Control

Project showcase by eldo85

  • 5,662 views
  • 5 comments
  • 18 respects

Arduino Based Security Project Using Cayenne

Project tutorial by ScottC

  • 9,169 views
  • 3 comments
  • 19 respects

Automated Irrigation System Using Cayenne

Project in progress by Jhonnatan Garcia

  • 9,093 views
  • 0 comments
  • 32 respects

Feel the Heat with Arduino and Cayenne

Project showcase by PauliusPlus

  • 4,802 views
  • 3 comments
  • 22 respects

MKR1000 Christmas IoTree with Cayenne Project Builder

Project tutorial by Benny Estes

  • 2,905 views
  • 3 comments
  • 9 respects
Add projectSign up / Login