Senin, 04 Januari 2016
Raspbian setup guide
Senin, 04 Januari 2016 by Alfanet Fx
Initial configurationFor instructions on installing an OS image to your SD card please see here or here.
After Raspbian has been installed login to the Pi from your computer using ssh...
(If you do not have ssh installed then for Windows checkhere,PuTTY is a popular choice,
else see the mainopensshwebsite.)
ssh -l pi {your Pi's IP address}
The default password for the user 'pi' is: raspberry
Run raspi-config
pi@raspberrypi ~ $ sudo raspi-config
(Use arrow keys to navigate. ESC to return. TAB key to move to the bottom line)
- Change User Password (for the 'pi' account) to one of your choosing
- Internationalisation Options -> Change Timezone (set the timezone to your location)
- Enable Camera -> choose
- Overclock -> select Medium
- Advanced Options -> select Hostname (choose the desired name for your Pi)
- Advanced Options -> select Update
- Select Expand filesystem (if all of your SD cards space has not been allocated)
Choose
Log back in as 'pi' and change the root password
pi@dash ~ $ sudo su -
root@dash:~# passwd
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Update the system
root@dash:~# apt-get update
root@dash:~# apt-get dist-upgrade
Add the camera user
root@dash:~# useradd -m -G video camera
root@dash:~# passwd camera
root@dash:~# su - camera
camera@dash ~ $ mkdir -p front rear sound usb logs/tmp
Change the file permissions so the camera directories are available to all (only needed for SAMBA).
camera@dash ~ $ chmod -R 777 /home/camera
camera@dash ~ $ exit
--- Optional ---
The Pi camera usingpicam
If you would like to use picamera for recording (which has a nice text overlay facility) we need to
install Python3 and picamera.
If you would like to use picamera for recording (which has a nice text overlay facility) we need to
install Python3 and picamera.
root@dash:~#apt-get install python3 python-pip
root@dash:~#pip install picamera
The picamera site has some great examples on programs you can write to use it's different
functions:http://picamera.readthedocs.org/en/latest/recipes1.html
--- End?
root@dash:~# apt-get install motion
root@dash:~# vi /etc/motion/motion.conf (an alternative text editor tovi is nano)
The bold variables are required, the others settings are recommended or my defaults.
---
daemon on
process_id_file /etc/motion/run/motion.pid
width 512 <?change to suit your camera
height 288 <?change to suit your camera
framerate 12 <?change to suit your camera
max_mpeg_time 600
output_all on
output_normal off
ffmpeg_video_codec mpeg4
target_dir /home/camera/rear
movie_filename %Y%m%d%H%M-%v
webcam_port 8080 (required for the GPS text annotation)
control_port 9080 (required for the GPS text annotation)
thread /usr/local/etc/thread1.conf (only needed if you are going to use the included scripts)
---
root@dash:~# mkdir /etc/motion/run;chown camera /etc/motion/run
GPIO(if you use LEDs or buttons)
root@dash:~# cd
root@dash:~# git clone git://git.drogon.net/wiringPi
root@dash:~# cd wiringPi
root@dash:~/wiringPi# ./build
GPS
If you are using a serial GPS remove the ttyAMA0 information from /boot/cmdline.txt
root@dash:~# vi /boot/cmdline.txt
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
to something like this:-
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
Comment out the ttyAMA0 line in /etc/inittab (at the very end of the file).
root@dash:~# vi /etc/inittab
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
Install the GPS software
root@dash:~# apt-get install gpsd libgps-dev
SAMBA(if you wish to access the files over a network)
Please see here
Scripts
Get the scripts like so... (as the root user)
root@dash:~# cd;wget http://dropcanvas.com/ozpja/1 -O scripts.tar
root@dash:~# tar -xf scripts.tar;chown -R 0:0 scripts;rm scripts.tarA directory called "scripts" in /root should now contain all the required files. The global.rc file
has many values used by these scripts which you can change to best suit your needs.
audio.sh - Uses arecord to save audio recordings to the audio directory
dashcam.sh - The main startup script. Mounts USB device, rotates logs, disk cleanup etc.
flash - C program to flash LEDs as required (GPIO #, count, delay, finish on/off)
global.rc - Resource file for all the global variables
gps_logger - C program to manage the GPS (via gpsd)
motion_camera.sh - Runs motion to record video when a USB camera is connected
picam.py - Pi camera recording using thepicamerapackage (requires python3)
pivid.sh - Pi camera recording using the raspivid command
pwr_butt - Monitors (GPIO 2 by default) for a button press
Although the scripts can be used separately the idea is to start them from the dashcam.sh program
and stop them with the pwr_butt program (usually via a button press). You can start one or more
programs using the dashcam.sh script with arguments:
/root/scripts/dashcam.sh pwr_butt pivid
This will start only the pwr_butt and pivid.sh camera recording programs.
N.B. If arguments are used then any global.rc *_enabled settings are ignored.
If no arguments are passed to the dashcam.sh then the defaults of GPS, motion, pivid & pwr_butt are
enabled. These defaults will be overridden by values found in /root/scripts/global.rc followed by the
'usb_directory' root mount point global.rc (if it exists) respectively.
Note
Killing pwr_butt with a SIGUSR1 will stop all running programs and shutdown the Pi.
Using SIGUSR2 will do the same but issue a reboot instead.
E.G. pkill -USR2 pwr_butt (or pkill -SIGUSR2 pwr_butt) will reboot the Pi.
The other scripts will try and exit cleanly if killed with an INT, TERM or USR1
A global.rc file can exist at the root of mounted USB storage. Any variables in this file will take
precedent over the progam defaults and also matching variables found in /root/scripts/global.rc
Auto-start
An easy way to have the dashcam script start automatically from boot up is to add it into the
/etc/rc.local file.
root@dash:~# vi /etc/rc.local
/root/scripts/dashcam.sh &
So it looks something like this:-
----
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
/root/scripts/dashcam.sh &
exit 0
----
You can test it works with this command:-
root@dash:~# /etc/init.d/rc.local start
Reboot and (all being well) everything should start when your Pi has booted up.
Other stuff
If you want to disable the Pi camera's LED then add the following to the /boot/config.txt file and reboot.
disable_camera_led=1
reff : http://pidashcam.blogspot.com/2015/03/raspbian-setup-guide.html Tags:
Langganan:
Posting Komentar (Atom)
0 Responses to “Raspbian setup guide”
Posting Komentar