Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Lithium ION
Published © GPL3+

This Microwave Sensor Can Look Behind Walls

A motion detection system using microwave sensor which comes with a lot of precision.

BeginnerFull instructions provided1 hour261
This Microwave Sensor Can Look Behind Walls

Things used in this project

Hardware components

Gravity: Digital Microwave Sensor (Motion Detection)
DFRobot Gravity: Digital Microwave Sensor (Motion Detection)
×1

Software apps and online services

Arduino IDE
Arduino IDE
PCBWAY

Story

Read more

Schematics

Circuit

Code

10ghz_mm.ino

Arduino
/*!
 * @file  microwaveSensor.ino
 * @brief  This example reads temperature and humidity from SHT1x Humidity and Temperature Sensor.
 * @copyright  Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
 * @license  The MIT License (MIT)
 * @author  Loan <Loan.he@dfrobot.com>
 * @version  V1.0
 * @date  2015-7-30
 */

/***********Notice and Trouble shooting***************
  1.Connection and Diagram can be found here
<https://wiki.dfrobot.com.cn/_SKU_SEN0192__Microwave_sensor%E5%BE%AE%E6%B3%A2%E4%BC%A0%E6%84%9F%E5%99%A8%E6%A8%A1%E5%9D%97>
  2.This code is tested on Arduino Uno, Leonardo, Mega boards.
  3.arduino Timer library is created by jonoxer.
  See <https://www.dfrobot.com.cn/images/upload/File/SEN0192/20160112134309yy5nus.zip arduino Timer library> for details.
 ****************************************************/
 
#include <MsTimer2.h>           //Timer interrupt function
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);
int pbIn = 0;                   // Define the interrupt PIN is 0, that is, digital pins 2
int ledOut = 13;
int count = 0;
volatile int state = LOW;       //Define ledOut, default is off

void setup()
{
  Serial.begin(9600);
  pinMode(ledOut, OUTPUT);
  lcd.init();                      // initialize the lcd 
  lcd.init();
  lcd.backlight();
  lcd.setCursor(1,0);
  lcd.print("Motion Tracker");
  lcd.setCursor(5,1);
  lcd.print("System");
  delay(2000); 
  lcd.clear();
  attachInterrupt(pbIn, stateChange, FALLING); // Sets the interrupt function, falling edge triggered interrupts.
  MsTimer2::set(1000, process); // Set the timer interrupt time 1000ms
  MsTimer2::start();//Timer interrupt start

}

void loop()
{
  Serial.println(count); // Printing times of 1000ms suspension
  lcd.setCursor(0,0);
  lcd.print("Motion Detected");
  lcd.setCursor(6,1);
  lcd.print(count*10);
  delay(100);
  
  if (state == HIGH) //When moving objects are detected later, 2s shut down automatically after the ledout light is convenient.
  {
    delay(1000);
    state = LOW;
    digitalWrite(ledOut, state);    //Turn off led
    lcd.clear();
  }

}


void stateChange()  //Interrupt function
{
  count++;

}

void process()   //Timer handler
{
  if (count > 1) //1000ms interrupt number greater than 1 is considered detected a moving object (this value can be adjusted according to the actual situation, equivalent to adjust the detection threshold of the speed of a moving object)
  {
    state = HIGH;
    digitalWrite(ledOut, state);    //Lighting led
    count = 0; //Count zero

  }
  else
    count = 0; //In 1000ms, interrupts does not reach set threshold value is considered not detect moving objects, interrupt the count number is cleared to zero.
}

Credits

Lithium ION
59 projects • 38 followers
A passionate electronics DIY boy. Currently improving in Embedded systems, soldering and programming.
Contact

Comments

Please log in or sign up to comment.