Longer than a Weekend Project

My original plan was to build an Arduino based oil tank level sensor, but all my plans grow legs. Now the Arduino will also be battery powered, measure the temperature and pressure, monitor the battery level, transmit it’s measurements via 433 MHz radio to a Raspberry Pi and consume as little power as possible – so I have to change the batteries less often.

I have a tendency to get lost in projects like this. I forget about the end goal and take my time never getting there. To help avoid falling into old habbits, I’m going to speed date the components of the system giving myself a maximum of two hours with each before moving on to the next part. Hopefully we’ll see some part of the project come near to completion quite quickly.

Well, the parts are ordered:

  • Bosch BMP180 Digital Barometric Pressure Sensor Board Module
  • Generic 433 MHz Tx/Rx Pair
  • HC-SR04 Ultrasonic Sensor Distance Measuring Module

Here are some resources I’ve been reading:

Here’s the fruit of my labour so far…

System level diagram of circuit to be mounted on an exterior oil tank.

System level diagram of circuit to be mounted on an exterior oil tank.

Next instalment will be after the goods arrive.

Patching and Diff

I’ll be using git to keep track of system configuration changes in my efforts to build a concise kickstart to be redeployed again at a later stage to build another cluster.

git uses diff -u rather than plain diff. I generally like this, but the default of showing three lines of context gets in the way at times.

For example, I’ll want to incorporate the network bonding setup into the kickstart file, but, by default the installation will include the MAC address for each interface in the ifcfg-ethX files. If my patch includes a MAC addresse in the context, the patch will fail to apply. Not good.

To overcome this, when generating the patch use:

git diff -U0 <file>

This produces 0 lines of context thus eradicating the problem.

Fedora 20: Full Network Installation

I’ve got a new (old) PC from work that I want to put Fedora 20 onto. In the distant past, I would burn the full set of installation CDs / DVD. More recently, I’d burn the NetInst CD and do a network install of the rest from a mounted DVD ISO on another machine on my LAN. This time, I’m going to download the bare minimum necessary to PXE boot the target machine, and do the rest over the net. I’ll do a minimal install first, and perhaps a more full featured graphical desktop install afterwards.

Step 1: Research

From: http://en.wikipedia.org/wiki/Preboot_Execution_Environment, we learn that the process is roughly:

  • Client send DHCPDISCOVER
  • DHCP server(s) send DHCPOFFERs
  • The PXE client picks an extended DHCPOFFER
  • Something about a DHCP Proxy Server???
  • The client downloads the network bootstrap program (NBP)
  • The hard part is over… Or so he thought!

Step 2: Put it into practice

I’m going to use m0n0wall on a virtual machine within my existing Fedora installation. I have a bridge set up, so for the purposes of this article, you can imagine it’s just another machine on the LAN. m0n0wall will provide me with a DHCP server with the extended DHCPOFFER – basically a ‘next server’ attribute which tells the PXE client where to download, via TFTP, the next stage from.

I have tftpd installed as a xinetd service on my host Fedora machine. That TFTP site hosts the guts of a netinstall CD. The target machince boots SYSLINUX. I modified the boot menu to save myself typing in the path to the Fedora installation mirror.

If you, like me, are using m0n0wall, skip the DHCP specific instructions in the following documentation: Fedora Docs: PXE Boot Configuration.

My tftp directory, /var/lib/tftpboot/, looks like this:

# ls -lR
total 4
drwxr-xr-x. 3 root root 4096 Mar 15 23:24 pxelinux

total 39032
-rw-r--r--. 1 root root 34631660 Mar 15 23:24 initrd.img
-rw-r--r--. 1 root root    26460 Mar 15 22:49 pxelinux.0
drwxr-xr-x. 2 root root     4096 Mar 16 00:45 pxelinux.cfg
-rw-r--r--. 1 root root      171 Mar 15 23:13 splash.png
-rw-r--r--. 1 root root   155792 Mar 15 23:14 vesamenu.c32
-rwxr-xr-x. 1 root root  5139320 Mar 15 23:24 vmlinuz

total 4
-rw-r--r--. 1 root root 619 Mar 16 00:45 default

The default file is the only one that needed to be modified. I simply added:

repo=http://nearest.mirror.com/path/to/Fedora/20/x86_64/os/ vnc

to the append line. The vnc allows you to connect in via VNC (provided you know the IP address, which you should if you keep an eye on m0n0wall), and step through the installation remotely.

Stage 2 is just a hosted copy of the installation DVD. You can download and share this via NFS, FTP or HTTP if you’re going to do multiple installations. The exercise here is to install across the internet, so I went with my nearest HTTP mirror host.

The Fedora Docs: Configuring Installation Source page is a good reference if you are doing anything differently to me in this article.

Believe it or not, that was it! The DHCP Proxy Server never resurfaced to bite me. I think it’s only required if your DHCP server is on a different subnet to the target machine – not the case for me on this occasion.

Office Upgrade: Part 4

This post brings us right up to speed on developments with the office. We’ve so far done the following:

  1. Installed the projector
  2. Installed a new Mains Electrical Outlet
  3. Fitted a detachable ceiling rose

This next item didn’t take long at all – mostly because I decided not to mount it in any way – permanent or otherwise.

From my searches online, CPC came up trumps again with this VGA Extender. It fit the bill perfectly. I had the following requirements:

  • Must not require power
  • Should use Cat5 cable
  • Must go to at least 1024×768
  • Extend 10 meters minimum

This pair of boxes satisfied all of the above requirements. Into the shopping basket with them and await delivery…

When the set of units arrived, there was a very scant booklet acompanying them. It said that the RJ45 connectors on the Cat5 cable should be screened and connected to each other through the cable. I don’t have any cables like that, and I don’t want to buy anything I don’t have to! The booklet suggests tearing open the cable, pulling the screen out and attaching it directly to a screw terminal on the box. Ughhh..

From my previous work on the electrical wiring in the house (see parts 2 and 3 of this series), I knew that the earth would be shared on both sides of this extension via the mains. I decided to chance connecting them with a UTP cable.

Perhaps it’s because of the relatively short length of cable (6 meters or so), but it works almost perfectly fine. There are occasional glitches in the image, but I think that’s because of some electrical interference which sometimes makes itself heard through loudspeakers in the house.

Other things I wasn’t expecting were a switch on the side of the transmitting unit for mode 1 and 2, and a set of dip switches on the receiving unit. To garner more info on what exactly these switches do, I did more research. I found that the units are actually the same as this Atlona Passive VGA Extender. That site has a useful PDF Manual under the Documentation section.

All in all, I am very happy with the purchase and would recommend to all but the high-end user.

Part 5 of the series will deal with making a new screen for the projector. This is something I’ll put on hold until we have more space.

The last part of the series will, if it ever happens, concern making a new solid hardwood desk. In actual fact, this would be a series in it’s own right, so I’ll probably just link to it from here if I ever do get around to it.

Office Upgrade: Part 3

Wow! It’s now taken me twice as long to write this ‘series’ than it took to do the actual work. That’s stamina!

Following on from Part 2 of the Office Upgrade Series; Next on the agenda is a replacement of the light fitting in the office in order to prevent this pretty silhouette from becoming inextricably linked with my memory of every film watched on this setup.

Lamp Shade Silhouette

The projector is close to unusable with this humongo-shade casting a shadow the size of a solar eclipse onto the wall! Time to get rid.

Replace Light Fitting

The projector is mounted very close to the ceiling, so if I was going to have a light there at all, it would have to be flush mounted to the ceiling. This would involve taking a considerable chunk out of the ceiling plasterboard: Rented house, not an option!

The answer was to find or fabricate a new light fitting that could be detached. This would be ideal too so that, if needed, the room could be transformed back to normality.

I thought there must be loads of options out there, so I searched and searched using every combination of the keywords: ceiling, socket, detachable, screw-in, light, fitting, fixture, mount. I couldn’t find anything. I started designing my own fitting in SketchUp with intentions of sending it off to one of those prototyping (3d printing) places. I started by modeling the dimensions of a standard plug and socket pair, then I added a screw to the outside for load bearing capability – just for the cable, bulb and shade when connected.

Ceiling Plug Socket

This is as far as I got with the design. As it started to get tough, I found out that these things were called roses. A further search yielded the desired result. Behold, the clip in ceiling rose from CPC. Hallelujah.

Do It!

This was another project that’d have a small amount of !DANGER! associated with it. Another first for me in the home electrical wiring arena. Time to consult my friends at: DIYfaq.org.

I built upon the new-found knowledge with a couple of YouTube clips. Here’s just one that I took in: How to fit a ceiling light UK- Ultimate Handyman DIY tips – YouTube.

The DIY wiki above was like learning academic theory, while watching the YouTube vids somehow instilled practical confidence. Time to get to work!

Off with the light at the switch, and also off at the main circuit breaker – no risk taking here thank you!

On unscrewing the original rose, parts of the plaster collapsed, so I’m not sure that I’ll ever get it back on. Worry not. To get the new clip in rose in place I had to break more of the plaster board away to make space for the rectangular body of the fitting – now I’m sure I’ll never get the original fixture back up!

There was ample space within the cowling of the original light to completely envelope the new fixture, so I kept both of the covers on the cable. That means I will not lose anything between now and when I decide to take the new rose with me to our next home.

And volla, the new rose in situ, and below without the lamp hanging from it.

Clip In Ceiling Rose Attached

Clip In Ceiling Rose Detached

Success – and it really wasn’t all that difficult.

git for homogeneous system configuration

For some time now I’ve been wondering if it was possible to use git as a means of keeping configuration identical between servers, especially those in a cluster. Good news,, it is!

Having never used any type of version control system before, I found it took a bit of time to get used to the concepts and tools that it entailed. I’ve still got plenty more to learn. Leaving that aside, here’s a quick summary of the commands I use most commonly:

git init # Create a git repository in the current directory
git add <file> # Start tracking a file and stage it for a commit
git log # List the committed change to the repository
git status # Lists files that have changed, been deleted, are untracked, etc.
git diff # Show what has changed since the last commit
git commit -m <message> # Commit the added changes

So, now that that’s done, here’s how to use git for homogeneous system administration:

Go to the root of the filesystem.

cd /

Then initialise a git repository.

git init

You must add each file that you want to remain consistent across servers, for example:

git add /etc/httpd/conf/httpd.conf
git add /etc/my.conf
git add /etc/php.ini

Commit the changes.

git commit -m 'initial commit'

It works!

If you run git status now, it will complain about all sorts of files that are untracked. I do a blanket ignore on all files so that it doesn’t bother me with them. There is a downside to this though – you have to add files with force in future. Here’s how you do all this.

echo \* > /.gitignore
git add -f /etc/environment

The last thing to complete our setup is a way to replicate these changes to at least one other server.

What I wanted to be able to do was make changes on server A, and git push them to server B. This is not possible though; you cannot push to another working tree. The only solution I know of is to have an intermediary repository, push to it on one server and pull from it on the other. Not quite as streamlined as I was hoping for. Anyone got any answers??

Office Upgrade: Part 2

Continuing on from Part 1 of the Office Upgrade, the next item on the agenda is…

Electrical outlet near to the projector

The projector is now mounted in the wardrobe of our office. I knew I would need a power socket and a pattress to complete the job, and a junction box along the way too. This being the first time I would ever actually interfere with a domestic mains system, I thought it wise to do some homework first. I was going to have to switch off the circuit I wanted to modify – that’s easy, just a trip switch at the Consumer Unit (CU / fuse box), but I wanted to know more about earthing and the system in general. Some research: DIYWiki Electrical Topics.


With this new bouquet of knowledge, the plan was clearer. Remembering that there was a retrofitted mains outlet in the attic, I launched an investigation to see how this could be extended south to the office. As it happened, a socket in the master bedroom was supplying this attic outlet along with the house alarm system – this was clearly visible since whatever electrician did the job did not attempt to conceal his work. Was the house alarm going to pose some sort of threat to my plan? Time to test!

The labeling is not clear on our CU, so trial and error was the approach taken to identify each of the circuits. Using an extension lead, I fed power to a lamp from one of the sockets in the master bedroom. I placed the lamp where I could see it from the CU, and I switched, and switched, and switched again until the lamp went off. The control panel for the alarm system decided to chime in at this point to let me know it had lost it’s mains. Grand. Power it back up and off to the shops!


I visited the local hardware store – big shoutout to Lennehan’s at the top of Rathmines – and purchased:

  • A 4-way Junction Box (though I only needed 3-way)
  • 13A Switched Socket
  • Square pattress 16mm deep
  • Length of Mains Cable


With materials in hand, it was time to get down to action.

Drill a hole for the mains into the office

Hole in Attic Floor

This cutout was used to drill into the plasterboard ceiling below, and ultimately to pass a mains cable through.

I attempted to lift one of the sheets of chipboard flooring in the attic to expose the plasterboard ceiling of the office. This did not work – over years the chipboard had expanded and the nails were deeply embedded in them, and rusty too, so fell apart when attacked aggressively by me. Trying to be respectful to the house owners, I neatly drilled out a square of the chipboard at it’s edge, and a smaller hole through the plasterboard into the office.

There is a false ceiling in the wardrobe itself, so yet another hole was needed. Since this had to be precisely located, I drilled this from the office below. This located me close, but not directly under where the previous holes were. Oh the fun that awaited us…

With disfigured wire hangers in hand, my other half and I staked out for about an hour developing the necessary communication and motor skills to hook our two bits of hanger together. When we finally succeeded, the electrical cable was taped on for dear life and began it’s S-shaped journey through the cavities of our abode. Perhaps it’s just bad memory, but I think we had to do everything twice because we failed at one point or another the first time. When completed, we did walk away very satisfied!

Install the Pattress

With the cable now hanging down into the office, next up was preparing the patress. I attempted to drill a hole in the top of it, but a portion of the top instead smashed off – don’t know what I would do differently: perhaps go slower, more gently, try another bit, use my since-acquired table drill… In any case, the smash was not a disaster, it would be closed off from the world, butted up against the false ceiling of the wardrobe.

Placing the cable through the gap, I slid the patress up to the top and it fit snugly enough. I pre-drilled pilot holes in the back wall of the wardrobe through the partess’ own holes, and screwed it on tightly. Done.

Wire the Outlet

Is there much to say here? This was a very standard affair. Once wired, I slid it up to meet the patress while feeding the cable back up into the false ceiling.

Joining it all up

The objective was getting ever closer. I cut the power using the circuit breaker. Tested with a phase tester to ensure I wasn’t going to kill myself, and proceeded to cut the cable running from the junction box installed by the electrician some years before to the house alarm. (I had measured this fairly accurately in the planning phase)

Junction Box Installed

Junction Box wired and fixed on to a rafter in the attic.

I wanted to reroute the cable for tidiness sake behind a gigantic skylight tunnel. I finished with a mail of cobweb, but happy. There was just enough length to mount the junction box where I wanted without setting up an attic full of trip-wire booby-traps.

Finally, I stripped the wires back, secured them in the junction box and fixed the whole thing to a rafter. Done. Time to test.


Flicked the trip switch back on, and how chuffed was I when I saw the lamp I had plugged into the newly installed socket light up? Very bloody happy! It felt like an enormous achievement at the time. We were now able to put a laptop in the wardrobe and watch a movie on our own big screen without unsightly cables drooping out in search of a power source.

Mains Socket in Wardrobe

Socket with patress at the top of the wardrobe in our office. Mains cable exits the top of the patress straight into the false ceiling above.

The project would have been a complete triumph if it hadn’t been for our house alarm going off 3 nights later at 4:30 a.m. It transpires that the unit already had a bad battery, and my slow work during the induced power cut set us on a collision course for a rude awakening. It was deafening!

Next: Office Upgrade Part 3: Replace Light Fitting