First, basic settings
Move to the fifth "Enable Camera", enter, press the TAB key to switch to "enable" to confirm the return. Back to the main menu, tab to "Finish" to confirm the return. The Raspberry Pi will restart automatically.
or execute a command to manually shut down the machine
Warning!!!!!!!!!!!!!!!!!!!!!!!!!
Absolutely can not be plugged into the camera with the power supply, if live operation, ten your camera will GG, Bo Master Blood and Tears lessons. And the camera GG after each call or will light, but you can not accept the data, the problem I have Google for a long time, we generally think it should be burnt out = =
When you are all installed, make sure to connect the hardware and then power it. (Remember not to hot-plug the camera)
Second, the configuration of seven Qiniu
We need to create a new warehouse, point to open their own arbitrary selection of nodes, in fact, several nodes in the domestic speed are similar, can meet the demand.
Then we can get the surveillance photos to come here to query
Third, compile the program
First, we write a. Sh script
take_photo.sh
12 |
raspistill - o current_photo.jpg python test.py |
Then install the seven Qiniu python SDK and execute it on the command line
In the take_photo.sh directory we build a test.py
123456789101112131415161718192021222324252627282930 |
# -*- coding: utf-8 -*-
import
time
from
qiniu
import
Auth, put_file, etag, urlsafe_base64_encode
import qiniu.config
import
os
#需要填写你的 Access Key 和 Secret Key
access_key
=
‘‘
#这里的密钥填上刚才我让你记住的密钥对
secret_key
=
‘‘
#这里的密钥填上刚才我让你记住的密钥对
#构建鉴权对象
q
= Auth(access_key, secret_key)
#要上传的空间
bucket_name
=
‘mypi‘
#上传到七牛后保存的文件名
key
=
‘%s_%s_%s_%s_%s_%s.jpg‘
%
(time.localtime()[
0
],time.localtime()[
1
],time.localtime()[
2
],time.localtime()[
3
],time.localtime()[
4
],time.localtime()[
5
])
#生成上传 Token,可以指定过期时间等
token
=
q.upload_token(bucket_name, key,
3600
)
#要上传文件的本地路径
localfile
=
‘current_photo.jpg‘
ret, info
=
put_file(token, key, localfile)
filename
=
‘current_photo.jpg‘
if
os.path.exists(filename):
os.remove(filename)
|
That way, every time we execute the take_photo.sh script, we can have the Raspberry Pi take a picture and send it to the seven cow cloud, we just log in to see the data
Iv. Scheduled execution
Manage this script with Linux's timed task crontab
At the end of the Chase Plus
1 |
* * * * * / home / pi / take_photo.sh |
Restart Cron After
1 |
sudo service cron restart |
Qshell Use tutorial http://developer.qiniu.com/code/v6/tool/qshell.html
Raspberry PI Development Journey-enabling cloud Platform monitoring