Monday, June 29, 2015

How To Backup Your Pi

If you use your Pi often, like me, you know that it can be a pain to lose everything by reinstalling Raspbian whenever something breaks. To avoid this you can backup your home folder to save a copy of all of your work.

Time: 5 minutes.
Difficulty: Easy.

You will need:

  • A way to access your Pi.
  • A USB flash drive.
Steps:
  1. Open the command line and type sudo su. You will need to be a superuser to do this. The user Pi is by default.
  2. Type cd /home/
  3. Type tar czf pi_home.tar.gz pi
  4. Type exit to exit the superuser shell.
  5. Now move the file pi_home.tar.gz to your flash drive and you are finished. The file is located in your /home folder.

Wednesday, June 24, 2015

Setting Up Motion to Access a Webcam Over Your Local Network

In this tutorial we will use Motion to access a webcam connected to your Pi. When we are finished, you will be able to see a live stream of a camera on your local network.

Time: About 30 minutes.
Difficulty: Medium

You will need:

  • A way to access your Pi's terminal. SSH, works great because all you need is the command line.
  • A webcam.
  • An internet connection.
Steps:
  1. Log in to your Pi and open the terminal.
  2. type sudo apt-get install motion
  3. sudo nano /etc/motion/motion.conf
  4. This will open a long configuration file.
  5. There are a couple of things you will need to change, but since the .conf file is so long, it can be helpful to use CTRL+W to find things.
  6. You will need to change daemon off to daemon on.
  7. You will also need to change webcam_localhost on to webcam_localhost off. This will make it so any computer on the network can access the stream, not just the Pi.
  8. You will also need to disable control_localhost by changing it from control_localhost on to control_localhost off.
  9. That should be it, just exit the nano editor and restart.
  10. You will need the IP address of your Pi. You can get it by typing hostname -I.
  11. In a browser, type the address and at the end, type :8081. You should see a live stream from your webcam. I have had problems with Google Chrome but Firefox works fine.

Tuesday, June 23, 2015

Blinking your first LED

In this tutorial we will blink an LED using Python.

Time: 10 minutes
Difficulty: Easy

You will need:

  • A Raspberry Pi.
  • A way to access its terminal.
  • A breadboard.
  • A 220 ohm resistor.
  • An LED
  • An Internet connection on your Pi.
  • 2 Jumper Wires
Steps:
  1. If you don't have the GPIO library, you'll need to install it by typing sudo apt-get install python-dev python-rpi.gpio. If you get an error message, try typing sudo apt-get update --fix-missing and try again
  2. Wire up your pi exactly as shown. Be sure to do the wiring with the Pi unplugged.
  3. Type sudo nano /home/pi/Desktop/RPiLED.py
  4. Copy and paste the following code into the nano editor. 
  5. import RPi.GPIO as GPIO  import time    
    def blink(pin):  
            GPIO.output(pin,GPIO.HIGH)  
            time.sleep(1)  
            GPIO.output(pin,GPIO.LOW)  
            time.sleep(1)  
            return  
    GPIO.setmode(GPIO.BOARD)    
    GPIO.setup(11, GPIO.OUT)    
    for i in range(0,50):  
            blink(11)  
    GPIO.cleanup()
  6. Exit the nano editor by pressing CTRL+X, Y, and Enter.
  7. Right now, running RPiLED.py will cause the LED to blink 50 times. You can change how many times the LED blinks by changing the highlighted text above.
  8. Try running your script by typing sudo python RPiLED.py in the terminal.
  9. If it does not work, check your wiring. If you don't see a problem, try using a different LED.
The code for RPiLED came from www.rpiblog.com.


Wednesday, June 17, 2015

Using Your Raspberry Pi to Take Time Lapse Videos

For this project, we will be setting up a webcam on the Raspberry Pi using fswebcam. We will then create a shell script to take a pictures at scheduled intervals. This is a great skill building project so we will do some variations on it in the future. The video below was taken this way.


Time: 20 minutes
Difficulty: Easy

You Will Need:

  • A Raspberry Pi.
  • Some way to access it's terminal. You can use SSH, Remote Desktop, or keyboard and mouse.
  • A USB webcam.
Steps:
  1. Plug in your USB webcam before powering on your Pi.
  2. Power on your Pi and open the terminal.
  3. Type sudo apt-get install fswebcam. This is a simple way to use a webcam with your pi. You can test it by typing fswebcam /home/pi/Desktop/this_is_my_test_picture.jpg. You will see your picture
  4. Type mkdir /home/pi/Desktop/Timelapse
  5. We will now write a bash script to take the pictures.
  6. Type sudo nano /home/pi/Desktop/timelapse.sh
  7. In the nano editor, type DATE=$ (date +"%Y-%m-%d_%H%M")
  8. On the next line type fswebcam /home/pi/Desktop/Timelapse.
  9. Press CTRL+X, then y, and then Enter to exit nano.
  10. Right now all our script does is take a picture. We want it to take lots of pictures at specified intervals. To do this, we will use cron, a way of scheduling tasks to run on the Pi at certain intervals.
  11. To edit your crontab (the place where cron looks to find out which command to run) type crontab -e in the command line. You will see this window.
  12. In the bottom, in a new line, type * * * * * /home/pi/Desktop/timelapse.sh. Save with CTRL+X, Y, and Enter. You should then the message "crontab: installing new crontab"
  13. If everything is set up correctly, you should start to see pictures in your Timelapse folder.
  14. You can use any video editor to turn your stills into a video. According to the Raspberry Pi website, you can use the following commands to convert the pictures on the Pi.
  15. sudo apt-get install mencoder
  16. cd /home/pi/Desktop/Timelapse
  17. ls *.jpg > stills.txt
  18. mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4:aspect=16/9:vbitrate=8000000 -vf scale=1920:1080 -o timelapse.avi mf type=jpeg:fps=24 mf://@stills.txt



Using SSH to Access Your Pi's Terminal Remotely

In this tutorial I will show you how to use SSH and PuTTY to access your Pi's command line from a Windows computer.

Time: 5 minutes
Difficulty: Easy

You Will Need:

  • A Raspberry Pi running Raspbian.
  • A keyboard and mouse. You can also use Remote Desktop.
  • A Windows computer.
Steps:
  1. Log in to Raspbian and open the terminal.
  2. Type sudo raspi-config and press Enter.
  3. Use the arrow keys to navigate to "Advanced Options".
  4. Use the arrow keys to navigate to "SSH"
  5. Navigate to the "Enable" button and press Enter.
  6. You will see a screen saying that SSH is enabled. Hit "OK".
  7. Navigate to the "Finish" button and press Enter.
  8. You will be prompted to restart your Pi. Hit the "Yes" button.
  9. You are done with setup on the Pi. Now we will install PuTTY on your Windows machine from the PuTTY website.
  10. Go to the link in step 9 and install PuTTY.
  11. When you open PuTTY you chould see something like this.
  12. Enter in your Pi's IP address in the box labeled "Hostname (or IP address)"
  13. Set your "Connection type" to SSH
  14. Click "Open" (You can save your setup for later by clicking save)
  15. You will have to log in to your Pi with your username and password.

  16. You should now see the command line of your Pi.

Tuesday, June 16, 2015

Host a Wordpress Site on the Raspberry Pi

In this tutorial I will show you how to host a Wordpress website from your Pi.

Time: About an hour.
Difficulty: Medium.

You Will Need:

  • A Raspberry Pi running Raspbian
  • An Internet connection
  • Keyboard, mouse, and monitor. Or you can use remote desktop.
Steps:
  1. Log in to Raspbian and open the terminal.
  2. Type sudo apt-get install apache2 -y and press Enter.
  3. Find the IP address of your Pi with hostname -I.
  4. Write down and save the IP address.
  5. In a web browser, navigate to the IP address.
  6. You should see this.
  7. Type sudo apt-get install php5 libapache2-mod-php5 -y. This will install php.
  8. Type sudo apt-get install mysql-server php5-mysql -y. This will install SQL.
  9. SQL will prompt you to set a password. Remember it, you'll need it later.
  10. Now we will install Wordpress.
  11. Type cd /var/www
  12. Type sudo chown pi: .
  13. Type sudo rm *
  14. Type wget http://wordpress.org/latest.tar.gz
  15. Type tar xzf latest.tar.gz
  16. Type mv wordpress/* .
  17. Type rm -rf wordpress latest.tar.gz
  18. Now let's set up the Wordpress database
  19. Type mysql -uroot -p
  20. You will have to enter the password you set earlier.
  21. Type create database wordpress;
  22. Then use Ctrl-D to exit
  23. Go to the IP address of your Pi and you should see a Wordpress site like this one.
  24. Press the Let's Go! button to fill in the details for the configuration form.
  25. You will now have to enter in the information as follows.

  26. Press submit.
  27. Copy and paste the information from the next screen to wp-config.php and hit Ctrl+X, Y, and Enter.
  28. Click Run the Install.
  29. Fill out the form in the next page and click Install Wordpress.
  30. DONE!
Log in to Wordpress to customize your site!

The code for this project came from the Raspberry Pi Official Website. They have many great tutorials so check them out!

Monday, June 15, 2015

Using Remote Desktop Connection to Access Your Pi.

In this tutorial I will show you how to use XRDP and Remote Desktop Connection to access your Raspberry Pi remotely. This process is very simple and eliminates the need for a keyboard, monitor, and mouse.

Time: less than 5 minutes.
Difficulty: Easy

You Will Need:

  • Raspberry Pi running Raspbian.
  • Keyboard, mouse, and monitor (for setup only).
  • An Internet connection, either Ethernet or wifi.
  • A Windows computer
Steps:
  1. Start your Pi and log in to Raspbian.
  2. Open your terminal.
  3. Type sudo apt-get update and press Enter.
  4. Type sudo apt-get install xrdp and press Enter.
  5. Once this finishes, type hostname -I. This will show the IP address of your Pi. Write it down and save it for the next step.
  6. log in to your windows computer
  7. Open Remote Desktop Connection
  8. Type the IP of your pi in the box labeled Computer.
  9. This should show a log in form for your Pi.
  10. Type in the user name and password for your Pi.
  11. You should see your Pi's desktop or terminal.




The OSMC Media Center Operating System



OSMC is a media center operating system for the raspberry pi. There are many different media center type operating systems for the raspberry pi (Raspbmc and OpenELEC) this one has worked out best for me, and here’s why.


  •  Add-ons. They are easily installed from within the OS and seem to work pretty well.
  • The OSMC skin. OSMC comes preloaded with a beautiful, functional, and easy to use skin.
  • The online remote. It comes preloaded with one but it only really works if you are looking at the screen. I use Chorus, which can be downloaded from within the OSMC operating system.
  • Samba. Samba requires almost no configuration except for turning it on. Once Samba is running you can easily transfer files to and from your Pi.
Let’s talk about the other media center operating systems.

I  tried Raspbmc and was never really able to get it to work. I did not like the interface as it was confusing and did not look very nice. I would not recommend it.
I also tried OpenELEC which was slightly better but still not perfect. It ran and add-ons such as YouTube and Pandora were available. The interface was the same though and it was not as fast as OSMC.

Conclusion.

OSMC is by far the best. It is fast and responsive and the add-ons work. I would highly recommend it as a media center operating system.
 

Friday, June 12, 2015

New Project: Tangram on the Raspberry Pi

Hello,

For my first project I am trying to set up Tangram (a map program) on the raspberry pi B+. So far I have installed Tangram, built it for the Pi, and configured it to read the map tiles locally, instead of just getting them from the Internet. There are, however, a couple of problems. The map tiles are HUGE! An individual tile is not but when you need to download literally thousands of them (more than 4,000 just for Manhattan) it can be easy to eat through all of the space on the Pi. Also, after downloading all the map tiles for Manhattan, and cringing as all of my memory disappeared before my eyes, the map was still very slow and took a long time to update. My goal in the end is to have an on-board screen, (maybe PaPiRus), a GPS module, and a battery.