[原创] 树莓派项目实践——可用 web 控制的人体感应小夜灯

A time-controllable human sense light based on Raspberry Pi, which has a web UI to control it.
一个基于树莓派的、(开关)时间可控的人体感应灯,可以通过一个web UI界面开灯、关灯,以及设置成自动模式(在感应到人接近的时候自动点亮灯),并且可以设置自动模式的工作时间段。
这个设备已经放在我家里稳定地运行了很久了,很实用。
 

源代码在Github上,极客学院上有我录制的教程


文章来源:http://www.codelast.com/
The Web UI(control panel of the system):

I only tested this system on Raspberry Pi Model B+(Revision 1.2) & Model B(Revision 2), but it should work on other models of RPi too, except that the hardware wiring should be some difference, and the code should need no modification.
文章来源:http://www.codelast.com/

Environment:

Raspberry Pi model: B+/B
OS: Arch Linux ARM
You can use this project to build a human sense light, in short, when a person gets close to the light, the pyroelectric module connected to Raspberry Pi will detect the human movement & ouput a high level to one of the GPIO port on RPi, then the program runs on RPi will light up some LEDs connected to it. Also, you can set the time range of day, only in those time range the LEDs can be lighten up, and in other time range the LEDs will be turned off.

Usage instruction

Dependencies installation

Before compiling this project, you should have some software packages installed on your Arch Linux ARM(besides the basic development tools such as gcc, etc.):

  • WiringPi(a GPIO access library for Raspberry Pi)
git clone git://git.drogon.net/wiringPi && cd wiringPi && ./build
 
  • glog(Google logging module)
pacman -S google-glog
 
  • libconfig(C/C++ Configuration File Library)
pacman -S libconfig
 
  • gtest(Google's C++ test framework) - to run the unit tests in this project
pacman -S gtest

文章来源:http://www.codelast.com/

build the hardware system

Buy essencial electronic components and build the hardware system according to the circuit diagrams.
 

build the binary program

make && make install

modify the configuraion files according to your needs

vim deploy/conf/main.conf
vim deploy/conf/time-range.txt

start the backend program

cd deploy/bin
./run-timer-sense-light.sh
use any web browser to visit the web UI to set parameters(assume that your RPi's IP address is 192.168.16.108)
http://192.168.16.108
文章来源:http://www.codelast.com/

Hardware model

You should prepare some specific hardware components for this project, including:
A pyroelectric module(HC-SR501):


Some LEDs:

文章来源:http://www.codelast.com/

How to know your Raspberry Pi revision

 
Install WiringPi, then execute command "gpio -v" to get RPi's revision, the output info looks like:
gpio version: 2.25
Copyright (c) 2012-2015 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty
 
Raspberry Pi Details:
  Type: Model B+, Revision: 1.2, Memory: 512MB, Maker: Sony
文章来源:http://www.codelast.com/

Future work

Add machine-learning ability to the system, to let it auto-adjust the time range according to history human movement data.

文章来源:https://www.codelast.com/
➤➤ 版权声明 ➤➤ 
转载需注明出处:codelast.com 
感谢关注我的微信公众号(微信扫一扫):

wechat qrcode of codelast

《[原创] 树莓派项目实践——可用 web 控制的人体感应小夜灯》有2条评论

发表评论