Aula Jazmati
Published © MIT

Motion Detection Automatic Light On/Off with Hexabitz

Automating home stuff is fun. In this tutorial we are using PIR sensor to detect motion and turn ON bulb using Raspberry Pi and Hexabitz.

IntermediateFull instructions provided1 hour753
Motion Detection Automatic Light On/Off with Hexabitz

Things used in this project

Story

Read more

Schematics

Schematic

Code

Demo code

C/C++
/*
    BitzOS (BOS) V0.2.3 - Copyright (C) 2017-2020 Hexabitz
    All rights reserved
		
    File Name     : demo.cpp
    Description   : Hexabitz demo source file. .
*/
/* Includes ------------------------------------------------------------------*/

#include "../hexabitz/BOS.h"
  
uint8_t array[10]={0};


int main(int argc, char *argv[])
{
  
wiringPiSetup () ;
pinMode         (0, INPUT) ;
pullUpDnControl (0, PUD_DOWN) ;
delay_s(1);



int k=0;
while( k < 200){
   k =   k +1 ;
   delay_s(1);
if (digitalRead(0) == 1) 
{ 
std::cout<<"Motion Detected"<<std::endl;  
messageParams[0] = (uint8_t)(10000>>24); 
messageParams[1] = (uint8_t)(10000>>16); 
messageParams[2] = (uint8_t)(10000>>8); 
messageParams[3] = (uint8_t)(10000); 

SendMessageToModule(1, CODE_H0FR6_ON, 4);
delay_s(10);}}


       init();	

	std::cout<<"Press any Key and enter to exit"<<std::endl;
	while(1){
	  
	  
	  if(getchar()!=0) break;
	  
	  delay_s(1);
	      }
	std::cout<<"exiting ..."<<std::endl;
  
	return 0;
}
/*----------------------------------------------------------------------------*/

HF1R0x-Firmware

Solid State Relay (H0FR6x)

Make a Pre-built Array Topology File https://hexabitz.com/docs/how-to/make-a-pre-built-array-topology-file/

Credits

Aula Jazmati

Aula Jazmati

53 projects β€’ 215 followers
πŸ’‘πŸ•ŠοΈ

Comments