Book Image

Internet of Things Programming with JavaScript

Book Image

Internet of Things Programming with JavaScript

Overview of this book

The Internet of Things is taking the tech world by storm, and JavaScript is at its helm. This book will get you to grips with this exciting new technology. Where do Node.js, HTML5 and Windows 10 IoT Core come in with JavaScript and IoT? Why Raspberry Pi Zero rather than Arduino? How do you configure and build an IoT network from scratch? All your IoT JavaScript questions are answered in this book.
Table of Contents (15 chapters)
Internet of Things Programming with JavaScript
Credits
About the Author
www.packtpub.com
Customer Feedback
Preface

Detecting motion with a PIR sensor


We will build a project with a common home automation sensor: a motion sensor (PIR). Have you ever noticed those little white plastic modules that are in the top corners in some rooms of the houses, the modules that change color to red when someone walks in front of them? That's exactly what we will do in this project.

The motion sensor must have three pins: two for the power supply and one for the signal. You should also use a 5V voltage level to be compatible with the Arduino card, which also operates at 5V. The following image shows a simple motion sensor:

For practical purposes, we will use the signal input 8 for connecting the motion sensor, the signal voltage of 5 volts and ground GND.

PIR sensor interfaced with Arduino

PIR sensors detect body heat (infrared energy). Passive infrared sensors are the most widely used motion detectors in home security systems. Once the sensor warms up, it can detect heat and movement in the surrounding areas, creating a...