A lack of time, not a lack of motivation

Posted on

Unfortunately since my last update I have done very little with everything. Life does get in the way, but I am still very interested in learning more, which is something. I did however purchase a proximity sensor and got it up and running with my spark.io which is quite cool,  I did think about having that at the end of my hallway to turn on the philips hue when it detects movement. I will post the code and whatnot later on.

Another day, another pi

Posted on Updated on

So my second raspberry pi has stopped working, and this time I don’t think I am at fault. The symptoms were just a single red light with no ok green light or anything else. HDMI out did not work and it was just…. dead. Reading online, the red light with nothing else indicates that it is not reading the SD card, so I tried another without success. I confirmed that the SD card was fine so through excellent deductive reasoning it must be the Pi. Oh well, time to purchase my 3rd Pi.

I also decided to do some soldering. I bought a pi cobbler a while back, it essentially allows you to connect your raspberry pi gpio ports to a breadboard for easy working. I was quite impressed with the overall result

pi cobbler soldering

In slightly related news, I signed up for a couple of courses from coursera.com they are free online courses which I decided to give a go.The courses I went for were fundamentals of electrical engineering and Programming Mobile Applications for Android Handheld Systems and both of them started this week. It then transpired that the level of mathmatics you actually required for electrical engineering was far above my head, while I could understand small parts this is not very encouraging when you are in the first week. So I dropped that course, intending to take it at a later date and have signed up to Calculus One instead. Hopefully that will give me what I require.

As for the android course, I thought it would be good to learn something which could help me program and might have some greater use later on.

I will have another update shortly showing a motion detector that I bought and connected up to my arduino and spark core. Exciting times!


Brief Update part 2 – Spark.io and wifi plug

Posted on

Having built the relay I have not done anything with it yet, mainly out of apprehension that I am going to blow myself up with 230volts. Despite that I will press on with the question ‘how can I remotely control the relay?’

Enter spark.io which is essentially a wifi enabled microcontroller based on the arduino language (which is just a subset of c++)

I received my spark core last night, in a very fancy box with loads of extra goodies to play with. Quite a nice haul all in all!

spark core on a breadboard
spark core on a breadboard
spark core with all the stuff I received
spark core with all the stuff I received

The spark core is controlled from the internet, it has an online area for programming and flashing the unit so once you have connected it to your wireless network it is ready to go.

First things first, make a little blue LED on pin D7 flash.

int LED = D7; //initialise an integer called LED and assign it D7

void setup() { //this is the initialisation routine
    pinMode(LED, OUTPUT); //set up pin D7 as an output
 Serial.begin(9600);//this enables the device to appear on a connected computer

void loop() { //this method loops around forever
    digitalWrite(LED, HIGH); //set the LED high i.e. on
    delay(100); //wait 100 milliseconds
    digitalWrite(LED, LOW); //set the LED low, i.e. off
    delay(1000); //delay for 1 second

With this spark I could connect the relay and wire it in which I could then get my phone to send a command to trigger the relay and that will enable the plug

The second item I bought is a wifi enabled plug. Ingeniously called wifi plug I have not received this yet but there is an API available that should also allow me to achieve the same goal.

Now I am not a programmer by any means. I want to understand everything so that is something I must get into. Frankly pointers and all that in C has been a bit of a mystery but hopefully with time and effort I will get there.

Now the next steps really are to wire up more than just a single LED to the device, but I am not sure where.

I also signed up for an intro to electronics course at coursea it is a free course which hopefully will give me some further insights.

Now I just need to have some time to do all of this!

A minor victory with electronics

Posted on

Quick update. Four things I have learnt this evening

1) Never solder unless you are absolutely sure
2) Measure more than twice before you commit
3) Even if you measure, it doesnt mean it will actually fit
4) I am not very good with DIY

item 1 on my list is to do with electronics, items 2,3, and 4 are to do with some DIY I just attempted, and while it came out ‘okay’ it is not fantastic

Nevertheless I have had a minor victory with the electronics side so I am happy.

Thinking about home automation, originally I had planned to use z-wave devices, which is a wireless protocol which is baked into a fair few devices. The advantages are that you don’t really need in-depth electronics knowledge, just a bit of programming and you are done. The disadvantage is that because home automation is not popular with the masses, it is expensive.

I decided therefore to try and put my electronics stuff that I am learning to some use before I commit fully to z-wave devices.

A relay in electronics term is a bit like an electronic switch, but rather than completing one circuit, you are actually completing two separate circuits. It is difficult to explain, but imagine you have a simple battery connected to an LED, once that circuit is complete it will light the LED (assuming you have a resistor to not blow it up). Now imagine there is another circuit with a light dependent resistor on it which is waiting for a light source. Once the LED of the first circuit is on, the resistor on the second one drops its resistance and the second circuit is completed. That is essentially what a relay is (well it is exactly one type of solid state relay), except most of the time it is mechanical.

Because of this it is possible to control a 230v circuit, i.e. a lamp at home with a simple 5v arduino board.

I purchased this relay from proto-pic to see firstly if I could actually solder anything without burning myself or totally messing it up and secondly if I could actually control my lamps at home using either my arduino or raspberry pi.

I spent the best part of an hour soldering all the components on the board, and while it was difficult as the resistors and everything are so small I actually managed to solder everything correctly. Well everything except the LED. If I have not stated this before, the short leg of the LED goes to ground.

Proof that I got it to work

relay connected to the arduino
relay connected to the arduino

now the first time round, the LED didnt work. But the advantage of the giant relay in the middle is that you can tell if a connection has been made because you hear an audible click where the mechanical switch has clicked in on the 230v side.

I simply (hah!) de-soldered the LED and put it round the right way, and the results are what you see.

On the 5v side there are three inputs, corresponding to the 3 terminals of the transistor on the board. There is the positive 5v, the ground (which is negative) and the control. The control is what you use to determine whether the circuit is open (off) or closed (on). By having the control set to on, you are allowing the transistor to get over the resistance of the chemical inside and have an electron flow. Without that additional push, the 5v is not sufficient to bridge it. That is what I think happens anyway (I think it is an NPN transistor).

In the above picture, I simply had a wire going from control to the 5v so that the circuit was always on and I didnt have to program anything. On the arduino side I had one wire going from the 5v to the aforementioned 5v and control on the relay board, and then on the ground I had it going to one of the GND ports on the arduino.

That is as far as I have managed to get this evening. When I am feeling brave enough to deal with 230volts I might take it one step further. But one thing I have to also do, is make either the raspberry pi or the arduino take an input from the network to trigger the relay and somehow not blow myself up in the process! Fortunately I have something on order that should help with that🙂

Brief update – tasker, lampshade.io and hue

Posted on Updated on

It has been a while since I posted, almost 2 months. Insert usual excuses here, been busy, been on holiday, etc.etc. I have not been that complacent however with looking at various home automation bits.

I ended up blowing 2 power supplies for my raspberry pi. I have an LED string (more information on this later) which was being powered by a 2A 5v power supply along with my raspberry pi but it transpires that I was drawing too much current. With 50 LEDs at a maximum of 60milliamps each that is a whole 3amps just for the LEDs! No wonder I blew up the supplies as I was drawing far too much current. I then purchased http://www.ebay.co.uk/itm/330958739671 which is a 50watt (so 10amp) 5v powre supply for them. So far so good, nothing has blown yet. Although I wont leave home with them turned on.

In other news I set up a tasker profile on my android phone. Tasker is an amazing app for android which allows you to trigger events based on conditions occurring. The equivalent for iphone is IFTTT (if this then that).

At the moment I have two profiles which are of use,

1) Turn on the hue lights when I get home. I might have gone over this before but I will expand on this. For this you require ssid selector as well as lampshade.io

Profile > State > wifi near > the ssid of your wireless network
Task >
SSID selector > the ssid of your wireless network
Tasker > Wait 999 miliseconds (this is because it takes a while to authenticate on your network, it is not instantaneous!)
Plugin > lampshade > configuration > all @ 100%

This then sets the bulbs on. I am going to alter this when I get the hue via the website working to be a gps location as it takes a while for the bulbs to actually come on whereas I would like them to come on when I am approaching home.

2) Flash the bulbs when a phone call is incoming
Profile > Event : Phone Ringing
Task >
Plugin > Lampshade > Group: All, Mood: Red Alert
Wait > 7 seconds
Lampshade > Group: All, Mood: Relax @ 100%

In lampshade.io I have two moods, red alert is an flashing red light, and relax which is just a calm one for the lamps to go back to. It would be nice to go back to the previous state they were in, which I might do at some point as it would require reading from the bulbs their current state and then going back which I think is beyond the current ability of lampshade.io to set via tasker.

Electronics wise I have not done much however, although I am planning to look at a relay with the arduino/pi later on in the week. A relay is essentially a switch for another circuit. Basicaully you can have a 5v DC circuit control a larger 230v AC circuit depending on whether it is on or off. My plan is to use the arduino to control whether my sidelamps are on or not.

I also plan to use Eagle to show some schematics of the stuff I am making.

Pi in Technicolor (TM)

Posted on

If like me you are a masochist, then vi or vim is the best text editor to use on linux. There are zillions of commands and I know roughly 3, but to make life easier when coding you can get vi/vim to show up text in lovely colours.


To do this run 

 sudo apt-get install vim 

then edit .vimrc in your home directory (either /root/.vimrc or /home/pi/.vimrc or whatever really) and put in it

 syntax on 





Vi and Vim in colour
Vi and Vim in colour

Frying the Pi Part 2

Posted on

So it transpires that I have blown the polyfuse on my old Revision 1 Raspberry Pi, although the potential difference (read voltage) across the fuse F3 is only around 0.3 volts there is no voltage going to the rest of the board (0.1 volts minimum needed is about 4.6) and the power LED comes on very dimly to begin with and then goes out. As soon as I short the fuse the power LED comes on.

So the revision 1 now can become a proper testbed, just need a soldering kit to play around with it!

The siblings
The siblings

So there is the revision 2 I purchased with 512megabytes of RAM and the Raspberry NoIR camera that I purchased but never got around to putting on. I also bought a new case for the second one off of amazon. Bit fiddly but I quite like the clear perspex and it is easier to do stuff with it.

To get the camera working I follow the tutorial on the official website

As root is disabled by default, if you want to run in the context of the administrator, you use sudo.

Either you can do

 sudo -i 

This puts you into a root style shell where you can run the commands

or you can do

 sudo apt-get upgrade 

This would run only this command in the context of root

because I am lazy, I always use sudo -i

Anyway to take a picture, just do

raspistill -o filename.jpg

it takes a few seconds to take, but the quality seems reasonable

Baldy heed
Baldy heed

There is my lovely face (read: urgh) taken with the camera. The colours are a little off as there is no infrared filter on the camera. I am hoping to create a lizard cam with my leopard gecko who is nocturnal so this would be a good way to use some infrared LEDs to catch what the Missus does late at night.