Soekris net4801 pfSense Router

0

I’ve been running a pfSense router on a small form-factor PC for a few years and have been happy with my setup. What I don’t like though is that the PC is relatively loud and draws way more power than is necessary to meet my routing needs. As part of a recent move I thought I would take advantage of the opportunity and dig out my old Soekris 4801 and try it out as my router instead.

Following are the steps I took to turn my net4801 into a pfSense router and the resulting speedtest returns.

The Box

In case you don’t know, the Soekris net4801 is a compact, low-power, low-cost, computer based on a 233 Mhz 586 class processor. My box has three 10/100 Mbit Ethernet ports, 256 Mb SDRAM main memory and a 4Gb CompactFlash card plugged into the main board.

Soekris net4801

Soekris net4801

Flashing the CF Card

The first thing we need to do is grab a copy of the image we want to burn to our CF card. I grabbed a copy of the latest embedded platform build for i386 for 4g cards (pfSense-2.1.4-RELEASE-4g-i386-nanobsd.img.gz).

Next we need to extract the image and burn it to our card. This is an easy process regardless of platform, but I happened to be on a Mac when I downloaded the image so those are the steps I’ll provide:

  1. Double-click the downloaded gzip in Finder and it will extract the image file to pfSense-2.1.4-RELEASE-4g-i386-nanobsd.img
  2. Insert the CF Card and unmount the Volume – Your volume name may be different. If in doubt, Google it!
  3. sudo diskutil unmount /dev/disk2s1
  4. Write the image to the card
  5. sudo dd bs=512000 if=pfSense-2.1.4-RELEASE-4g-i386-nanobsd.img of=/dev/rdisk2

This process will take a while so don’t be in too big of a hurry.

Booting Up

Now you’re ready to install the CF Card back in the 4801 and boot up. Some sites claim that the image will just work and the Soekris box will boot right up. That, however, was not my experience.

In order to find out what was going on I needed a way to view the device console. Since the Soekris box doesn’t have a VGA, DVI or HDMI port, I had to dig through my stash to find some parts to connect to the old-style serial console port. The Soekris box has a male DB9 serial port for its Console. No computer made in the past five years or so has a DB9 serial port. I needed to find an old computer with a serial port or buy a Serial to USB adapter.

I grabbed the first desktop I could find and was lucky enough to find a serial port on the back. Like the Soekris, this port was also a male DB9 style interface. Next I started searching for cables. I found two male to female DB9 cables and a null-modem adapter – PERFECT!

Serial Cable and Null Modem Adapter

Serial Cable and Null Modem Adapter

I set up my computer and booted it up and was pleased to see an old Ubuntu server installation. A couple of guesses for the ID and Password and I was in. Next step was to connect the null-modem adapter between the two cables and then connect one end of the resulting cable to the Soekris and the other to the Linux PC. I then fired up a copy of screen and rebooted the Soekris:

screen /dev/ttyS0 9600

At this point the pfSense software started its configuration routine. I won’t cover the details here other than to say that I defined my WAN, LAN and OPT1 ports and configured DHCP for the LAN interface. Once this was complete I was able to access the web interface via a browser.

The Test

Before I tried out the new Soekris box I ran a Speedtest as a baseline.

pfsense-1

I then plugged my WAN and LAN connections into the Soekris box and ran the test again.

pfsense-2

I wanted to ensure that my results were accurate so I proceeded to run the tests a few more times just to be certain that the results were consistent. A number of runs on each server showed that the results were very close each and every time.

Conclusion

Ultimately the loss in performance meant that the Soekris was not a viable replacement option for my small form-factor PC which has more memory, faster NICs and a better processor. I think I’ll opt for a VK-T40E pfSense hardware appliance which has an AMD G-T40E Processor with 2 CPUs and 4Gb of SDRAM and should provide equal or better performance than my existing PC based router.

Until next time – GEEK OUT!

~GT~

   

Dayton Audio MA1240a Amplifier Hack

0

I recently bought a couple of Dayton Audio MA1240a Twelve Channel Multi-Zone Amplifiers to power the speakers I have throughout my home. What drew me to this particular amp was its fair price and the fact that it has an “Auto” setting that senses a signal on the RCA line-level inputs that is supposed to automatically put the amp in to ready mode.

After receiving the amps and setting them up, I ran them in the “On” setting for a couple of weeks while I waited for the time to fully integrate the amps into my Home Automation setup.

ha-audio1

Close Up of the connections panel on the back of the MA1240a. The zone area is replicated another five times for a total of six zones.

One of this weekend’s projects was to set up six Apple Airport Express servers to act as zone controllers for each of the designated zones in my home. The idea was to leave the amps in the Auto setting which would spend most of their time in standby mode. As I route music through an Airport the appropriate amp should then switch to ready mode and start playing music – easy, right!?!

We’ll let’s just say the “Auto” feature of this amp is terrible. After sitting down and configuring the amps, I discovered that using the Auto feature does, indeed, pull the amps out of standby mode as desired, but after they heat up (20 – 30 minutes) they start to drop in and out of ready mode thus causing my zones to turn on and off. If I put the amps back to the On setting they work just fine.

It would be easy enough to just turn the units on and off, as needed, by pressing the power button on the unit face, but it just irks me when something doesn’t work correctly. My other issue with this is that it’s not a “wife proof” approach. If my wife can’t just press a button on the iPad to make it work, then it’s not acceptable (my standard, not hers). So, the next step was to figure out a way to fix the problem.

One approach was to use a relay powered wall outlet such as the RPS-NODE-9255 Single Port Web/Internet Remote Power Switch. Another option was to use a Z-Wave or Insteon managed outlet. Either of these options would work, but this is a bit of a brute-force way of accomplishing the goal. I wanted something more elegant.

The other option was to use MA1240a’s “Trigger” feature which is a handy way of connecting the amplifier to an automation system. The 3.5mm mini-plug jack is rated to accept a 3-30V AC/DC output from another device. When the trigger circuit is energized, the amp is supposed to switch into ready mode.

Since I drive most of my Home Automation via Insteon I decided to use an I/O Linc so I could easily trigger a relay while, at the same time, leveraging the I/O Linc’s on-board 5V output to feed into the amp’s Trigger circuit.

ampWire1v2

Using a 5V IO/Linc voltage source. 3.5mm mini-plug wired for positive tip.

To accomplish this, I found an old 3.5mm mini-plug from my stash and wired it up and then jumpered the 5V output into my circuit. Pre-hookup multi-meter testing showed that the circuit performed as expected by delivering 5V DC to the mini-plug when the I/O Linc relay was engaged.

Photo Jun 08, 1 13 46 PM

Smarthome I/O Linc with a 3.5mm mini-plug and internal 5V DC to drive the amp trigger circuit.

When I hooked the jack up to the amplifier and energized the relay, the amp switched to ready mode and all seemed well. After a few seconds though the amp started misbehaving. Just as with the Auto setting that I tried previously the amp would drop in and out of ready mode thus causing my zones to turn on and off.

Before giving up I thought I would try to use a higher voltage to see if that might help the MA1240a’s relay to stay engaged thus keeping the device in ready mode. Unfortunately the I/O Linc doesn’t supply an output for anything more than 5V so that meant the solution was going to need to get a bit more complex. Turning to my trusty stash, I found a wall-wart that put out 12V DC and wired that into my circuit.

ampWire2v2

Using a 12V wall-wart. 3.5mm mini-plug wired for positive tip.

I then proceeded to hook the jack up to the amplifier and, again, energized the I/O Linc relay and the amp immediately switched to ready mode. I waited for a few seconds and, this time, there was no drop out. It worked!

Photo Jun 08, 2 50 23 PM

Smarthome I/O Linc with a 3.5mm mini-plug and external 12V DC to drive the amp trigger circuit.

Now my whole house audio system is, once again, wife proof. She can press a button and the amp comes on and starts playing music in the zone or zones of her choosing.

Until next time – GEEK OUT!

~GT~

   

The Fireplace Hack – Revisited

3

Back in February 2013 I wrote an article entitled “Hacking a Fireplace”. In that article I wrote about how I used an Arduino to create an interface that would allow me to directly control my fireplaces from my home automation system. That solution worked great and I was successful in running two fireplaces from the single controller for a year with no issues. What I didn’t like though was that the completed project was bulky and I wanted something much smaller that I could put under the fireplace, thus out of sight! To accomplish this, I decided to buy a couple of Model B Raspberry Pi’s to replace the Arduino.

Raspberry Pi

Raspberry Pi

Following is how I set them up.

WARNING: Let me interject here that one should exercise EXTREME caution before deciding to implement any kind of automated home controls such as those I will outline below! If you’re not comfortable dealing with electrical circuits then STOP here. Also be aware that your fireplace is supplied with natural gas or propane and working with its components presents a hazard. If you don’t know what you’re doing STOP and hire a professional to help you.

Prep Work

The first thing I did was set my DHCP server up to assign specific addresses to each Pi. These are the addresses that my HA system uses to trigger the on/off events.

Server Setup

Start by installing Raspbian. My implementations will be headless so I chose not to run a desktop thus reducing a little bit of overhead. There are tons of install examples online so I won’t cover that here. Once complete, run:

sudo raspi-config

Now choose to expand the filesystem and reboot.

Install Software

sudo su
apt-get install php5-cli php5-curl apache2 php5 libapache2-mod-php5 vim

Install WiringPi

I’m a CLI guy and WiringPi lets me control the GPIO pins via a command line utility – LOVE that!!

git clone git://git.drogon.net/wiringPi
cd wiringPi
git pull origin
./build

Setup Wi-Fi

There is no GUI to configure Wi-Fi so we’ll need to configure it manually. Don’t forget to use your own SSID and password.

sudo su
vim /etc/network/interfaces

Replace the contents with the following:

auto lo

iface lo inet loopback
iface eth0 inet dhcp

#iface wlan0 inet manual

auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-ssid "yourSSID"
wpa-psk "yourPASSWORD"

iface default inet dhcp
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

By default, Raspian will try to manage the adapter’s power use by putting it to sleep. This causes all kinds of issues so we need to disable that “feature”.

sudo su
vim /etc/modprobe.d/8192cu.conf

Now paste the following and reboot:

# Disable power saving
options 8192cu rtw_power_mgnt=0 rtw_enusbss=1 rtw_ips_mode=1

Interfacing the Relay to the Raspberry Pi

I picked up a couple of these simple single-relay boards off of Amazon:

Relay Board

Relay Board

Then I wired the relay to the Raspberry Pi as follows:

Relay Raspberry Pi
vcc 3v3
gnd gnd
in #4

Here’s a layout of the Raspberry Pi pin layout along with the WiringPi assigned pin numbers:

GPIO Layout

GPIO Layout

My relay is a single pole, double throw relay. Connect to the common and normally open side of the relay and use the following commands (note that wiringPi changes the pin numbers):

gpio mode 7 out to setup the gpio pin for output mode

gpio write 7 1 to turn off (high)
gpio write 7 0 to turn on (low)

If connecting to the normally closed side of the relay the commands would be opposite of the above to turn off/on.

With my setup, when connecting this way, it is CRUCIAL to use the normally open side of the relay. If connecting to normally closed, a power failure would turn the fireplace on – NOT the desired result.

Startup Script

In order for this solution to function correctly we need to initialize the Raspberry so that our GPIO pin behaves in the desired way.

sudo su
vim /etc/init.d/relayinit

Now past the following:

#! /bin/bash
# /etc/init.d/relayinit


# Carry out specific functions when asked to by the system
case "$1" in
start)
echo "Starting Relay"
# Turn 7 on which keeps relay off
/usr/local/bin/gpio write 7 1
#Start Gpio
/usr/local/bin/gpio mode 7 out
;;
stop)
echo "Stopping gpio"
;;
*)
echo "Usage: /etc/init.d/relayinit {start|stop}"
exit 1
;;
esac

exit 0

Make the file executable:

chmod 777 /etc/init.d/relayinit

Now tell your pi to run this script at boot:

update-rc.d -f relayinit start 4

(Note: You can safely ignore the “missing LSB tags” warning.)

Fireplace Code

Now we need to set up an interface on the Raspberry Pi so we can control the relay from an external source (e.g. my HA system). A simple PHP application will serve this purpose perfectly:

vim /var/www/fireplace.php

Now paste the following:

<?php

#Turn Fireplace Off
if ($_GET["RELAY2"] == "2") {
  exec('gpio write 7 1',$output, $return);
  if ($return == 0) {
    echo "2";
  } else {
    echo "problem";
  }
} elseif ($_GET["RELAY2"] == "1") {
#Turn Fireplace On
  exec('gpio write 7 0',$output, $return);
  if ($return == 0) {
    echo "1";
  } else {
    echo "problem";
  }
} else {
#Get status
  exec('gpio read 7',$output, $return);
  if ($output[0] == 0) {
    echo "on";
  } elseif ($output[0] == 1) {
    echo "off";
  } else {
    echo "unknown";
  }
}
?>

Now all I need to do is wire the relay in parallel with the Skytech system and make some minor tweaks to my HA scripts and I’m off an running.

Until next time – GEEK OUT!

~GT~

   

Go to Top