Cool, you got your Raspberry Pi. Now what?
There are wealth of information and projects you can find on the web. And you can always start with the official Raspberry Pi Documentation.
For now, let's get it started! You can either use a NOOBS sd card, or download one image to load on to a sd card to install the OS. At least for the first time setup, we suggest you have the following equipment ready:
After first time login and setup some basics, you can connect to Raspberry Pi using other simpler approaches that do not require monitor, nor USB keyboard/mouse. The first thing is to enable SSH and Serial by running raspi-config.
sudo dd bs=4m if=2016-11-25-raspbian-jessie.img of=/dev/rdiskN
ssh pi@raspberrypi.local, then login with default password: raspberry
Reference: Shrink using GParted on Ubuntu,
or Resizing an image.
Here is my outline by doing on a Ubuntu box:
sudo dd if=/dev/sdc of=/home/USERNAME/shrink_image_name.img bs=block_size count=block_count. For example, if you shrink the space to 3.6G, you can use block_size=4M and block_count=900, 4M x 900 = 3600M
Be very very careful with next command, you need to be definitely, positively sure that "/dev/diskN" is the SD card where you want to put raspberry pi, replace "diskN" with actual disk number.
If you are not sure, just don't do it, and wait until we meet next time. You could run the risk of wiping out your own computer!!
On Macbook:
diskutil list // to find out the disk number N of your SD card diskutil unmountDisk diskN sudo dd bs=4m if=downloaded_image_file of=/dev/rdiskNAfterwards, eject SD card from Finder window, and pull out the SD card.
In order to get into Raspberry Pi headless, please add this two files under /boot directory (usually /Volumes/boot on Mac)
# /etc/wpa_supplicant/wpa_supplicant.conf ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid="your_wifi_ssid" psk="your_wifi_passwd" key_mgmt=WPA-PSK }
This is pretty much the most important thing you care about. You need network connection to go on Internet, and you will be untethered to Raspberry Pi if you get "wifi" going.
To check network status, at command line, type ifconfig. To scan for WiFi network, type sudo iwlist wlan0 scan.
sudo vi /etc/wpa_supplicant/wpa_supplicant.confThen add the following section to wpa_supplicant.conf
network={ ssid="your_wifi_ssid" psk="your_wifi_password" key_mgmt=WPA_PSK }
sudo vi /etc/network/interfaces
auto lo iface lo inet loopback allow-hotplug wlan0 iface wlan0 inet dhcp wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf iface default inet dhcp
sudo raspi-config; then go to Interface Options; set vnc to Yes.
When running Pi in headless mode, need to bring up a virtual desktop for VNC to connect to. Login to Pi, and start
vncserver &then note down the IP address and display number, and use that information in your VNC viewer to connect to this display. When it is done, you can stop the virtual desktop on Pi by
vncserver -kill :[display_number]
sudo apt-get install mutt
set smtp_url="smtp://your_gmail_account@smtp.gmail.com:587/" set smtp_pass="your_gmail_password" set from="your_gmail_account@gmail.com" set realname="Your Name"
#!/bin/bash # Email-to-SMS Gateways # number@txt.att.net / @vtext.com / @messaging.sprintpcs.com / @itelcel.com HOSTNAME=`hostname` # EMAIL=PHONENUMBER@txt.att.net # EMAIL=1234567890@vtext.com ETH=`ifconfig eth0 | grep inet | awk '{print $2}' | sed 's/addr://'` WLAN=`ifconfig wlan0 | grep inet | awk '{print $2}' | sed 's/addr://'` echo "eth0 ip: $ETH, wlan0 ip: $WLAN" | mutt -s "$HOSTNAME ip:" $EMAIL > /dev/nullMake sure to set the script executable: chmod +x notifyIpAddress.sh
## trigger notifyOnStartup script to send out notification post-up /home/pi/notifyIpAddress.sh &
Reference to Linux commands for beginner
A more comprehensive and advanced reference to Linux shell environment and shell script
Reference to vi cheatsheet for beginner
A more comprehensive reference: vi editor tutorials
Install software Text-to-speech software on reaspberry pi. Reference link. You can use any of the package: festival, espeak, pico
sudo apt-get install festival
Also setup omxplayer to play .mp3 file over a speaker. You can copy .mp3 file from your computer to Raspberry Pi for testing, or use "wget" or "curl" to download .mp3 from Internet onto Raspberry Pi. Or copy one from your computer to Raspberry Pi:
scp sample.mp3 pi@[your_raspberrypi_ip_address]:/home/piYou can adjust the spearker volume by using amixer, such as:
amixer sset PCM,0 60%
We will use PS3 Eye, which is a great inexpensive webcam too, with 4 speaker array on the back. We can use it for audio input, as well as taking video and image for future project of image / face recognition.
sudo apt-get install motion
sudo apt-get install libav-tools
sudo modprobe bcm2835-v4l2
arecord -l
arecord -D hw:1,0 -f s16_le -c 4 filename.wav
omxplayer filename.wav
sudo motion -n
Reference: Alexa Voice Service sample wiki
Note: before you start the automatic installation process, please use "sudo raspi-config" to "expand file system" first, so we have enough disk space for the installation.
During automatic installation, please observe the output log information. You may see some warning messages, which may be fine. If you see error messages, pay attention to those and may need to be handled.
If everything goes smoothly, you may see this messages at the end.
To run the demo, do the following in 3 seperate terminals: Run the companion service: cd /home/pi/alexa/alexa-avs-sample-app/samples/companionService && npm start Run the AVS Java Client: cd /home/pi/alexa/alexa-avs-sample-app/samples/javaclient && mvn exec:exec Run the wake word agent: Sensory: cd /home/pi/alexa/alexa-avs-sample-app/samples/wakeWordAgent/src && ./wakeWordAgent -e sensory KITT_AI: cd /home/pi/alexa/alexa-avs-sample-app/samples/wakeWordAgent/src && ./wakeWordAgent -e kitt_ai GPIO: PLEASE NOTE -- If using this option, run the wake word agent as sudo: cd /home/pi/alexa/alexa-avs-sample-app/samples/wakeWordAgent/src && sudo ./wakeWordAgent -e gpio
You need to use VNC to access Pi GUI interface, and run "Terminal" within the GUI environment, because the AVS Java Client requires GUI.
Use VNC to gain access to Raspberry Pi GUI mode, then start Sonic Pi, by going to "Raspberry" icon -> "Programming" -> "Sonic Pi" to bring up Sonic Pi application.
Reference materials:
Please make a piece of music at home, and we will share during next class.
Use VNC to gain access to Raspberry Pi GUI mode, then start Minecraft game, by going to "Raspberry" icon -> "Game" -> "Minecraft" to start the game.
Reference materials: Minecraft API
You can use IDLE env (python) to control and play the game, and you can write a program to remotely control the game too.
Download "Reverb" app, which acts as Amazon Echo device. Also download "Alexa" app, so you can manage Alexa Skill Kit (ASK).
Reference materials:
Develop a ASK skill for home automation.
Here is a Raspberry Pi image for sync up our Raspberry Pi environment setup. image as of 2017.01.15 You can use restore approach to load to your SD card.