Brief introduction
A simple device for the control sensor of the terminal
Features that can be implemented
It can realize real-time monitoring of Raspberry Pi terminal by mobile phone, camera gimbal manipulation, intrusion alarm, temperature detection, light control, automatic light control and other functions.
Equipment pictures
Run
All the hardware that needs to be used
- Router
- Raspberry Pi Motherboard
- Raspberry Pi power supply (5V 2A)
- At least 8g TF card (recommended class 10,8g enough)
- OUV-enabled Camera (Logitech C170)
- Peanut stick and power supply (or replace with Peanut Shell Intranet version )
- Lego bricks (small particles)
- Two cable
- Temperature sensor (DHT11)
- Light sensor (photosensitive resistor module)
- Human infrared sensor (HC-SR501)
- Relays (5V low-level triggering)
- Stepper Motor (28BYJ-48-5V)
- Stepper Motor Drive Board (UL2003 type)
- Gpio Connection Line several
Windows side of all software that needs to be installed
Python 2.7.9
- Download Link: https://www.python.org/downloads/
Putty (0.63)
WinSCP (5.1.7)
Win32diskimager (0.9.5)
notepad++
Raspberry Pi End
Configuration process Initialization Raspberry Pi using putty login Raspberry Pi
Username: pi
Password:raspberry
Get root Permissions
sudo passwd root
(You need to enter the root password you want to set twice)
sudo passwd --unlock root
Restart Putty When Setup is complete, log in as root
Free up space and set time zones
Log in as root will automatically eject the Raspi-config settings tool, you can also directly enter the raspi-config
recall
1. Perform the first item, always select OK
2. Select the fourth item and select the second entry to enter the time zone setting
3. Select Asia--shanghai, OK, change to + 8 time zone
Set static IP
sudo nano /etc/network/interfaces
Put this line
iface eth0 inet dhcp
Replaced by
iface192.168.1.101255.255.255.0192.168.1.1114.114.114.114
Modify the Resolv.config file
sudo nano /etc/resolv.conf
Revision changed to
nameserver114.114.114.114
Otherwise, the domain name may not be resolved under static IP conditions
Update the software source (optional)
nano /etc/apt/sources.list
Delete all content from the original file and replace it with the following:
deb http://mirror.sysu.edu.cn/raspbian/raspbian/ wheezy main contrib non-freedeb-src http://mirror.sysu.edu.cn
Ps: Raspberry Pi Official list of software sources http://www.raspbian.org/RaspbianMirrors
PS2: Several software sources in China
Zhongshan university
http://mirror.sysu.edu.cn/raspbian/raspbian/
China University of Science and Technology
http://mirrors.ustc.edu.cn/raspbian/raspbian/
Tsinghua university
http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/
Hust
http://mirrors.hustunique.com/raspbian/raspbian/
Dalian Neusoft Information Institute Source (North user)
http://mirrors.neusoft.edu.cn/raspbian/raspbian/
Chongqing University Source (Midwest users)
http://mirrors.cqu.edu.cn/Raspbian/raspbian/
Update the cache and upgrade the software
sudo apt-get update && apt-get upgrade
Installation and Configuration
Install all required software, install required packages, and debug successfully
If there is a problem with the debugging process, please refer to the other articles in this blog (appendix), or welcome the message to discuss
Installing the Software
Configure the Router
In the router setup interface, set up a static IP for the Raspberry Pi, or set a static IP on the Raspberry Pi, remembering this IP
Configure the peanut wand (or
Peanut Shell Intranet version)
If the network environment has a public IP, you can set DDNS on the router (DDNS can search other related articles), if this environment is not available, the Peanut shell Intranet version (software) or peanut stick (hardware) to achieve public address and docking with the common platform.
First apply for a peanut shell domain name, and then log on to the Peanut Stick Management page (http://hsk.oray.com/bang/)
Select the intranet map to add the map, fill in the Raspberry Pi static IP, map the Raspberry Pi 80 port to the domain name, and check the use of the external network 80 port (very important, otherwise unable to complete the docking)
Apply for another peanut shell domain name, map this domain name to the Raspberry Pi 8080 port, still check the use of the external network 80 port
Ps: On the Peanut shell intranet version of the acquisition, you can
http://www.oray.com/activity/140902/
To pay one-yuan certification fee to open the free service
Peanut shell internal version of the installation and peanut stick is similar, it is necessary to note that if the use of Peanut shell intranet version in the work before the need to confirm the Peanut shell Intranet version of normal work and can be normal analysis
Configure Apache2
Because my 80 port needs to be occupied by the public platform, so I can not let the page go 80 ports, need to change the port
nano /etc/apache2/ports.conf
Change listen 80 to listen 8080
Debug camera
Run the "stream.sh" file in the Testcam folder into the git package directory in the Raspberry Pi:
sudo chmod +x stream.sh
(The script file must be compiled before it can be run with./filename)
sudo ./stream.sh
When you run the program, if an error occurs, the process is still working because it was running, and it is not possible to run it, you can run Ps-a, view the running process and process ID number, and then use the " kill id号
" kill process
Run the "testcam.html" file in the Git package on your PC, right-click on edit index.html, change to 树莓派ip
your Raspberry Pi fixed IP, save, double-tap open testcam.html
See the camera output image to indicate that the camera is working properly.
Application and configuration of public platform test account
- Open page http://mp.weixin.qq.com/wiki/home/index.html request a test account for a public platform
- Select Test number application on the left | online debug Select interface Test number application
- After successful application, enter the management interface
- Enter the domain name you applied for in the peanut shell at the URL of the interface configuration information, followed
/weixin
by
Fill in tokens with a list of your favorite letters and don't click Submit when you're done.
(At this point you can download my previous public platform base template for docking, you can successfully docking after the next work to test the network environment is configured to complete
Article address: http://blog.csdn.net/u010027419/article/details/40835963)
Download and configure the main program
deploying Web pages
- Edit the index.html in the file in the GIT package and change it to the IP address of the Raspberry Pi in your Raspberry Pi IP
- Upload the index.html to the
/var/www
directory, replacing the previous index.html
- Enter in the browser
http://你的树莓派局域网ip:8080/
to try to access
If the page appears successfully, the Web page deployment succeeds
Set up a public account menu
- Select Get access token below the public platform management test account
- On the left menu select * Base interface get access token*
- At the bottom right, select Debug this interface using the Web Debugging tool
- Get access token first
Before you fill in AppID and secret to manage the data provided on the Test Account page, click Check Questions
- The blue Access_token Below is the one that will be used to submit the menu access_token, copy this token
- Select the custom menu in the interface type and select the custom menu in the interface list to create the interface. Enter the following interface, fill in just the access_token(access_token has a certain timeliness, time is too long to be re-acquired)
- In the body, fill in the contents of the Menu.txt in the Git package, and click Check Questions
- The menu creation is successful if Request successful is displayed.
Ps: You can view the effect directly by cancelling the attention number again. Otherwise constrained, it takes 24 hours for the cache to be refreshed before it can be viewed.
PS2: parameter Description
Parameters |
whether you must |
Description |
button |
Is |
The first-level menu array, the number should be one |
Sub_button |
Whether |
Two-level menu array, the number should be a |
Type |
Is |
Response Action type for menu |
Name |
Is |
Menu title, no more than 16 bytes, sub-menu no more than 40 bytes |
Key |
Click Type must |
Menu key value, for message interface push, no more than 128 bytes |
Url |
The view type must |
Web links, users click on the menu to open the link, no more than 256 bytes |
Apply for Yeelink Internet of Things service
- Open http://www.yeelink.net/Registered Account
- After landing on the admin home page, your API Key is Yeekey
- Add a new device
- Remember your device ID when you're finished adding it
- Fill in the program with your device ID and yeekey, and change the neighborhood to
自己的yeelink页面
your own page
End & Tips
- In touch with Python, a very good language
- Learned to write a blog markdown, too convenient
- Playing Raspberry Pi, super awesome little computer
- I bought a lot of fun little things with my money.
- Have developed a lot of good habits
Appendix
Python's public platform base code
Https://github.com/329703622/raspchat
Sensor Debug Code separately
Https://github.com/329703622/Sensor
Raspberry Pi, topsy-public platform – Beginner's chapter
http://tieba.baidu.com/p/3232803694
Raspberry Pi, play public platform – Intermediate
http://tieba.baidu.com/p/3477722264
Using Raspberry Pi with public platform docking (python)
http://blog.csdn.net/u010027419/article/details/40835963
Public Platform button and menu creation
http://blog.csdn.net/u010027419/article/details/40949065
Raspberry Pi Camera related to surveillance
http://blog.csdn.net/u010027419/article/details/41123709
Raspberry Pi Control Stepper motor (python) via Gpio
http://blog.csdn.net/u010027419/article/details/41518321
Raspberry Pi Connection dht11 temperature sensor get temperature (python)
http://blog.csdn.net/u010027419/article/details/41722261
Raspberry Pi set up HTTP Server Mount Web page
http://blog.csdn.net/u010027419/article/details/42343057
HTML page compatible with mobile browser (to solve the problem of small display page)
http://blog.csdn.net/u010027419/article/details/44857827
Running on Raspberry Pi smart home prototype