About this site

This is my little site on the web, it is part blog and part traditional website. The blog posts can be found down below here, using the tag cloud to the right or the search box up above.The majority of the non blog style pages are relating to my main hobby of flying model aircraft, you can find these using the list of pages over on the right, or the menu bar tabs up above. The main homepage for model related stuff can be found here.I occassionally Geocache, a map of found caches can be found here. A few other bits can be found from the menu bar above too.

Using a Raspberry Pi to control Maplin power sockets

remote-controlled-mains-socket-set-singleFor a while now I’ve been intrigued by the idea of home automation, but despite a large amount of research I’ve yet to take the plunge and buy anything. The one thing I do have is a bunch of these Maplin remote control sockets. These are simple things which just plug into any wall socket, then have a socket which you can plug any device into, a simple RF remote offers 8 buttons, on and off for each of the four sockets. The remote lets you choose from one of four channels meaning you can have four sets of four remotes all working within range of one another. I bought these originally because we had a few power sockets in awkward to reach places – who wants to move the sofa every time you want to turn a light on? – but never considered the possibility of using a computer to  control them.

That was however, until I spotted a intriguing sounding tweet from Andy Swan directed at Andy Stanford-Clark:

Oh really Mr. Swan, now this does sound very interesting. I asked for some details and Chris pointed me at this blog post which explains pretty much everything I needed to know. The post linked to this library from Duncan McGregor which did the hard work and linked to the source of the transmitter I would need. Sorted then, this sounded simple enough!

10534-01aI bought one of the transmitters and a ribbon cable with a plug that fitted the GPIO connector of the Pi. I planned to snip all but three cables from the ribbon, shorten the remaining ones and solder these to the 3 pins on the TX, the hope was with a very short wire from the GPIO plug to the TX I’d be able to hide it inside my existing case. The pin out of the GPIO and the connections you need to make are listed on Duncan GitHub repo in the Readme. But in short it goes like this:

 

 

 

Tx PinRaspberry Pi Header Pin
Pin 1 GNDPin 6 0V (Ground)
Pin 2 Data inPin 11 GPIO 0
Pin 3 VccPin 2 5.0 VDC Power
Pin 4 ANT173mm antenna wire (not on the Pi!)

Once I’d soldered the connections, I plugged the ribbon cable onto the GPIO and booted the Pi. One quick clone of Duncans repo later and I ran the following:

sudo ./strogonanoff_sender.py --channel 1 --button 2 --gpio 0 on

And hey presto my fish tank light turned on. *minor celebration* :)

I wanted to try and avoid sudo access, but reading a few, things, decided that sudo was probably safest! So be it.

I’m pretty terrible at remembering that the fish tank lights are channel 1, button 2 so I wrote a short python script which accepts room names and a simple on or off:

It essentially just uses a Python dictionary to store the room to channel and button mapping:

switches = {
'bookshelf': { 'channel' : 4, 'button' : 1 },
'tank':      { 'channel' : 4, 'button' : 2 },
'sofa':      { 'channel' : 4, 'button' : 3 },
'outside':   { 'channel' : 4, 'button' : 4 },
'spareroom': { 'channel' : 3, 'button' : 1 },
'all' :      True
}

I’ve put this script ‘switch.py’ into a repo in my Github account here. You run it like this:

./switch.py -s tank -a on

The success of all this lead me to consider actually building a remote control for these things that I could use on my phone, partly because it sounded like a neat thing to do and partly because finding the remote when the kids have been using it is non-trivial.  The added, actually useful feature would be to turn lights off remotely when I go out and forget to turn them off.

So I pondered for a bit and sketched out a plan for a simple HTML UI running on a web server, somehow talking to the Pi to do the work.   I didn’t want to expose the Pi to the internet because I already have a Linux box with a public IP and apache running on it and didn’t want two entry points into the house.  I just needed a way of getting a command from a client browser, via the other linux box and onto the Pi.  Then it dawned on me, I already use Mosquitto, the open source MQTT broker for moving temperature readings around, I could just use that.  A bit more hacking lead me to write maplin-mqtt.py which is a variation of switch.py and simply subscribes to the MQTT broker and listens for messages containing commands.

I wrote it to expect JSON messages in the following format:

{ "channel": 3,"button": 2,"action": "off"}

Testing this is as simple as using the command line MQTT publish client:

% mosquitto_pub -h trin -t foo/bar -m '{"action": "off", "switch": "spareroom"}'

So now I just had to write a simple web UI which could publish messages of the correct format. I’ll write about that at another time because I hit upon something which changed my plans slightly :)

Sea Rover aka Nualas Boat

I’ve put a gallery of pics of the rebuild up on the Sea Rover page in preparation for writing up the work. IMG_1246

Updates

I’ve hauled the S-Pou out of the loft and intend to start flying it again at our clubs indoor evenings. Hence I’ve moved its page out of Historic and into the RC Aircraft section and updated it accordingly.

I’ve also added the following new kits to the Lego page:

Hopefully I’ll update the blog more often in 2015, I’ve written quite a lot of code recently, and done some cool things with my Raspberry Pi. I must also try and write up the renovation of the Sea Rover!

Fortigate Firewall Logstash Grok filter

I’ve been playing with Logstash recently, just this week I was asked to import a Fortigate firewall log. I did this by putting up a logstash syslog interface on a specific port, tagging the inbound traffic as type=fortigate and then using a simple RE and the kv{} filter to parse the log.

The gist can be seen here, or embedded below:

Mini Tyro electric conversion

Airframe finishedSo I’ve made some progress on my electrification of the Mini Tyro. After a bit of maths and some guess work I ordered a D2822/14 1450kv outrunner and a Turnigy 18A Plush. The plan is to try a APC 8×4 and a 7×45 prop on it to see what power it draws.

I made a start by removing the Mills from its mount and cutting a hatch into the wood above the tank. Then the tank was removed and the tank bay floor cut away. The next step was to remove the old firewall because it was too far back to mount the motor on, I could have used standoffs but that would have left a rather small bay behind it for the battery. A new firewall was cut and installed about 3/4″ further forward than the old one. This gives a sensible clearance between the front of the fuselage sides and the rear of the prop but also has some room for adjusting the right/down thrust

D2822-141450(1)As it happens the battery needs to live under the wing, but the space previously occupied by the tank is a perfect home for the ESC, with the Receiver living just behind it, slightly in front of the wing.

The battery has quite a lot of room to move around under the wing so it will need some sort of restraint, some velcro is likely.  The front end needs tidying somewhat, the covering is looking tatty and I’ve yet to make a cover for the tank, now ESC bay.

Having said that, I’ve weighed it and run it up and all seems fine.

TR-P18AWeights

Complete airframe minus battery is 259g

The 3S 500mAh battery is 47g

The 3S 850 mAh battery is 67g

 Power

Using a 3s and the 7×4.5 prop it pulled 5.9A /  57W WOT. Giving roughly 79.3 W/lb which is probably about right for the little Tyro. I expect the 8×4 might give a good bit more and maybe even too much. We’ll see!

I’ve yet to test the 8×4 because it needs reaming out to fit the prop adapter.

 

I’ll post some pictures when its finished, although the temptation to fly it as it is now is quite large!

 

 

Multiplex Merlin

Multiplex MerlinBetter late than never! I’ve added some information to the Merlin page here. Which is slightly ironic given I am no longer flying it! But I felt I ought to add something as part of a general spring clean of the blog!

Edge 540qq

img_8724The venerable old Edge is still being thrown about quite a lot. I’m trying to practice aerobatics with it rather than just chucking the sticks into the corners. Minor updates to its page here,  it survived a pretty big ‘landing’ recently. It is back in the air but isn’t quite as nice to fly as it once was, still loads of fun though!