From charlesreid1

A guide to hacking on the Raspberry Pi, a microcomputer that runs a full stack Linux OS, all on a mobile processor:

RaspberryPi PluggedInRPi.jpg

Installing

The page containing instructions for installing an operating system on the Raspberry Pi is over at RaspberryPi/Installing


Interfacing with Headless Pi

If you are running a headless Raspberry Pi, you can follow these instructions for modifying the Raspberry Pi boot sequence so that you can find your Pi on a network: RaspberryPi/Headless


First Steps with Pi

You can find a guide to your first steps with Raspberry Pi, mainly covering the setup process for Raspbian Linux: RaspberryPi/First Steps

Running Web Server on Raspberry Pi

If you're running a web server on Raspberry Pi, you'll probably want to run on port 80. However, Raspberry Pis sometimes have a problem when installing Python packages into /usr/local/lib, so you have to install them into a custom directory. This creates a problem when trying to import the package as root, because root python won't be able to find it (won't have the $PYTHONPATH variable set correctly).

To get around this, you can bind to port 80 without being root by following these instructions:

http://stackoverflow.com/questions/413807/is-there-a-way-for-non-root-processes-to-bind-to-privileged-ports-1024-on-l

http://www.wensley.org.uk/info#setpcaps

Flask

Flask is an excellent lightweight web server in Python. Flask makes it easy to create an API for requesting data and passing JSON between Python (which is a powerful language that can control all kinds of things on the Raspberry Pi) and Javascript (which provides a nice user front-end via a web interface).

For an example of how you might do this, see my Dymouse project on Github: http://github.com/charlesreid1/dymouse

This uses a Raspberry and a Flask script to create an API for a USB postage scale. Python provides a means for grabbing the weight reading from the postage scale; Flask turns it into JSON; and Javascript turns the JSON into HTML text/plots.

Raspberry Pi Projects

Raspberry Pi Timelapse Photo

Software

Since I hadn't connected my Pi to the net in a while, the first thing I did was to update the package manager:

sudo apt-get update

Next, I upgraded the operating system:

sudo apt-get dist-upgrade

With all of the updating and upgrading out of the way, I moved on to the actual Raspberry Pi camera itself. There is a Python module to control the Pi camera, available through aptitude:

sudo apt-get install python-picamera python-picamera-docs

However, I was still not able to use my camera, because I had to run the Raspberry Pi configuration program. To run it:

sudo raspi-config

You enable the Raspberry Pi camera in the configuration menu.

Setup

The setup I had used one of these as the camera. This is a whopping 5 MP, which is as good as a point-and-shoot, except it's extremely tiny. I was able to get it hooked up to my Raspberry Pi and working just fine with the above steps.

You can use Python code to trigger the camera to take a picture, and you can specify a filename to save to. Here's a quick script I hacked together to take a picture every 2 seconds, and save it to sequentially-numbered files (0001.jpg, 0002.jpg, etc.):

# pic.py

import picamera
import time

camera = picamera.PiCamera()

i = 0
while True:

    filename = "%04d.jpg"%(i)

    camera.capture(filename)
    print "Saving photo to %s"%(filename)

    i += 1
    time.sleep(2)

To run this, I use screen. I log in remotely, then run the screen command. In that screen I run python pic.py. It will print out as it progresses. Running it with screen allows you to disconnect and leave the Pi unattended.


Hello World LED Circuit with GPIO

This project controls a simple LED circuit with the Raspberry Pi's onboard GPIO cable. A python code is used to send high/low voltage signals to pins on the GPIO, and make an LED on a breadboard blink.

Hello_World_Arduino_Pi


Kali Linux on Raspberry Pi

Getting deeper into the world of networking and using the Pi to analyze networks: Kali Pi

Resources