Changes

Jump to: navigation, search

Raspberry Pi

5,776 bytes added, 00:19, 1 November 2015
C-Media USB sound device
*Follow EASY setup - http://elinux.org/RPi_Easy_SD_Card_Setup
*resizing main partition from booted raspberry pi - http://elinux.org/RPi_Resize_Flash_Partitions
==TextMate and rmate for simple remote editing==
*install textmate on os x system
*install ruby on raspberry pi:
<syntaxhighlight lang="bash">
sudo apt-get install ruby
</syntaxhighlight>
*install rmate on raspberry pi:
<syntaxhighlight lang="bash">
sudo gem install rmate
</syntaxhighlight>
*setup ssh tunneling
<syntaxhighlight lang="bash">
ssh -R 52698:localhost:52698 pi@192.168.2.144
</syntaxhighlight>
=Debugging=
*list all device addresses on a port
**<code>arp -i bridge0 -a</code>
==Set IP address==
*On OS X set ethernet to DHCP with manual addressing. Choose address 192.168.3.1.
*Scan for raspberry pi: <syntaxhighlight lang="bash">sudo nmap -sP 192.168.32.1/24 | awk '/^Nmap/{ip=$NF}/B8:27:EB/{print ip}'</syntaxhighlight>==Set .local name==
=Maintenance=
==Backup your System Image==
===backup with rpi-clone===
*uses dd and rsync:
https://github.com/billw2/rpi-clone
 
 
===backup with tar.gz===
http://sysmatt.blogspot.com/2014/08/backup-restore-customize-and-clone-your.html
 
===backup with dd===
*power off the pi, remove the sd card, and insert it in your computer.
*check what drive it is. on os x:
*when it is done. eject the disk.
**<code>diskutil eject /dev/rdisk2</code>
 
==Restore from backup image==
*repeat steps above to insert SD card, identify, and unmount.
=Configuration=
==create local wifi hotspot==
*http://www.daveconroy.com/turn-your-raspberry-pi-into-a-wifi-hotspot-with-edimax-nano-usb-ew-7811un-rtl8188cus-chipset/
*https://forums.adafruit.com/viewtopic.php?f=19&t=47716
 
==create .local domain name for raspberry pi==
*http://www.howtogeek.com/167190/how-and-why-to-assign-the-.local-domain-to-your-raspberry-pi/
=Software=
==pocketsphinx / usb mic==
https://wolfpaulus.com/journal/embedded/raspberrypi2-sr/
==google speech scripts==
<s>*install pyaudio:
<syntaxhighlight lang="bash">
sudo apt-get install python-pyaudio
</syntaxhighlight>
</s>
*install pyaudio dependencies:
<syntaxhighlight lang="bash">
sudo apt-get install libportaudio0 libportaudio2 libportaudiocpp0 portaudio19-dev
</syntaxhighlight>
*install pyaudio:
<syntaxhighlight lang="bash">
git clone http://people.csail.mit.edu/hubert/git/pyaudio.git
cd pyaudio
sudo python setup.py install
</syntaxhighlight>
*install flac:
<syntaxhighlight lang="bash">
sudo apt-get install flac
</syntaxhighlight>
*clone google speech scripts:
<syntaxhighlight lang="bash">
git clone https://github.com/jeysonmc/python-google-speech-scripts
</syntaxhighlight>
 
==Voice Command==
*http://www.instructables.com/id/Raspberri-Personal-Assistant/?ALLSTEPS
./client</nowiki>
If you've done everything successfully, you should see a variety of sample output from the running <code>server</code> program.
==receive osc messages through puredata pd==
*https://www.youtube.com/watch?v=ZBX7UzXTmd4
*execute shell commands http://puredata.hurleur.com/sujet-9005-inteface-shell-scripts
==pyOSC==
*http://www.raspberrypi.org/forums/viewtopic.php?t=59714&p=446513
=Graphics=
After these libraries are built, you can then <code>cd</code> to each example project, <code>make</code>, and run the resultant binary file. Please note that these instructions are repeated in the included <code>README</code> file.
=Hardware Peripherals=Verified Peripherals - http://elinux.org/RPi_VerifiedPeripherals==Pi Camera==
*getting started - http://www.raspberrypi.org/archives/3890
*code: https://github.com/raspberrypi/userland/tree/master/host_applications/linux/apps/raspicam
===motion triggered camera===*taking photos with PIR sensor - http://www.raspberrypi.org/learning/parent-detector/*with motion detection opencv - http://www.sodnpoo.com/posts.xml/raspberrypi_camera_with_opencv_motion_detection_and_recording.xml ===picam python interface===*http://www.raspberrypi.org/learning/python-picamera-setup/===Streaming from RPi to OS X===*RPi: <pre>raspivid -t 999999 -o - | nc 192.168.2.31 5001</pre>*Laptop: <pre>nc -l 5001 | mplayer -fps 31 -cache 1024 -</pre>====low-latency====*http://blog.tkjelectronics.dk/2013/06/how-to-stream-video-and-audio-from-a-raspberry-pi-with-no-latency/ ===Adding an M12 mount===*http://wiki.raspberrytorte.com/index.php?title=Camera_Module_Lens_Modifcation#Lens_Mount_Modification===Taking a Photo=raspistill==
<syntaxhighlight lang="bash">
raspistill -o image.jpg
</syntaxhighlight>
*faster photo: https://bitbucket.org/niklas_rother/rasperry-pi-userland/raw/master/host_applications/linux/apps/raspicam/raspifastcamd_scripts
 ==taking video with raspivid=Take =*take a video===
<syntaxhighlight lang="bash">
raspivid -o video.h264
</syntaxhighlight>
*Convert to mp4<syntaxhighlight lang="bash">ffmpeg -i video.h264 -vcodec copy video.mp4</syntaxhighlight> ==New Video Parameters=new video modes==
*http://www.raspberrypi.org/new-camera-mode-released/
*install rpi-update:<syntaxhighlight lang="bash">sudo apt-get install rpi-update</syntaxhighlight>*update:<syntaxhighlight lang="bash">sudo rpi-update</syntaxhighlight>*exploring camera modes:<syntaxhighlight lang=Capture"bash">v4l2-ctl -p 90</syntaxhighlight><syntaxhighlight lang="bash"> v4l2-ctl -v width=640,height=480,pixelformat=H264</syntaxhighlight><syntaxhighlight lang="bash"> v4l2-ctl --stream-mmap=3 --stream-count=900 --stream-to=test90fps.h264</syntaxhighlight> 
*half resolution, binned:
<syntaxhighlight lang="bash">
raspivid -w 640 -h 480 -fps 90 -t 10000 -o test90fps.h264
</syntaxhighlight>
 
 
 
==streaming the pi camera==
*RPi:
<syntaxhighlight lang="bash">
raspivid -t 999999 -o - | nc 192.168.2.31 5001
</syntaxhighlight>
*Laptop:
<syntaxhighlight lang="bash">
nc -l 5001 | mplayer -fps 31 -cache 1024 -
</syntaxhighlight>
*low-latency: http://blog.tkjelectronics.dk/2013/06/how-to-stream-video-and-audio-from-a-raspberry-pi-with-no-latency/
 
==python interface (picam)==
*http://www.raspberrypi.org/learning/python-picamera-setup/
==motion-triggered capture==
*PIR triggered (motion triggered) camera
*PIR sensor - http://www.raspberrypi.org/learning/parent-detector/
*launch python script in detached screen session:
<syntaxhighlight lang="bash">
sudo screen -dmS mocap /home/pi/code/housemachine/pircam.py
</syntaxhighlight>
*reconnect to screen:
<syntaxhighlight lang="bash">
sudo screen -r mocap
</syntaxhighlight>
*copy new video files:
<syntaxhighlight lang="bash">
rsync -va --ignore-existing pi@office.local:~/videos/pircam/ ~/Pictures/ceiling_fisheye/
</syntaxhighlight>
 
*mmal opencv modetect
*set recording format in code.
*with motion detection opencv - http://www.sodnpoo.com/posts.xml/raspberrypi_camera_with_opencv_motion_detection_and_recording.xml
*https://github.com/sodnpoo/rpi-mmal-opencv-modetect
*run in terminal and save motion frames to video:
<syntaxhighlight lang="bash">
./mmal_opencv_modect > video.h264
</syntaxhighlight>
==wrap h264 then combine two files==
*concat first and second half:
<syntaxhighlight lang="bash">
avconv -i concat:a.h264\|b.h264 -c copy sum.h264
</syntaxhighlight>
*wrap as h264 (with avconv):
<syntaxhighlight lang="bash">
avconv -i sum.h264 -vcodec copy sum2.mp4
</syntaxhighlight>
*wrap as h264 (with ffmpeg):
<syntaxhighlight lang="bash">
ffmpeg -i sum.h264 -vcodec copy sum.mp4
</syntaxhighlight>
 
==alternate lens mounts==
*Adding an M12 mount: http://wiki.raspberrytorte.com/index.php?title=Camera_Module_Lens_Modifcation#Lens_Mount_Modification
 
=Wolfson Audio=
*update wolfson audio drivers - https://blog.georgmill.de/2015/02/18/update-for-wolfson-audio-card-on-raspberry-pi/
*Command line recording - http://www.element14.com/community/community/raspberry-pi/raspberrypi_projects/blog/2014/04/06/wolfson-audio-project
==Jack from OSX to Raspberry Pi==
On Raspberry Pi:
*wolfson script to select audio output:
<syntaxhighlight lang="bash">Playback_to_Lineout.sh</syntaxhighlight> or the direct amixer commands
<syntaxhighlight lang="bash">
amixer -Dhw:0 cset name='HPOUT2 Digital Switch' on
amixer -Dhw:0 cset name='HPOUT2L Input 1' AIF1RX1
amixer -Dhw:0 cset name='HPOUT2L Input 1 Volume' 32
amixer -Dhw:0 cset name='HPOUT2R Input 1' AIF1RX2
amixer -Dhw:0 cset name='HPOUT2R Input 1 Volume' 32
</syntaxhighlight>
*run dbus:
<syntaxhighlight lang="bash">
eval dbus-launch --auto-syntax </syntaxhighlight>
*copy results and export them:
<syntaxhighlight lang="bash">
export DBUS_SESSION_BUS_ADDRESS= ...
export DBUS_SESSION_BUS_PID= ...
</syntaxhighlight>
*start jackd:
<syntaxhighlight lang="bash">jackd -R -T -p 32 -d alsa -n 3 -p 2048 -r 44100 -i2 -o2 &</syntaxhighlight>
*start netone pointed to slave IP:
<syntaxhighlight lang="bash">jack_netsource -H 192.168.0.104 &</syntaxhighlight>
 
On OS X:
*configure jack for necessary outputs (only done once) (2 in 2 out)
*qjackctl with netone backend
 
On Pi:
*route jack signals:
<syntaxhighlight lang="bash">
jack_connect netjack:capture_1 system:playback_1
jack_connect netjack:capture_2 system:playback_2
</syntaxhighlight>
 
*jack routing - https://gist.github.com/nyarla/36724e8931fa6bc244a0
*https://github.com/jackaudio/jackaudio.github.com/wiki/WalkThrough_User_NetJack2
 
=Hardware Peripherals=
Verified Peripherals - http://elinux.org/RPi_VerifiedPeripherals
==C-Media USB sound device==
*setting up with alsamixer, etc - http://asliceofraspberrypi.blogspot.com/2013/02/adding-audio-input-device.html
*setup C-media usb sound device - http://www.cpmspectre.pwp.blueyonder.co.uk/raspberry_pi/MoinMoinExport/DaffodilUSBSoundAdapter.html
==U9 MiniMic==
<syntaxhighlight lang="bash">arecord -f dat | aplay -f dat &</syntaxhighlight>
==C920==
**<code>lpstat -p -d</code>
*lp help http://www.cups.org/documentation.php/options.html
==Wireless Adapters==
*Adafruit adapter: https://learn.adafruit.com/setting-up-a-raspberry-pi-as-a-wifi-access-point/install-software
*LB-Link with mt7601: https://www.raspberrypi.org/forums/viewtopic.php?t=49864
**for kernel 3.18.7-v7: https://dl.dropboxusercontent.com/u/80256631/mt7601-3.18.7-v7-755.tar.gz
=GPIO=

Navigation menu