CxD Archive
Code: Internet of Things 2.0
Code: Internet of Things 2.0
  • Code Introduction
  • Prerequisite Knowledge
  • Tutorials
    • A. Meet Your IoT Kit
      • A-1 Circuit Board
      • A-2 Other Components
      • A-3 Electronic Circuits
    • B. Hello World Test
      • B-1 Start IoT Device
      • B-2 Login to Web IDE
      • B-3 New App Template
      • B-4 Global Variable
      • B-5 Setup Function
      • B-6 Loop Function
      • B-7 Flash App to Device
      • B-8 Modify App
    • C. Smart Light Device
      • C-1 Connect LED
      • C-2 Copy Hello World App
      • C-3 Connect Button
      • C-4 Add Button Code
      • C-5 Modify Button Code
      • C-6 Particle Cloud Code
      • C-7 Web App HTML
      • C-8 Web App CSS
      • C-9 Web App JS
    • D. Smart Security Device
      • D-1 Connect Motion Sensor
      • D-2 Connect Speaker
      • D-3 LED and Button Code
      • D-4 Motion Sensor Code
      • D-5 Speaker Code
      • D-6 Particle Cloud Code
      • D-7 Web App HTML
      • D-8 Web App CSS
      • D-9 Web App JS
  • References
    • Particle Build
    • Photon Device App
    • Web App - Single Screen
    • Web App - Multiple Screens
    • Particle Cloud
      • Web App Prep Steps
      • Get Device Variable
      • Call Device Function
      • Get Device Events
    • Physical Inputs
      • Push Buttons
      • Trimpot Dial
      • Motion Sensor
      • Magnetic Switch
      • Light Sensor
      • Temperature Sensor
      • Soil Moisture Sensor
      • Accelerometer
      • Ultrasonic Sensor *
    • Physical Outputs
      • LED Lights
      • Speaker
      • Servo Motor
      • Micro OLED Display
  • Links
    • IoT Project Guidebook
    • Particle Build (Web IDE)
    • Wiring Language
    • Photon Firmware
    • Particle API JS
    • W3Schools
    • Photon Kit Experiments
Powered by GitBook
On this page
  • Tutorial Goals
  • Smart Security System
Export as PDF
  1. Tutorials

D. Smart Security Device

PreviousC-9 Web App JSNextD-1 Connect Motion Sensor

Last updated 2 years ago

In this fourth tutorial, you'll modify your "Smart Light" device into a "Smart Security" device and program new apps for the device.

Tutorial Goals

The goals of this fourth tutorial are to help you:

  • Gain further experience by creating another practice IoT device and programming its apps

  • Become better prepared to create your own IoT device and apps for your team project

Smart Security System

For decades, security systems have been used to monitor homes and businesses for emergencies (burglary, fire, flood, etc.). These systems use some combination of: motion sensors, door/window sensors, glass break sensors, video cameras, smoke detectors, flood sensors, etc. Today, many security systems are being connected to the internet to offer additional features.

You'll create a prototype of a Smart Security device by modifying your Smart Light device (which has an LED light and push button) to add a motion sensor and a speaker:

  • The LED light will be used to indicate whether the security system is currently "armed" (LED is on) or "disarmed" (LED is off).

  • The push button will be used to switch the security system between "armed" and "disarmed" mode. (The button will simulate a security system's keypad, which is used to enter a numeric passcode. For this prototype device, you'll simply press the button to toggle the system between modes, as if you had correctly entered a passcode.)

  • The motion sensor will detect whether something is moving within the surrounding area.

  • The speaker will be used to produce an alarm sound if motion is detected.

You'll use a copy of your Smart Light device app as starter code for your Smart Security device app. You'll modify the existing code controlling the LED and button before adding new code to control the motion sensor and speaker.

You'll also program a web app that interacts with your Photon over the internet to perform these tasks:

  • Monitor the security system's current mode ("armed" or "disarmed")

  • Remotely toggle the security system between "armed" or "disarmed" mode

  • Receive an event notification if the security system detects motion

  • View the date and time of the last motion event detected