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

Build Your Own Motion Detector

Transform your space into a smarter and safer environment with this DIY Smart Motion Detector Device!

BeginnerFull instructions provided2 hours333
Build Your Own Motion Detector

Things used in this project

Hardware components

Adafruit PIR Motion sensor
×1
Grove - OLED Display 0.66" (SSD1306)- IIC - 3.3V/5V
Seeed Studio Grove - OLED Display 0.66" (SSD1306)- IIC - 3.3V/5V
×1
Wemos D1 Mini
Espressif Wemos D1 Mini
×1
Triple adapter
×1

Software apps and online services

Arduino IDE
Arduino IDE
Web-Flashing tool

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free

Story

Read more

Schematics

PIR_D1-Mini_0.66-OLED

Stack your soldered PIR, D1-Mini, and OLED onto the triple as shown.

Code

PIR_D1-Mini_0.66-OLED.ino

C/C++
Here is the Arduino code, copy and paste it into your Arduino IDE, select the appropriate port, and upload it.
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define OLED_RESET -1
Adafruit_SSD1306 display(OLED_RESET);

const int PIR = D3;
int PIRState = 0;
 
void setup() 
{
  Serial.begin(9600);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.setTextColor(WHITE);
 delay(2000);
 
  pinMode(PIR, INPUT);
   
}
 
void loop() 
{
  PIRState = digitalRead(PIR);
 
  if (PIRState == HIGH) 
  {
    display.clearDisplay();
    display.setTextSize(1);
    display.setCursor(35, 15);
    display.write("INTRUDER!\n");
    display.display();
    
  } 
  else 
  {
    display.clearDisplay();
    display.setTextSize(1);
    display.setCursor(40,15);
    display.write("No motion\n");
    display.display();
  }
  delay(1000);
}

Credits

TIMOTHY MWALA
29 projects • 17 followers
I am an Embedded engineer who like prototyping
Contact

Comments

Please log in or sign up to comment.