2011-07-22

Using GMail as a relay with Postfix

I fiddled a bit with this, so I thought I'd do a no-nonsense guide to doing this. There are other guides, but a lot of them are incomplete and will leave you with queueing issues or annoyances.

The science bit:

Edit /etc/postfix/main.cf:

smtp_use_tls = yes
smtp_sasl_auth_enable=yes
smtp_sasl_password_maps=hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options=noanonymous
smtp_sasl_tls_security_options=noanonymous

# Send all mail through smtp.gmail.com
relayhost = smtp.gmail.com


# Stop getting a catpcha, hopefully.
smtp_destination_rate_delay = 60
relay_destination_rate_delay = 60

Now, edit /etc/postfix/sasl_passwd:

smtp.gmail.com myemail@gmail.com:MyPaSsWoRd

It doesn't have to be an @gmail account, it can be a GAFYD account, once you've logged into it once to activate it.

Then just generate the map file for the sasl_passwd file and reload. As root:

postmap sasl_passwd
postix reload

And you're done. Monitor your queue a few times over the first few days to make sure stupid stuff hasn't happened (the delay between mails might get tweaked), but in general this has worked for me.

Have fun.


2011-05-26

Alive and Thinkin'

I am alive. Apologies to folks who were following the electronics stuff -- the short version is that it worked, although I didn't get to use it 'in anger' as such. The other thing I learned is that when traveling through UK customs on the week of a royal wedding, having a small plastic box with wires coming out of it and a 9v battery strapped to it with tape is not a clever thing to have in your car (thankfully the customs official had a sense of humour).

Since then I've been doing a bunch of for-money work, and only took time out this week to relax. I occasionally take a week off to hang around at home and get 'life administrivia' done. Think of it as a concrete block on the see-saw of work-life balance.

I've been playing around a bit with generalised messaging for domotics updates. I'm thinking of a centralised controller that can accept events from various signals, such as the Current Cost meter, a wifi device coming in range, or a small IC hanging off the doorbell circuit, for example. A lot of these devices don't have particularly fully-functional network stacks, so I'll have to bite the bullet and get the handful of ZigBee radios I got recently working. Doorbell will be the fun one, I think. My house already has a (private) twitter account, and DMs me for various stuff (unknown hosts grabbing a DHCP lease on the network, etc.). Adding more stuff to this is the idea.

I'm also interested in the idea of cloud applications with local storage or local encryption keys -- so all your data is stored encrypted on the server side, and only you have the keys, so the content is decrypted at render-time. Stuff like 1password does this with secure stuff like password databases, but I think web browsing machines are zippy enough to do this for userdata. I have to see if it's been done already (it probably has), but I want to do some fiddling with it.

So yes, same old. Too much science to do, never enough time.

2011-04-16

My Eyes!

I've not had a lot of time to go at electronics in the past while (mainly a combination of work things and family things kicking my ass), but I got to some of it tonight -- The clever parts of the design and build are basically done, so what's left is producing the final piece.

Aside from the motion sensor parts, there's also the bright light, to mess with people's night vision. For this, I got 4 super-bright LEDs, and did monstrous things with solder to produce a 5x2 header, that was fully connected along the long side. This gave me the 4 LEDs connected in parallell. This is pretty bright with the 5v applied from the analog output of the Arduino:



The final result will be built on an Arduno Fio board, which only has a 3.3v signal (It's powered off a 3.7v LiPo battery), so I'll need to amplify that somehow. I'm thinking I might try to power the board and LEDs off a regular 9V instead, or have the LiPo powering the board and the 9V powering the buzzer and leds, gated on the signal line of the board with some transistors. I may be of course talking out my ass. I'm going to pick up some various transistors over the weekend and experimenting. My guess is the gate and emitter of a transistor need a common ground, which won't work with using separate power sources. We'll see.

Of course, deadlines, help. I'm supposed to be using this thing next saturday. So, full steam ahead.

2011-04-03

Finding Day


One year ago today, a very small ball of fur decided to mew outside our front door in particular. We let her in and looked after her for a bit, and eventually decided she could stay.

We're not sure exactly how old she is, we're guessing se was about 6-7 months when she came to us, but I guess her finding day is as good a day as any to be happy she's around.

Happy finding day, Ping.


2011-03-25

I Seeeeee Youuuuu

So, first steps. I picked up a few PIR Motion sensors. These are a specific kind, there are a few other kinds, but they should have datasheets. You might recognise the bulbous white shape of them from those motion-sensing light switches. They're about a fiver each and fun to play with.

The comments section on Sparkfun had a very good tutorial on basic use, but also explains the basic principles of its operation. It has 3 pins -- DC, Ground and Alarm.

Science Bit

The alarm pin is what's called an Open Collector, which means it's either connected to ground, or to 'nothing'. To better understand this, let's assume you don't know what a transistor is (I know I sure didn't a few weeks ago).

Speaking simplistically, a transistor is a component where you can vary one voltage based on a much smaller voltage. In this way you can amplify a voltage pretty easily.

Here's a diagram!


Usually transistors are tiny and embedded or are tiny and on a breadboard, but let's assume for a moment that it's a box with 3 wires coming out of it. They're called collector, emitter and base. Emitter is always connected to ground, and provides the reference voltage, or definition of 'zero'. Base is a small voltage in relation to ground, and the voltage applied to the base controls how much voltage is allowed flow between the emitter and the collector. The difference between the voltage on the base, and the voltage allowed through the collector is called the 'gain'.

However! The voltage on the collector doesn't come from nowhere. It has to be supplied, and the voltage 'allowed' to flow is defined by the voltage on the base. So, if you apply 3.3v to the base, and 9v to the collector (the voltage marked 'Vcc' on the diagram there), you get a certain voltage that's actually 'allowed' through the transistor, and can be used in other applications by connecting them before the resistor (At 'Vout' on the diagram).

The zig-zaggy thing there on the diagram is a resistor. We put it across the larger Vcc voltage to lower it a bit, since transistors are usually only rated to take a certain voltage. The function of Vcc and the resistor is to 'pull up' the voltage across the emitter and collector. This is why the resistor there is often called a 'pull-up resistor'.

Transistors are handy for switches when you want to control a large voltage using a small voltage. They're also useful if you want to take a tiny voltage you get from a signal somewhere and amplify it.

Anyway, why this is relevant is that an 'Open Collector' is the collector from a transistor that's available as a signal. However, instead of usual 'binary' signals that might produce a 'True' voltage or a 'False' lack of voltage, it's either connected to ground, or not. Whether or not it is connected to ground depends on the base voltage. My guess is that the PIR sensor circuitry provides the 'base' voltage and lets us use any Vcc voltage we want, in order to 'pull up' the output.

So, if you go look at the circuit diagram and build instructions in the tutorial mentioned above, it works just so. The one modification I made here is that as well as pulling up the voltage, instead of connecting back to the LED on the Arduino board, I connected up to a big old Piezo Buzzer I got in Maplin.

The finished build looked like this:


So, the end result is that when you wave your hand in front of the PIR, the buzzer makes an annoying noise. Success!

Next up would be making things a bit smaller -- There are smaller, cheaper Arduino boards you can get, and I'll do a build soon that's a little easier to get into a project box and lug around with you.

2011-03-20

Aaaand..sleep.

I've been back from the states for a week or so now, and really have been meaning to get back to the electronics stuff. However, jetlag jetlagged me, and oncall oncalled me. I have played a bit with the PIR motion sensors I got, and with XBee, which I have to summon the mental wherewithal to write up and document.

Hoping to get back to it this week, in between the million other things happening, both work and non-work. The slowly spreading damp patch coming from the cieling of one of the rooms of my house would be #1 right now :-)

2011-03-10

Step 2: The Plan

Okay, I was talking last about my idea(s) for an electronics project, and I think I have enough of it thought about to sketch it out. I'll also point out where I got some of the specific parts for the project itself, in case you want to follow along at home (please don't, I don't know what I'm doing).



Those who are familiar with my escapades will know I'm into Airsoft, which is kind of like a bunch of grown men playing army with pellet guns. I've got a reasonable amount of kit, and have travelled quite a bit to various events and venues both Irish and abroad.

One of the venues I've been to a good few times is Sennybridge FIBUA Village in Wales. It's a Ministry of Defence training village that the British army uses to take pasty-faced youths and turn them into wet pasty-faced youths who want to go home. On a few weekends in the year, though, they open it up to pasty-faced middle-aged escapists to play 24-hour overnight Airsoft games. I've been to five of these so far, and I've another one coming up in April.

So, to the idea. One of the features of the game, of course, is being a sneaky git. It's the sort of game where World War I tactics of running line abreast at the enemy is unlikely to work. Sennybridge is comprised mainly of 2-3 storey buildings, which usually have between 1 and 3 entries. Usually you and a squad of 8 guys will take and hold the building until told otherwise. Sometimes this'll be at night, and you have to keep an eye open for people trying to take the building from you.



What would be nice is to be able to find out if someone's being a sneaky git and is sneaking up on you. So, something like a motion detection alert you can drop or conceal that'll let you know if it's time to watch those stairs.

Motion detection sensors are pretty easily obtainable, for less than a tenner. Sparkfun have one, and I'm sure there are other, possibly cheaper suppliers. After that it's about deciding what you do when you detect motion. So, I've ordered what I plan to do, in order of complexity (i.e. in order of likelihood to actually get done).

  1. Audible/Visible Motion Detector


  2. Pretty simple, really. If it detects motion, it makes an audible sound. You could also possibly switch it to 'night mode' where it makes a sound (so the person who set it off looks in that direction), and then it flashes a blinding white light, to screw up their night vision. I've picked up a X5 White LED PCB in Fry's that might do the job, if I can get enough power to it. Maplin also had a decent-sized buzzer, which you could make buzz with a couple of 555 timers. I like this idea because it could end up potentially costing less than 20 quid in parts, and I could make a few of them. It may not even require an Arduino (I know it doesn't strictly require an Arduino, but it may not require an Arduino even for an electronics leper like me).

    Incidentally, a great primer on 555 timers is in the Make: Electronics book, which I just read through on the train. They're tiny, cheap as chips (ho ho) and can be very powerful if applied correctly.

  3. Remote Motion Sensor


  4. A lot more complex, but potentially more effective. The sensor itself doesn't need to make a sound (although I could leave the flash in, since it has an effect). The sensor could alert me wirelessly and silently to it being tripped. I looked into a few options for this, including good old 802.11, but XBee seems to be interesting, and I've picked up a few XBee RF modems. Sparkfun and SK Pang have them, as well as Radionics.

    The sensor part could be quite similar to in Idea 1, except with a small antenna. I've also picked up some wearable LilyPad Arduino kit for the part attached to me. This can be powered from a couple of AAs or a small 3.7v LiPo (although probably AAs. I'm trying to limit my exposure to having lithium fires break out in my pockets). The alert could be audible, or could be via the LilyPad buzzer in a glove. So, someone sneaks into the building downstairs, and the back of my hand buzzes.



There are a few more ideas that came out of these, but this is the basic idea. Idea 1 is looking more likely, since I'm actually more likely to make it, the components are a lot cheaper (I'm entirely prepared for one or two of these to get stepped on, nicked or lost) and it's more likely to actually work reliably.

I've already done some exploratory work on XBee and motion detection, which I'll cover next. I've picked up a few PIR Motion Sensors and will document the fiddling next.

2011-03-07

And All the Hills are Rainbows

Various intricacies of how my job works these days means I work with people in a bunch of offices. They're not all in the states, but Mountain View and Irvine are two offices in California I do go to occasionally. When I was planning a trip to both late last year, I said I'd look at alternatives to flying for an hour (SFO->SNA). After doing some digging, I found the Coast Starlight, which is an Amtrak train that goes from Seattle to Los Angeles, and stops in Oakland and San Jose. It so happens Oakland is a short BART ride from SFO, so I said I'd give it a go.



I honestly am ambivalent about the TSA, and being groped and what-have-you. I realise there's no point in getting angry in Airports, because the people there are just trying to make a living. I'm also ambivalent about saving on flying (the plane goes whether I'm on it or not). I just like trains, and this one promised 12 hours or so of good geography and comfort. I got myself a 'roomette', which is apparently what you're allowed call a small cupboard with a seat in it, and it turned out to cost about $130, which is cheaper than some air fares SFO->SNA.

It also doesn't help that SNA is referred to in muttered tones as 'Disneyland Airport'. It's right beside Anaheim and the home of The Mouse, so it's usually packed with kids. The look on a co-worker's face when they called for people-who-need-extra-time-or-have-small-children, and half the airport marched onto the plane will stay with me always.



The train itself is good and comfy. Tea, coffee, juice on each sleeper carriage, and a bar and observation carriage which is decent for hanging out, and "has" "wi-fi" (said wi-fi could well have been using the train driver's 3G phone as an uplink, and meets the minimum federal requirement to be called 'wi-fi'). The food is/was reasonably decent, and some of the views are very pleasant.



12 hours is a bit of a hike, so it's not recommended if you have actual places to go, but it's miles more pleasant than the solid 4 hours or so of wangling door-to-door it'd take to fly, and also trains kick ass.

I'm in LA for the night, and continuing by train to Irvine tomorrow, where I will again endure the hilarity of having to rent a car to cross the road from my hotel to the office. Go California!

2011-03-02

Electronics Schwag (The Specifics)

A commenter asked me for more specifics on stuff to get when getting started with electronics, so since I've learned a little since then, here's my uninformed opinion.

Soldering Iron



Get a good one. I got a reasonably crap Draper one from Amazon, which was 25W. It's fine, but takes a while to heat up and can be a little while melting the solder, which is annoying when you're holding everything just-so and it's all perfect except the hot bit isn't hot enough. If I were doing this again I'd get a 40w one, and one with adjustable heat.

A lot of the soldering tutorials I've seen use a pointed tip on the soldering iron. I've found the chisel tip a lot easier. I can touch the tip against a solder point and heat the wire and contact a lot easier than using a pointed tip (which you don't use the point of anyway). I'd recommend you try both to see what works.

Solder



Lots of the online tutorials say "Don't use silver solder or lead-free solder, it's a pain in the ass to use". Well, thanks to RoHs, lead solder is at least very hard (if not impossible) to get in Europe. This crackpot here has a website talking about it, but you're probably wasting your time looking for lead solder in Ireland. I found it easy enough to solder with lead-free, but then again I've no frame of reference. I just picked up some 60/40 and 63/37 lead solder here in the bay area, so we'll see once I'm back.

People make a big deal about lead-free solder not being less dangerous than lead solder. All I know is that if you're burning a solid metal-looking object and smoke comes out, breathing it in is probably bad for you. Little pro tip there.

Wire Strippers



See this here, right?

stripper.jpg


Load of shite. Avoid like the plague. I wasn't able to adjust mine to strip the wire I got, and it just chomped ineffectually and was big and annoying.

Okay, now see this?

wire_stripper.jpg


Bog standard wire stripper, costs a fiver or less, is in pretty much every electronics set ever. That is because it's the only wire stripper you'll ever need. Some wire stripper inventor guy is using money to insulate his attic because of these babies, because they're great. Get one.

Wires



After talking about wire strippers, of course, I should let you know that stripping the ends off wires is for suckers. I picked up a Jump Wire Kit in Maplin in town, which has a bunch of varying lengths of wire, especially for breadboarding and the like. I also recommend this set of jumper wires from SK Pang, which are even neater (and cheaper!). For the first while you're probably not going to be soldering wires in place, so the jump wires are grand.

Breadboards



Breadboards are boards full of holes you stick wires into. If you're getting one, make sure to get one with a power rail going along each side, which are much nicer. It should look something like this:

halfbb.jpg


Get two or three so you don't have to dismantle something you're doing to re-use the breadboard.

Arduino Stuff and Components



The main Arduino stuff you want to pick up, barring any particular project in mind, is one or two (they're small and cheap) boards, the USB cable you need to talk to them, and some breadboards for fiddling around.

The board you want to get is the Uno, and you may want to avoid the SMD edition if you can. For a lot of stuff, it won't matter, but the main difference is you can't remove the microcontroller chip from the SMD version. There are reasons you may want to do this, which I'll cover in a later post. The SMD version was mainly produced due to a worldwide shortage of the Atmega328 chip in the larger removable form factor, so you're more than likely getting the non-SMD, but it probably doesn't make a difference. The SMD version apparently has other improvements for meganerds who want to fiddle with the firmware on the board.

This is the normal version with the microcontroller chip in a socket on the board:

uno.jpg


This is the SMD version, notice the tiny surface-mount chip. Same chip, different form factor. Notice the 6 extra pins near the USB port. Apparently you can do science with them:

unosmd.jpg


You might also look into getting 'shields' for the board, which are basically other boards that plug into the Uno. They're good for prototyping, but can be bigger than what you want when you want to shrink things down. You can get them for stuff like ethernet, XBee (mesh networking), and other kinds of wired or wireless comms.

I recommend getting one of the starter kits, the one from Adafruit is good, comes with everything you need. I also recommend getting a Proto Shield, which is a good starter soldering project. The Adafruit starter kit comes with one, and SparkFun do a different one that does roughly the same thing. While you're getting stuff, have a look around SK Pang, AdaFruit and SparkFun to see what they've got, there are a bunch of ready-made projects and widgets that'll give you ideas for projects. Personally, I picked up some LilyPad stuff for the project I dreamed up (details coming soon) and an RFID reader chip and breakout board for fiddling with RFID.

For more specialised stuff, there are smaller boards you can get, which end up cheaper than the Uno. The Pro Mini and FIO end up a fiver or so cheaper per board, and can be good if you have specific things in mind (I picked up a pair of FIOs, since they have an XBee socket onboard).

As components go, Maplin do 'lucky bags' of the likes of resistors, capacitors, etc. If you know exactly what you want, Radionics have a large catalogue and do next-day courier delivery in Dublin for a fiver.

Next Up



Next up I'll be talking about the project I've been thinking about, and the bits I've been gradually accumulating for it. I'll also show you the first few photos I have of my own tinkerings with RFID reading.

2011-02-28

Not bad, as Castles go

Myself and Favourite Lady took the weekend off to head to Dromoland (warning: terrible website will make all your orifices bleed rage). It was nice to get out to that part of the country again. Roomservice breakfast while reading the sunday papers is one of the best things ever.

We also had the opportunity to visit Bunratty Castle, which I'd last visited as a tiny nipper when my dad used to bring school tours there. We saw some chickens begging for scones.



Then we saw some of the old biscuits known to man. Shows how the old Kimberley/Mikado/Coconut Cream combination has stood the test.



Today, I'm flying off to the Bay area for a few weeks to issue barked instructions to nerds. I have a few posts lined up about the electronics stuff I'm doing, but they can be spread out over the next few weeks so I can resume when I get back. Inventing is interesting.

(I'm writing this from the Delta Sky Club in JFK, which gets a solid meh out of ten. The normal-person waiting area has iPads).

2011-02-19

Step One: Schwag

[Man, the editor in Blogger is terrible. I may move this if I start using it more.]

So Arduino, and electronics in general. To give some background, I seriously could not electronics my way out of a wet paper bag. I know what a resistor is, and Ohm's law. I know that a capacitor is the big metal cylinder you don't touch, and that soldering is a pain in the hole. That's about it.

I'll attempt to speak in English about this stuff, basically.

Kit

Step one to getting yourself set up with a new hobby is, of course, buying a load of expensive kit. Happily, a lot of this kit is not expensive at all. I'll list the basics I got, and where you can get them. This is pretty Ireland or UK-specific, since that's where I live.

Firstly, you're getting into a word of hurt when it comes to organising stuff. Electronics stuff is small, and there's lots of different bits. Get set up with some sort of system for organising stuff. I got some various-sized bins from Safety Direct (I got one of these sets). That's still pretty coarse, I'll probably end up getting a fiddly-little-bits organiser, too, but I've yet to find one.




I got my soldering iron, stand, desoldering pump, multimeter &c from Amazon UK. There's more and more of their stuff that ships to Ireland, which beats the hell out of a lot of hardware places. All these are pretty much essential. I also got one of those green craft mats with the grid on it, which are supposed to be useful, bit I think it just makes the cheap IKEA desk look like a workbench. Stay offa my "work" "Bench", cat.

I got solder, some various bits of wire, and a Helping Hand (that funny clampy dude with the magnifying glass for a head, who is also essential especially if you're blind like me) in Maplin in Dublin. Don't go near Peats, they're now quite useless when it comes to electronics stuff.

I got the component bits from:

- AdaFruit, who also have an excellent getting started tutorial on their site with lots of 'what to get' lists if you're in the states. I only got one or two things I couldn't get anywhere else from here, since shipping to here takes more than a week, and you'll almost definitely get stung for customs, plus six quid for An Post and a postman trying to have a fight with you (but that's another story).
- SKPang look to be top notch from my experience, have mae 4 or 5 orders so far and they usually ship same day and get to Dublin within 2.
- Radionics are a little spendy, but their range is fantastic. They also deliver next day in Dublin for 4 quid, which is nice if you get all excited about some parts you want. They have some Ardiono stuff, and have XBee modules in stock for less than you'll pay SK Pang.

I've also gotten some bits and bobs off Maplin UK, who do 'component lucky bags' in case you've always wanted to have a big bag of random potentiometers. Potentiometers are those guys with the twiddle on them.

Larnin's

I've watched a bunch of youtube videos (here is a good channel with random stuff on it, some useful, some not). I've also read a few online things. Basically I found out what a resistor, capacitor, voltage regulator, diode, and a few other friends do basically. I also remembered there's a unit called the 'henry', which I last heard about while listening to Therapy? down the back of physics class sometime in 1995, using that super-elite trick of putting a headphone in your sleeve and leaning on your hand.

I also read LadyAda's Arduino tutorial, which is a good start. I didn't actually go through any of the exercises, but reading through them is a good way of getting familiar with the basic concepts.

I noted last time that I didn't have a good project Idea. Well, now I do. I've to look more into it, but will fill you all in next time.

2011-02-17

Legbone connected to my Wristwatch

I've been fiddling about with small electronics recently, specifically the Arduino, which is a microcontroller/prototyping board. The boards have gotten way cheap (standard ones are around 20-30 quid, less if you want fewer I/O ports or a specialised board layout you need to solder bits onto.

The hard part, I've found, is thinking of things to make. In the meantime I'm practicing soldering, using projects like making a few ProtoShields, and the LOLShield.

Last night, I made a functional RFID reader, using less than 50 euro worth of parts, which for a long-time hardware luddite was extremely fulfilling. I even managed to solder without burning myself or others.


I've got one or two projects in mind, mainly around wireless sensors and domotics, which I'll put up here (hey, I have to put something here, right?).