Archive

Posts Tagged ‘ambient light’

Improved Google mail number of unread emails script

January 27th, 2010 Ed No comments

Since writing “Get number of unread posts from google mail”, I realised that I didn’t care about a lot of emails that I get on a regular basis, things like ebuyer emails, stock-market alerts etc. I only want to be notified when I’ve got emails from real people.

By applying a “Newsletters” label on GMail to all automated messages by filtering messages, I can now see how many unread emails I have, then subtract the number of unread newsletters I have, and flash the ambient light that number of times.

Grab getGoogleMail.sh, change the usernames and passwords, and change “Newsletters” to whatever your google label is. Then use the $count variable to do whatever you want.

Categories: Web Tags: , , , , ,

Scout racing lights – naturally arduino powered!

November 16th, 2009 Ed No comments

Inspired by techcobweb’s SlotCarDuino, the night before our scout group’s “Pinewood Derby” (cars made by the kids from a block of wood race down a track, powered by gravity), I decided to make a traffic-light system, and an indicator to say which car one (as there’s sometimes a debate)!

So, in between power cuts (6 days on the trot of less than 8hrs of power per day), with only a few hours of awake time before the event, I dismantled my home automation system (no loss, given there’s barely any power for the heating) and connected up the breadboard, ambient lights and a couple of wires that will act as trip wires.  As there are no pull-down resistors, and I have absolutely no components, the trip-wire is connected to ground and then digital pin 3.  Running digitalWrite(3, HIGH); enables the pull-up resistor, so whenever the circuit is complete (i.e. car hasn’t driven through the wire) it reads 0.

The way I made the trip-wire was to stick one wire over the track, and rest it in a small uninsulated loop of wire.  A quick trip to the scout hut proved this worked, although was in serious need of some debouncing as the vibrations on the track caused the wire to jump around a little.

Simple but reasonable effective race switch

The main loop of the code is very simple, it reads the two trip wire readings, and if one changes it increments a winning counter.  If that counter is more than 7000 (fairly random number that seems to work), it turns that lane’s ambient light green.  After that happens, when the next trip wire is broken, the appropriate light goes red.

I stole the one component I did have, a switch, from the B&Q ambient light, and wired that up in a similar way to the trip wires.  At the start of the loop, it checks this value to see if it has changed (the button is a normal switch, not a temporary push-button), and if it has changed (after some debouncing), it resets some variables, checks the trip-wires have been reconnected (and if not, flash the appropriate light), then runs the red-amber-green starting sequence.

The kids seemed to like it, and other than the odd dodgy connection, and a particularly streamlined car going under the wire, it worked perfectly!!

Next year will be a little more high-tech as I’ll change the trip-wires to some kind of optical sensor, and possibly have one at the start of the race so we can display track times, speeds etc.  May even make an automatic releaser, we shall see…

Categories: Arduino Tags: , , ,

Ambient Light and Arduino boxed up and ready to rumble

November 12th, 2009 Ed 2 comments

One bitsbox order and a trip to buy some deodorant later, and my arduino is boxed up, and ambient light has a stand!

The cap off an addidas deoderant can makes a nice enough base for the orb from a B&Q disco lamp (no link as can’t find it online).  I soldered the ends of some CAT5 to the BlinkM, and left the other ends loose to be shoved into the arduino.

As I’ve got an arduino and ethernet shield, I went for the second largest ABS box and even then, I had to break off the screw connectors on one side so that the plugs could stick through the outside.  I soldered the AM receiver and transmitter onto a small piece of stripboard (also from bitsbox), added a couple of wires for aerials (with a knot in each to prevent someone pulling it out the circuit).  So that’s pretty much the finished product, what a shame!  I will add a thermometer to it so it can become a thermostat in another room – eventually this’ll go in the sitting room, so will have the current cost meter producing one temperature reading from the kitchen, this one in the sitting room, and have just ordered another arduino for my bedroom’s ambient light/thermometer/development board.

The java code has been working nicely, turning the heating on and off via the hacked home-easy plug!  I sent a text from my phone to turn the heating on, very proud of actually finding a use for it as I was stuck in traffic but had friends coming round so the heating would have cut out at 5.30 (it heats up til 5.30, then waits for movement) – only to find there was a street power cut that has lasted 3 days (intermittently)!  So, if the power holds up a little longer, I should get a tweet tomorrow telling me how long the central heating was on for, fingers crossed!

So, time to write the web interface, pretty dull :(

Get number of unread posts from google mail

November 1st, 2009 Ed No comments

Here’s a simple bash script that gets the number of unread messages, and runs a command that does something with that. In my case, a java program that puts a message on a MQTT topic, which indirectly flashes an ambient light.

#!/bin/bash
while (true)
do

rm atom
rm atom_process

wget https://gmail.google.com/gmail/feed/atom --user=XXXXX --password=XXXXX 2&>1  /dev/null

cat atom | grep fullcount > atom_process
count=`sed -n -e 's/.*>\(.*\)<.*/\1/p' atom_process`

java -jar /home/ed/rrd/MQTTRunner.jar mpc_google 3 $count
sleep 60

done

Categories: Web Tags: ,

Graphing Current Cost

October 29th, 2009 Ed No comments

I bought a current cost and Viglen MPC-L (15W low powered computer running Ubuntu) last year, and have since been recording power and temperature.

Power consumption

Temperatures

Adapted from Jibble, I have been recording data in “RRD”, a round-robin database in a single file.  Initially, I didn’t have a computer on 24×7, so added some cheap and tacky code to pull the historical data from the current cost meter and log that.  A couple of weeks after buying the current cost, I realised I couldn’t live without live readings, so bought the Viglen MPC-L.

View code.

Part of that code runs “colours.pl” with the current power consumption, which sends a message to the arduino telling it to change the ambient light’s colour to a colour that depends on how much power the house is eating up. More about that shortly.

BlinkM Arrived

October 27th, 2009 Ed No comments

BlinkM, 6xAA power-pack container arrived from oomlout (arrived next day, despite being in the middle of postal strikes), along with a free RGB LED – seem like a good place to buy from.

Downloaded the examples and got it working within a few mins.  Slight gotcha was that after I told it to change colour, it changed, then did something else.  Turned out that  a sequence was still running, so I now stop the sequences in the setup() method with BlinkM_stopScript( blinkm_addr );

Categories: Arduino Tags: , ,