Raspberry Pi

From Robert-Depot
Revision as of 08:59, 6 May 2014 by Rtwomey (talk | contribs) (Streaming from RPi to OS X)

Jump to: navigation, search

<<< back to Wiki Home

Setup

Install OS on SD card

Debugging

Using a USB to TTL cable

  • Install USB drivers
  • Connect pins like so: 954close_MED.jpg
  • NOTE: LEAVE THE RED WIRE OFF TO USE EXTERNAL POWER SUPPLY. leave the red wire connected to power pi from the usb cable.
  • Use screen to connect to pi. From Terminal, start session:
    • screen /dev/cu.usbserial 115200

What port is my raspberry pi on?

  • list all device addresses on a port
    • arp -i bridge0 -a

Set address

  • On OS X set ethernet to DHCP with manual addressing. Choose address 192.168.3.1.
  • Scan for raspberry pi:
    sudo nmap -sP 192.168.3.1/24 | awk '/^Nmap/{ip=$NF}/B8:27:EB/{print ip}'
    

Maintenance

Backup your System Image

  • power off the pi, remove the sd card, and insert it in your computer.
  • check what drive it is. on os x:
    • df
    • you should see something like /dev/disk2s1, figure out which is your hard drive and which is the SD card.
  • unmount the card.
    • diskutil unmount /dev/disk2s1
  • duplicate the disk to your hard drive. replace the second argument, of=/Volumes/Cistern/RaspberryPi/... with the path and filename where you want to backup the image.
    • sudo dd if=/dev/rdisk2 of=/Volumes/Cistern/RaspberryPi/wheezy-20130522-backup.img bs=1m
    • you can hit Ctrl-t on your keyboard to see stats about the copy in progress.
  • when it is done. eject the disk.
    • diskutil eject /dev/rdisk2

Restore from backup image

  • repeat steps above to insert SD card, identify, and unmount.
  • duplicate from image file to sd card:
sudo dd if=twomey2-20140130-backup.img of=/dev/rdisk2 bs=1m

Shrinking too large image

Backup and Restore Raspberry Pi images to smaller SD cards, using a Linux computer

Add a Data Partition

4 GB:

rtwomey@rtwomey-MacBookPro:~$ sudo fdisk -u /dev/mmcblk0
[sudo] password for rtwomey: 
You will not be able to write the partition table.

Command (m for help): p

Disk /dev/mmcblk0: 3959 MB, 3959422976 bytes
4 heads, 16 sectors/track, 120832 cylinders, total 7733248 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000f06a6

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1            8192      122879       57344    c  W95 FAT32 (LBA)
/dev/mmcblk0p2          122880     7733247     3805184   83  Linux

16 GB

rtwomey@rtwomey-MacBookPro:~$ sudo fdisk -u /dev/mmcblk0

Command (m for help): p

Disk /dev/mmcblk0: 16.1 GB, 16130244608 bytes
4 heads, 16 sectors/track, 492256 cylinders, total 31504384 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00014d34

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1            8192      122879       57344    c  W95 FAT32 (LBA)
/dev/mmcblk0p2          122880    31504383    15690752   83  Linux

update firmware with rpi-update

Configuration

apt-get not connecting

  • add DNS server. see here:

http://www.raspberrypi.org/phpBB3/viewtopic.php?f=63&t=17016

vim instead of vi

vim instead of vi so arrow keys work:

  • sudo apt-get update
  • sudo apt-get -y install vim

bash configuration

  • edit .bashrc:
    • uncomment ll and la

add a user account

while logged in as PI user:

  • sudo adduser MyUser
  • sudo adduser MyUser sudo

now it is time to test out your new account.

  • logout as pi:
    • logout
  • at the login prompt, login as your username created above.
  • CONGRATS!
  • time to shut down your system:
    • sudo poweroff type in your password. the system will shut down.

add audio for non-default user

getting audio to work for a non-default user:

  1. sudo usermod -a -G adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,netdev,input rtwomey
  2. logout, then login

SSH Login

ssh login:

  • should work by default. you just need to know the IP address.
  • Connecting to a local mac with internet sharing on, it's probably 192.168.2.3, or 192.168.2.2.
  • Store your public key on the remote system, so you aren't prompted for password:

http://www.linuxproblem.org/art_9.html

not resolving IP addresses

  • sudo vi /etc/resolv.conf
  • add the line nameserver 8.8.8.8
    • this is the google nameserver.

vnc remote

overclocking

scp

  • to copy photos to my current computer, over ethernet cable:
    • scp rtwomey@192.168.2.3:~/images/*.jpg ~/Pictures/
  • if you've stored your ssh public key, you won't be prompted for password!

Software

Voice Command

Jasper

architecture.png

FM Transmitter

gphoto2

  • installing:
    • sudo apt-get install gphoto2
  • take a photo:
    • gphoto2 --capture-image-and-download
  • after taking a photo it's necessary to reset the USB port. use usbreset util.
    • usbreset /dev/bus/usb/001/004
    • put your /dev/bus/usb device as the second argument above. you can find it from --list-ports.
  • list cameras:
    • gphoto2 --list-ports
  • control and capture of DSLR http://skowron.biz/artikel/gphoto-raspberry/

usbreset

festival

pocketsphinx

Pockesphinx

megahal

  • try it -

supercollider

others

nltk

OpenCV

hd video playback

Video

OSC

liblo

To use liblo to write an OSC client and server in C, first install the liblo development package on both the computer you would like to broadcast from (the client) and the computer that will receive the messages (the server). Using APT: apt-get install liblo-dev

Then, visit http://liblo.sourceforge.net/ and navigate to the example code or documentation. The example code provides a simple client and server. If you're just copying and pasting these, and would like to quickly compile them and test that they work, do the following for the server:

wget http://liblo.sourceforge.net/examples/example_server.c
gcc -o server example_server.c -llo
./server

And for the client:

wget http://liblo.sourceforge.net/examples/example_client.c

Then on the line defining an lo_address, change NULL to the IP address of your server. Finally

gcc -o client example_client.c -llo
./client

If you've done everything successfully, you should see a variety of sample output from the running server program.

Graphics

OpenGL

Using OpenGL on the Raspberry Pi appears to be pretty idiosyncratic. For instance, see https://benosteen.wordpress.com/2012/04/27/using-opengl-es-2-0-on-the-raspberry-pi-without-x-windows/. Don't be misled by what is described on that webpage. While correct, far simpler example projects exist on the Raspberry Pi at /opt/vc/src/hello_pi. These are very useful! Read the README there, and get cracking. To get started, you can build every project by running:

sh rebuild.sh

If you would only like to build a subset of the projects, first cd to /opt/vc/src/hello_pi/libs, and build each library included there. Specifically:

cd /opt/vc/src/hello_pi/libs/ilcient && make
cd ../vgfont && make

After these libraries are built, you can then cd to each example project, make, and run the resultant binary file. Please note that these instructions are repeated in the included README file.

Hardware Peripherals

Verified Peripherals - http://elinux.org/RPi_VerifiedPeripherals

Pi Foundation Camera Module

Streaming from RPi to OS X

  • RPi:
    raspivid -t 999999 -o - | nc 192.168.2.31 5001
  • Laptop:
    nc -l 5001 | mplayer -fps 31 -cache 1024 -

low-latency

Adding an M12 mount

Taking a Photo

raspistill -o image.jpg

Take a video

raspivid -o video.h264

New Video Parameters

Capture

  • half resolution, binned:
raspivid -w 1296 -h 972 -t 10000 -o pi_0.h264
  • 90 frames per second VGA:
raspivid -w 640 -h 480 -fps 90 -t 10000 -o test90fps.h264

C-Media USB sound device

C920

microline 320 printer

installing

  • install cups
    • sudo apt-get install cups
    • willtake a little while
  • install menu item:
    • sudo apt-get install system-config-printers
  • reboot
  • add printer
    • start ltxde:
      • startx
    • Select Menu->Preferences->Printing
    • Printer should autodetect. Or you can enter the URI manually: parallel:/dev/usblp0
    • Change model to Generic, type Raw. This will pass raw data to printer.
  • http://ubuntuforums.org/showthread.php?t=1436079&page=2

command line

GPIO

through python

Logic Level Conversion

  • RPi is 3.3V.

untested

Applications

Use as AirPlay receiver

Problems

Course of Instruction