Friday 16 May 2014

Remote AC Control

So I guess I hacked Scotty’s account… or he just gave me access because he’s a top bloke. Either way I decided I better make good use of his blog space and post something constructive.

I thought I’d start with a couple of simple projects I completed. Today I’ll delve into my Air Conditioner Controller. Sometime next week I’ll show off my Arduino powered GPS Speedometer that won me $50 bucks from Jaycar.

So this little project came about over summer. We were getting some very hot days and I have a ten year old swampy on the roof of my house (an evaporative cooler). One of the multitude of problems with coolers like this is that the take ages to actually start bringing the temperature down. So after a long hot day away from home it takes a good thirty to forty minutes to bring the temperature down to something reasonable.  I can’t leave the thing going as a swampy requires the windows and doors to be open otherwise you end up with condensation over everything after two or three hours and a timer means I’m on some kind of time limit to get home. Bugger that.

So remote access it needs to be. If I’m at my parents in law, it’s a forty-minute trip, enough time to bring down the room temperature.

I already have a server running at home which I have remote access to, so getting into the home network isn’t an issue. What I need is a robot arm to push a button that I can control over the home network. I contemplated the idea of an Arduino with an Ethernet shield running some form of a relay in lieu of the robot arm, however after having a look at the bastardised versions of SSH on Arduino, it just didn’t float my boat. I needed something that had GPIO outputs, could run SSH and probably Python and preferably supported WiFi. Raspberry Pi!

A Raspberry Pi running Raspbian (Debian) was perfect. SSH in built, Python with a GPIO library and of course GPIO outputs – as well as WiFi support. I needed to do a couple of things though, not only do I need to be able to turn the thing off and on, I need to know what state it’s in. After starring at the AC control pad for a minute I realised something obvious, there’s a lovely power LED on the front of the unit. I had a spare Light Dependent Resistor (LDR) lying around and some other components – if I could get some baseline readings it could tell me if it’s on or off.

I did some shopping on eBay an found myself a 5 Volt relay. I also picked up a spare Arduino development shield, I like these as they have a common ground and positive rail, which makes building an LDR circuit (amongst others) nice and easy. It’s a fairly simple circuit, LDR, resistor and a capacitor while using a GPIO pin on the rPi to get the reading.

After ripping the AC controller off the wall I found the solder points for the physical switch, subsequently I soldered a couple of short wires to it and inserted the LDR into the case behind the power LED.

I found some Python code online (I’ve only just started playing around in Python), which had been used for opening and closing a garage door, I cleaned it up a little and managed to get my relay working quite nicely.

The only major issue I found was actually in my LDR Python code. When the LED was off it was taking a large amount of time to return the values (as it was completely dark in the enclosure). A simple exception handler worked here, it functioned on the basis that if no response was received form the LDR in ‘X’ seconds it reported the unit as off – it also displayed how it got its response. I did this as in the instance that the system was on it received a reading in less than half a second or so.

So here's the command line output:



I have SSH apps on all my portable devices, which means I can now turn my AC on or off as well as check its status no matter where I am in the world.

Overall I was really happy with this project, I managed to get it together for less than $100 and on the odd occasion when I feel like playing with a Raspbian interface I log in and enable VNC and screen share from my AC controller to my lappy. I should mention that the case does have a clear cover, it’s just hard to get photos with it on!

Finally, the finished project, mounted on the wall (the one visible black cable is the power cable):



Saturday 10 May 2014

Mini 7-Segment Clock (times two)

I follow quite a few electronics type blogs now, they're a great way to learn new things and see what other people are making.  One particular blog that I've been following for quite some time is Kevin Rye.  If you haven't checked out his blog before go get a coke and sit down and have a read.

He announced last month that he was selling a limited run of kits of the latest version of his Mini 7-Segment Clock - so I ordered two.  Not only are the clocks awesome, but it would be a great chance to do some more SMD work, I get to burn a bootloader to an ATMega and program it with the FTDI usb-serial adapter I recently got.

They arrived this week and I sat down this afternoon to put them together.  I just followed along the blog post and assembled them both in that order:





I made up the cable to burn the boot loader using my Arduino Uno and then used my FTDI adapter to upload the sketch:


One worked first go, the second one had the same segment of each digit in the display that didn't work.  Thanks to the Eagle files for the clock if was a very quick process to fix.  I first checked the resistor which was fine, so then checking the pin on the ATMega showing it was at fault.  A touch up with the iron and the second clock was working 100%.

I then changed the sketch to display 24 hour time instead of 12 hour time  - a personal preference.  With them both working completely it was time to look at powering them.  I had 2 very cheap knock-off Apple lightning cables ($3 each) that both failed (I note if you buy the kits now they come with a USB power cable).  So I cut them up and used them, and put them both in their cases:


Pretty stoked with them - and I throughly enjoyed the process of putting them together.   Now I just have to work out where I want to put them...

Sunday 4 May 2014

Raspberry Pi Radio

I like listening to music while I work.  I stream a lot of music over the internet from places like SomaFM and Pandora.  I wanted something though that would play music for me while I work that was independent of my MacBook Pro.  Seemed like a good way to go was a Raspberry Pi with the Adafruit LCD.

I love the stuff from Adafruit.  It's always great quality and has very clear instructions and in most cases tutorials on how you might like to use some of the bits.  So I ordered my LCD kit (and some other bits) and waited.

Once the bits arrived it was a very straight forward matter of following the instructions to put the LCD shield together:



Pretty simple.  Once I confirmed the LCD worked as expected I moved onto the Adafruit pi wifi radio tutorial.

This by and large worked - there were just two small pieces I had to change to make this work 100% for me.  The first was that the current pianobar package available through the RPi repositories is sufficiently old that it suffers from this bug.  This is not the TLS fingerprint issue - but a separate one.

So I removed the apt installed version and downloaded and compiled pianobar from source.  Worked first go without issue.

So I moved onto adding the few lines that run Adafruits python at startup - and it only work some times.  After a little debugging it turns out sometimes my wireless connection on my RPi wasn't quite ready and so things were timing out which it why it only worked on startup sometimes - but worked 100% if I ssh'd in and started it manually.

To fix this all I did was add a sleep statement (for 5 seconds) to the startup commands and now it works first time every time!

Overall (not counting the time for the LCD to arrive) this whole thing is very straight forward and start to finish shouldn't take more than an hour or so to complete, but i'm still pretty stoked.

Nixie Clock!

I've wanted a nixie clock for a long time.  A good mate and I talked about doing it over 10 years ago now - and he ordered some IN14 nix...