Subscribe via feed.

Can a Pi Raspberry?

The Raspberry Pi is a small computer, and as such an obvious but important question occurred to me, and despite Google, I was unable to find an answer. So using science, LEGO, a balloon, and a compressed air supply I set out to discover if the Raspberry Pi could indeed blow a raspberry.

To embark on this scientific discovery, first, I needed to be able to control a motor, for this I built a dual relay board that can be switched using a couple of the Pi’s GPIO pins:

LEGO PF Motor Controller v3

Here is the circuit diagram:

LEFO PF Motor Controller v3

And the Python source code:

To which I connected a large LEGO PF motor. This is used to switch the pneumatic valves via a clutch cog and a large cog. I used a 9v power supply for this, but a PF Battery box can be used, cut an PF extension lead in half, use the light grey side for the motor, and the dark grey end to connect to the battery box. My compressed air supply operates at 2bar / 30 psi, it was built to work with LEGO pneumatics, I found that anything much above that pressure would cause the pipes to pop off the connectors.

The Pi Raspberry Project

Obviously I needed something that would make a sound. For this, a balloon (the sausage type), a small pop bottle, and some more LEGO were suffice. The air is injected into the bottle trough a couple of holes at the rear.

The Pi Raspberry Project

I would like to say thanks to the people on the Raspberry Pi forum for their advice on the electronics: http://www.raspberrypi.org/phpBB3/ and further reading about LEGO PF motors can be found here: http://www.philohome.com/pf/pf.htm, and the raspberry http://en.wikipedia.org/wiki/Blowing_a_raspberry

A Recent walk to Bradfield

Posted under Uncategorized (no responses)

Dreadlock Sheep

Dreadlock Sheep

Goose vs Swan

Swan and Goose

Using the Raspberry Pi to Make Music in the Style of a Pub Singer / Les Dawson

I have built a Toy Organ using a NE555 timer chip and have controlled it with the Raspberry Pi. If you are building this, remember to test with a 6v battery to power the circuit and use a 3v battery on the GPIO input points before you connect it to the Raspberry Pi.

Circuit Diagram:

Pi Organ

Source Code:

Using the GPIO as a Normal User on the Raspberry Pi

In one of my previous posts I mentioned setting the ownership of the /sys/class/gpio to dialout using /etc/rc.local. This worked up to a point, however entries are created in the gpio when you start using them and they retain the original root group permissions, which means you are required to run your code as root. As this is bad practice I have been looking for ways to get around this, so far setting a udev rule has proved futile.

However, I have found a tool called GPIO Admin and they have also written a Python GPIO API for it, simply install the software, add your user to the gpio group and you have access to the header without having to use root. They have written the API for Python 3, but I have found it will work in Python 2.7 (so far, with the version I downloaded on 29 June 2012, its still in development). The Flask framework has not been updated to work in Python 3.

Blinking LED's

Karl’s Roast Calculator

Posted under Interesting (1 response)

Because of this website makeover, my incredibly useful Roast Calculator which, not only, helps you work out the time you need to cook your joint of meat for, but also works out what time to put it in the oven, now has a new link: http://www.g7smy.co.uk/roast

Python and Apache on the Raspberry Pi using the Flask Framework

From reading the Raspberry Pi forum, I see many are wanting to control their hardware projects from the web. Here I will show a method of integrating Python with the Apache web server, and allowing the Apache server access to the GPIO and UART ports without having to run it as root, if you have PHP already installed, both will run in the same environment. For this I am using am using Debian from here: http://www.raspberrypi.org/archives/1435, on a freshly installed SD card.

Part One: Installation, configuration and testing

As root, install the following packages:
# apt-get update
# apt-get upgrade
# apt-get install apache2 libapache2-mod-wsgi python-setuptools python-flask

edit your virtual host in /etc/apache2/sites-enabled, here I have added the wsgi components to the default host 000-default.

Parts easily missed are setting ExecCGI on the Options and adding index.py to the DirectoryIndex. Note that I have set the wsgi to identify python by the extension .py, normally .wsgi is used, I think this is some kind of tradition, or old charter, or something.

Set permissions:
Apache on Debian runs as the user www-data, for access to the serial port and GPIO on the Raspberry Pi you will need to add that user to the relevant groups. Do not run apache as root, while this is not so important when on the Pi it is good practice to avoid.

Edit /etc/rc.local and add these two lines to the end of the file:
chgrp -R dialout /sys/class/gpio
chmod -R g+rw /sys/class/gpio
when you reboot the computer, group permissions will be set to dialout on the gpio

add www-data to the dialout group
# usermod -a -G dialout www-data

Update: the /etc/rc.local method does not work, instead I have found found a tool called GPIO Admin and they have also written a Python GPIO API for it. Currently it is under development, but once installed add apache to the gpio group:
# usermod -a -G gpio www-data
and the web server will have access to the gpio pins

enable the module (it may of been enabled when installed) and restart apache
# a2enmod wsgi
# /etc/init.d/apache2 restart

To test your wsgi installation place the following file into your apache root directory /var/www as myinfo.py and load it using your web browser, http://<pi’s ip address>/myinfo.py .

Part 2: Using The Flask Framework
Here I have made a simple demonstration of how to use Flask, it consists of a wrapper, demo.py, the actual program coreDemo.py and some html to process, demo.html. It does not show how to use the GPIO or UART. The wrapper is used to capture error messages and conveniently display them in the web browser. Again save these files into your apache root directory, /var/www and load it using your web browser, http://<pi’s ip address>/demo.py

demo.py:

demoCore.py:

demo.html:

Now all you have to do is open the port 80 forwarding on your router, and everyone in the world can make your little buzzer project make noises at two in the morning.

Ladybower Sinkhole

Posted under Pictures (no responses)

Ladybower sinkhole

Customising Debian on the Raspberry Pi

Using the latest distribution of Debian for the Raspberry Pi, I wanted add myself as a user and connect to a network share. Here are the steps I took:

install a couple of programs:
# apt-get update
# apt-get upgrade
# apt-get install minicom joe

set default shell to bash, add new user with groups, and set that users password:
# useradd -D -s /bin/bash
# useradd -m -G adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,input <username>
# passwd <username>

created a directory to be shared, and add the samba share to /etc/fstab:
# mkdir /home/raspberry
# nano /etc/fstab

and added this to the end:
//<ip address>/<share> /home/raspberry cifs username=<username>,password=<password>,_netdev,uid=<username> 0 0

set sshd to start on boot:
# dpkg-reconfigure ssh

and removed the console serial output to allow me to use the UART:
http://www.irrational.net/2012/04/19/using-the-raspberry-pis-serial-port/

 

A Case for Raspberry Pi

For the Raspberry Pi computer. More of a framework than a case.

Pi Case