pfSense on ALIX 2D13

One of my favourite internet-“television”-shows is TechSnap on On TechSnap 66 there was an interesting user feedback of Felim about installing pfSense on a little ALIX 2D13 box.

[ 28m20s – 30m40s ]

So, I’ve ordered an ALIX 2D13 at Gooze with a ALIX wireless kit and installed pfSense on it.

I’m very happy with it. pfSense works very nice and adding rules to the firewall is very understandable, even for a network noob like me 😉

Raspberry Pi and Wi-Fi

I’ve bought this USB WiFi Adapter at

This cheap (5.25€) WiFi adapter has a Ralink5370 chipset,

and works very well with a Raspberry Pi. Just follow the instructions at

Because I’ve seen some strange behavior (route – default gateway not set correctly) when both eth0 and wlan0 were up, I’ve changed /etc/network/interfaces so that when the USB WiFi adapter is plugged in, eth0 is disabled.

pi@raspberrypi ~ $ cat /etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback

# my wifi device
allow-hotplug wlan0
iface wlan0 inet dhcp
 	pre-up	   ifconfig eth0 down
	wpa-driver wext
 	wpa-conf   /etc/wpa_supplicant.conf
	post-down  ifconfig eth0 up 
# The primary network interface
# allow-hotplug eth0
iface eth0 inet static
	pre-up	ifdown wlan0
	post-down ifup wlan0
pi@raspberrypi ~ $ 

Raspbian I²C

These are the steps to enable I²C on Raspbian after downloading the new Raspbian “wheezy” image.

Add i2c-dev and i2c-bcm2708 to /etc/modules.

pi@raspberrypi ~ $ cat /etc/modules
# /etc/modules: kernel modules to load at boot time.
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
# Parameters can be specified after the module name.

# snd-bcm2835
pi@raspberrypi ~ $ 

Install i2c-tools

pi@raspberrypi ~ $ sudo apt-get install i2c-tools
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  libi2c-dev python-smbus
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/58.9 kB of archives.
After this operation, 223 kB of additional disk space will be used.
Selecting previously unselected package i2c-tools.
(Reading database ... 56011 files and directories currently installed.)
Unpacking i2c-tools (from .../i2c-tools_3.1.0-1_armhf.deb) ...
Processing triggers for man-db ...
Setting up i2c-tools (3.1.0-1) ...
pi@raspberrypi ~ $

Add pi to the group i2c if you want to access i2c without sudo.

pi@raspberrypi ~ $ sudo usermod -a -G i2c pi

Use i2cdetect to see if there are devices connected on the i²C-bus.

pi@raspberrypi ~ $ i2cdetect 0
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-0.
I will probe address range 0x03-0x77.
Continue? [Y/n] y
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
pi@raspberrypi ~ $ 

Mount Raspberry Pi on PCB

The Raspberry Pi is a interesting little computer to use in embedded projects, especially when you need something more powerfull than a common microcontroller.

A disavantage of the Raspberry Pi is that it doesn’t have mounting holes, so it’s difficult to mount it on a PCB.

Because in embedded projects the yellow RCA connector is not usefull, I have used that connector to mount the Raspberry Pi vertical on a experiment board. This is done by using a 3mm bolt with heat shrink, which holds the Raspberry Pi steady in place, but also allows to remove it easily when needed.

To avoid rotating the Raspberry Pi, I have used a second 3mm bolt at the place of the audio connector.

The final result of this quick and dirty hack looks like this:

Note, no Raspberry Pi’s were harmed while doing this experiment 😉

Raspberry Pi TC74 I²C

In my previous post I have connected a TC74 via USB to the Raspberry Pi. It works, but I consider it a waste because the Raspberry Pi has GPIO’s available.

So, I have connected a TC74 directly to GPIO-0 & GPIO-1 of the Raspberry Pi.

On the software side, I make use of the Debian Sqeeuze Image, but upgraded the kernel to Chris Boot’s Raspberry Pi Kernel. I have also installed i2c-tools.

With i2cdetect I can see the TC74 on the I²C bus.

And with i2cget, I can read the current temperature (hex) of the TC74.

To make all this available to a webserver like in my previous post, I have changed cgi-bin/temp to the following:

echo Content-type: text/html

# USB : 
# echo "document.write(\"`/home/pi/usb/temp`\");"

# I2C :
Thex=`/usr/sbin/i2cget -y 0 0x48 0 b | cut -d"x" -f2 | tr '[:lower:]' '[:upper:]'`
T=`echo "ibase=16 ; $Thex" | bc`
echo "document.write(\"$T\");"

Which gives the following result when I connect with a web browser to the Raspberry Pi:

Raspberry Pi + PIC18F4550 TC74 USB

So, now that I have a Raspberry Pi and I can read the temperature with a TC74 over USB, I thought it would be nice to combine them together.

Because the Raspberry Pi makes use of the ARM architecture, a re-compilation of temp.c is necessary.

(click for larger image)

After compiling temp.c, everything just works like on a normal PC… Great! 🙂

As a test, I have then installed a webserver (boa) on the Raspberry Pi and created a little webpage that displays the current temperature.

The index.html of this simple webpage looks like this:

<meta http-equiv="Refresh" content="4">
<body style="margin:0px;" background="background.png" text="#000000"  bgcolor="#E0E0E0" link="#0000FF" vlink="#800080" alink="#FF0000">

<h1>Test : Raspberry Pi Debian GNU/Linux + PIC18F4550 TC74 USB</h1>

<h2>The temperature is now <b><script type="text/javascript" src="/cgi-bin/temp"></script><noscript>No JavaScript support!</noscript></b>C.</h2>


And cgi-bin/temp looks like this:

echo Content-type: text/html
echo "document.write(\"`/home/pi/usb/temp`\");"

When I connect with a normal web browser to the Raspberry Pi, I get a simple webpage that displays the temperature:

It should also be possible to connect a TC74 directly (via I²C) to the GPIO pins of the Raspberry Pi, mmmm,… maybe something for a next post 😉

Read temperature over USB (PIC18F4550 + TC74)

After doing my first USB experiments, I have connected a TC74 I²C temperature sensor to the PIC18F4550.

The PIC18F4550 reads the temperature of the TC74 via I²C and makes it available through the USB port.

When connected to a PC, it is possible to read the current temperature with the program ./pc/temp.

The source is available here, or you can download a tar.gz with all the files.

First experiments with PIC18F4550 USB GNU/Linux gpasm (GNU PIC assembler)

Serial and Parallel ports are becoming less and less common on modern PC’s. Especially, the parallel port was very handy to control something with a PC.

Because of this, I’m now experimenting with USB and a Microchip PIC18F4550, using a 4Mhz crystal.

Problem with USB is that writing USB firmware is rather complex. Microchip has published an USB stack which is written in C. But I prefer USB firmware where (1) I can understand how it works and (2) I can create an HEX file by using my Debian GNU/Linux PC.

I’ve found very interesting firmware written in assembler, but trying to assemble it with gpasm gives a lot of errors 🙁

Lucky enough, I found this thread where Ben Dugan has ported lab2.asm to work with gpasm. After a few modifications, it worked perfectly with the PIC18F4550/4Mhz 🙂      Thanks Ben!

You can download my lab2/PIC18F4550/4Mhz/gpasm source here.

I have also modified the original lab4 found at to work with gpasm. You can download this modified lab4 here. You can compile the pc-files of the original lab4 with “gcc -l usb“.