Saturday 6 December 2014

Xmas lights 2014

Well it's that time again when we all try to out do each other with flashy outdoor xmas lights. This being the first xmas in our new home I had to rethink how to put them up, and of course the wiring.
I'm still looking out for the best wire to use, I keep hoping to find thin green twin core wire, but alas I never find it to buy (appears all xmas light manufacturers know where to buy it!) so for now I'll stick to good old cat5 as it's not bad for the job, just the light grey colour isn't ideal as it's not noticeable.
The lights are my little xmas trees with lights in them, and a mini pir at their base. The idea being, feed power to the pir, take its output back to my Arduino and then control power to the lights on each tree.
The basic code is from my previous blog posts, and appears to work however I think somewhere between the rain last year, the house move and the pir being very cheap Chinese imports have decided to fair, or at least 3 out of 5 are now returning 2v on their signal line constantly instead of pulsing the 5v when motion is detected.
Tomorrow's task is to check them for short circuit, test their boards and try to fix them.
For now they're running my Arduino sequence.

Next jobs, use my multiplexer to provide more outputs from the Arduino and control even more mini trees and also maybe the other hanging lights strung around the windows and door

Monday 16 June 2014

Problems with DHT11 Moisture sensor

I've recently been playing around with the DHT11 1-wire temperature and moisture sensor for my Arduino, and you may have seen my posts on and my old blog.

Now as an update, the DHT11 has burnt out! I was starting to get fewer and fewer readings, getting a checksum and then timeout error from the arduino code I was using. Eventually I never got any returned values, so decided to take a look. After checking all the cable runs, etc, I then added the pull-up resistor that was recommended in some locations. But unfortunately still nothing. So I decided to prise open the little blue plastic package, and the problem was quite clear:

If you look, in the lower left corner of the small coil (?) you can see the burnt parts which seemed to have made contact with the lower circuit board (where the spare leg was) and caused this burnt look. I'm not sure how or why this happened though.
My best guess is a large amount of moisture gathered, condensed and the water droplet caused the short to take place and kill the sensor.

So I've now got a replacement DHT11 and trying to work out how to safeguard the next one against damage and how to better sense the moisture in the dryer without destroying the sensor too!

Saturday 7 June 2014

Arduino Leonardo with ENC28J60

This is a very quick post, it's mainly to act as reference for me in the future!
When connecting an Arduino Leonardo up to the ENC28J60 cheapo ethernet adapter things are a little more complicated than with the other Arduino's

I've used them before with the Uno and it's straight forward. PIN conections are:

// PIN Connections (Using Arduino UNO):
//   VCC -   3.3V
//   GND -    GND
//   SCK - Pin 13
//   SO  - Pin 12
//   SI  - Pin 11
//   CS  - Pin  8

However, when you get to the Leonardo things are a little different, as the Leondardo has the ICSP header which you need to use for this connection.
The ICSP connections are:
//   MISO  VDD (+5v)
//   SCK   MOSI
//   RST   GND

So the connections are:

Pin Connections (Using Arduino Leonardo):
//   VCC -   3.3V
//   GND -    GND
//   SCK - SCK
//   SO  - MISO
//   SI  - MOSI
//   CS  - Pin  10

Then to init the library pass it the pin 10 like this:
ether.begin(sizeof Ethernet::buffer, mymac,10)

And it works! Hopefully this will help you out if you're trying to do the same, otherwise it's just handy for my ageing memory ;-)

Friday 6 June 2014

New Blog

Hello and welcome to my new blog. I'm moving from my old geeklog blogging to this, mainly because others use it and I like the format and ease of not having to maintain it. One such feed is who is always entertaining and good to read up on the challenges of running a DSL/ISP these days and hits upon many issues and frustrations I do too through $job

I'll hopefully import all my older blogs into this soon, but bear with me.

Tuesday 27 May 2014

DIY clamp-meter current flow indicator

 This is a brief one. After my clothes dryer arduino sensor, I quickly realised I wanted to determine when my dryer was powered on. I didn't want to modify the dryer itself, so started to look as passively sensing when the dryer was turned on. To do this I looked at the clamp-meter method of determining current flow. (I use this for my electricity consumption for the entire house, but using a commercial product).

Checking various websites I found that this was something that could be made with some success, so I started to look for the relevant parts. I had spare copper wire, a spare caribena and set about it. The result was this:

As you can see I had to use a couple of different wires that I joined. But the basic principle remains. I could hook this around one of the two feeds to the dryer (Only live or neutral, round both cause a cancellation effect) and then read the millivolts induced by the crude 'transformer' I have made.

However, no luck. I re-wrapped this several times, tried different methods and different ways of connecting it up and no matter what I tried I never got any output on my multi-meter.

So here it is. What have I done wrong, or how could I improve my design to make this work?


Clothes Dryer arduino moisture alert

 So, since moving house we've had to relocate our clothes dryer to the garage. This being slightly inconvenient I keep forgetting to check when it has finished drying clothes which ends up either leaving them ages and having to put the dryer back on to help get damp back out of the clothes, or having trips every 20 mins to the garage to check on it. Either way, I'm lazy and wanted technology to solve my problems.

Searching the web, I found a few people doing smart things with dryers, based around the premise that when clothes become dry, they stop emitting moisture (pretty obvious) and so if you can monitor the operation of the dryer and the moisture still present you can estimate when the clothes are dry and either shut off the machine or advise that it's time to take the clothes out. The general principle is to put a moisture sensor in the vent/output of the dryer to see how much moisture is being emitted. Less moisture, then clothes dryer. You can then build up a reasonable threshold for when the clothes are dry by observing the values and testing.

The plan is to use a spare Arduino Uno I have, plug its usb into the server already in the garage and take readings off this. When a pre-determined threshold is reached it can then alert me by some means (Not sure what yet, tweet, email, sms, bluetooth alert, whatever!). So onto the sensor. Checking around you can get moisture sensors pretty cheap, so I went for the DHT11 moisture/temperature 1-wire sensor (not the usual 1-wire protocol, but well documented and there is an Arduino library for it).

 The sensor itself is around 5-10cm in size, so easily hidden and has 4 terminals along the base. These are for +vcc data (unused) and -vcc

These can be bought on ebay from UK sellers for under £2 which is a bargain I'd say! So I got one ordered to play around and test. So next step, link it up to the arduino and load the library, see what happens. Here it is connected up to my Arduino Uno for testing.

So far so good, running a simple sketch I could retrieve the moisture value (in %) and temperature (in oC) so I was getting together something I could use.

By soldering a long cable onto the sensor and wrapping it a little in electricians tape I then needed to tackle the dryer itself and identify how to make this work. My dryer is a Hotpoint self-ventilating dryer (avoids the external hose requirement) as it uses a condensing technique to convert the moisture-rich hot-air back into water (which then collects in a tub to empty).

So, I didn't want to modify the dryer in any way (I'd get into trouble off the mrs!) so I then looked at how to sense whats in the drum. The following image shows the layout with the door open:

Here you can see the main filter which fits into the dryer drum in the middle. This is all snug-fitting plastic, so no option here really, plus the sensor would end up getting clogged with dryer lint. However, following the internal plastic duct it comes out at the bottom, if you look at the middle+bottom you can see the cut-out that then feeds into the condenser fittings and into the water collector. This seemed like a good place, it was relatively lint-free and would take the hot air coming out. This seemed like a good spot, and it fits when closed using rubber+felt fittings, so I could fit the cable in quite easily.

I therefore put together the sensor onto a long wire and duct-taped it inside the duct (Yep, duct-tape actually being used in a duct).

After the initial test, the humidity rose rapidly with a full load of wet clothes and as the dryer kicked in it heated up. Initially this looked good, temperature going up and then I found a rapid drop in humidity, checking this did indicate that the clothes were reaching the optimum dryness, so it looks like it works. I waited longer to let the temperature level off and then the moisture dropped rapidly showing completion of cycle.

(The dryer isn't smart, it doesn't have a moisture sensor and will continue to run on its timer, so I think this may also let me help save energy by shutting it off early, but that will be a future change)

Unfortunately, I didn't keep a graph of this test, so I cannot show the simple correlation I did. However, something odd I noticed. Afterwards the graphing continued (I use the excellent Munin for graphing as it is so easy to write plugins) and I saw the humidity jump up and then remain at around 95%. This seemed odd, and I did a few things to see if it was a fault, but now I suspect that when the dryer is idle, and not heated its at quite a low temperature, and residual water in the dryers mechanics must stay there and keep moisture high. This also makes me worry about the dryer itself, as it cannot be healthy for it idle at high moisture, but again that is something to worry about another time.

The final design seems to work, and I'm going to continue doing some more test runs before setting up a threshold monitor and alerting part of this. The graph below is from the days after the test and shows the very high humidity. If you can think of a better explanation than mine I gave above, please feel free to add to comments and put me right!

As you can see the temperature remains around the same, but humidity sits up at 95% almost constantly (I'm going to assume the drops in humidity are graphing/serial errors and can be ignored. I should really write that into my code!)


I'll try and get another capture of when the dryer is being used to illustrate the correct graphing values that I captured.

You'll also noticed I added an "On" to the graph. The idea is that this will indicate when the dryer power is applied. This is proving tricky. I looked at and made my own caribena induction power monitor to hook around the mains cable and measure when power was flowing (Poor mans clamp meter), as my thinking is that this beast takes around 1kW of power, so its significant and I should be able to see even a tiny voltage showing on my home-made pickup coil. But alas I've failed miserable and I'll address that in another article. So for the moment I'm still working out how to monitor when the dryer power is applied (I still want to avoid intrusively digging into the dryers control panel/inners, especially as it would also probably involve an opto-isolator or something else wired into the 220v mains on the dryer which I like to avoid where possible)

 Also, code for the arduino sketch is at github:


-- Additional --

I've had a little longer now to look at the code/stats, and have determined that when the dryer isn't being used I should ignore any values, as the moisture values often sit at 95% which I assume is just from the dryer having residual moisture. I'm also building up a decent picture of when clothes are dry. Take a look at this graph from today when the dryer was used 3 times:


As you can see on the graph, when the dryer is on (the green ON isn't working correctly, so it's not showing all 3 switch on times) the moisture goes down as temperature goes up. And the final drying cycle you can see the moisture drops rapidly slowly followed by temperature going up. Therefore this looks like a good set of threshold values to monitor. I suspect having a condition such as:

if temperature > 45 && moisture < 50 then clothes are dry


-- Addendum--

Thanks to everyone visiting from !


Monday 12 May 2014

Fetchmail IMAP multiple folders and IDLE

 This is more as a reminder for myself than anything the mass public may find useful, but here goes!

I use fetchmail to keep a remote server updated with email from the host system. So I use fetchmail for this, run it in daemon mode and have a config like this:


 set daemon 300 set syslog poll protocol IMAP username password mypassword is me@localhost no rewrite keep smtphost localhost 

Pretty simple so far! So I then wanted to pull down the "Junk" folder from the remote server, as I realised mails were getting missed as they got stuck there and I never checked there wasn't something I wanted in there. So I checked and fetchmail has the option to provide multiple folders, in the man pages, web pages, etc, it specified you add 'folder' followed by a comma separated list of the folders you wish to poll. Great, so I tested it, added 'folder inbox' and it identified it was only fetching specific folder 'inbox' I then changed it to 'folder inbox, inbox.junk'

And it failed. It retrieved the first folder, and then stopped. Checking all over I couldn't work it out, man pages appeared correct, in the right section. I tried various different ways of represending it. With quotations, without, spaces, no spaces, multiple lines, etc. And none worked, it always stopped after the first one. I then found a very obsure statement in an online document:

"The ‘idle’ option is intended to be used with IMAP servers..... It also doesn’t work with multiple folders; only the first folder will ever be polled."

Ah, and as I use IDLE the code is obviously just hitting the first folder and stopping (Probably because the code for fetchmail isn't multi-threaded or very smart, it just hits the first thing it finds and sits waiting there on IDLE). So to fix it I set "no idle" in my config, and it works now! (OK, It's a trade-off/performance hit, but I'll have to live with that I guess)


Monday 7 April 2014

Powerline Ethernet

 Hello once again, sorry for not posting more regularly, as usual I have quite a few projects I should/could post, so will start with this one.

After moving house recently the new battle to 'tech-up' the house took place. I had various goals and needs to fulfil fairly quickly after moving. The first and primary being, how to get the TV systems working again. As many of you will know I use XBMC and TVHeadend on all TV sets, so each TV needs network access to be able to access the TV systems we use (DVB-T and DVB-S over ethernet). In the old house, I had managed to pipe network cables around from the garage pretty well, as I had a duct up into the loft-space from the garage and could then reach all of the rooms I needed.

However, our new house having a 3rd floor stopped all of this, no loft space that could access each bedroom, no easy link between garage and the rest of the house (The garage was not separate from the house, but there were no obvious ducts/cable runs, etc, between the two, only a power socket). My first thought was WIFI (I've not had much luck with HD over WIFI, but it might work!), so setup my wifi router in the garage (where the servers, TVHeadend live, etc) and started to see what the signal was like. Bad news, the house was built with good thermal insulation (read - tin foil) and so signal was next to non-existant even beside the wall where the WIFI router was setup, so looks like that was out. I then started to think how to cable at least one location and run everything from there, naturally I didn't really want this as did not want to start modifying a brand new house! So I turned to powerline ethernet. Not something I'd used before, but had played about with it at work as a trial, and it seemed pretty good.

I did some reasearch on Powerline Ethernet (Or Homeplug as its sometimes called) and found there are lots of different manufacturers licensed to it, but they all use the same standards pretty much so seem compatible with one another. I looked up the different speeds, and types. My theory being, the higher the stated throughput of the units, the higher chance of it working at HD video that I needed (I'd guestimated up to 30Mb). I found the TP-Link products and that they were on various deals at the moment.

I settled on the TP-Link PA411KIT AV500 which are the 500Mbps twin pack, for around £35 from argos, which is a bargain really for the potential these things had. A few initial observations though, just to be wary before you rush out to buy them!

They are quite stylish, in a white/grey casing and pretty small too (around the size of a regular wall-wart). They have one button on them for security/pairing, 3 LED's (power, powerlinethernet, ethernet) and an RJ45. Here was the first odd thing, its was a 10/100 network port. But the adapters are supposed to do 500Mbps, so why only a 10/100 not giga? After reading, the 500Mbps is as usual a bit misleading, they mean total, so 250Mbps is actual throughput (when in full duplex), but even so, we're still not at 10/100. But then there is the loss of the whole system, generally this can drop you down quite a bit.

My initial testing was very good. One in the garage plugged into my server/switch. One in the living room (Do not plug them into multi-ways, or adapters as it does affect them. I managed with a 2/3-way direct wall plugged splitter for power. If you have to, just make sure it doesn't have surge filters, etc, as those degrade the signal terribly). Doing that I was getting great results, TV streamed fine, as did HD content and all as fast as I needed. So I went out and bought another pair, plugged these into the TV's upstairs in two bedrooms. Again, these worked great, streaming TV was no issue, internet was fine, etc. So I went out again and bought another 2! (These things act almost like a small switched network, very neat). Now depending on what you read maximum is either 6 or 8, so I should be fine. Plugged them in and all did appear fine.

For a few days....

Then it started slowing down, I was having problems with HD content, it just stuttered after a few seconds (basically filling the xbmc buffer and emptying it again). I was also starting to get occasional stutters from SD content, network traffic was slow, etc. So really not good news. I was worried. Was the technology just not that good?

Troubleshooting involved unplugging all the homeplug adapters, so I just had one in the garage and one in the living room. No difference. I updated their firmware, and setup the network to be on my own named instance (By default you pair them and they use their own 'network name' and security), and ensured they were all set the same. Using the TP-Link windows utility it also showed the throughput available to each device, which worried me. They started to show 11Mbps to a few adapters. Depending on which one I plugged into it showed different ones with 11Mbps. So that made me think, what has changed, something has degraded the powerlines and caused this to happen.

I started to read up on the technology, to see what affects it. Seemingly everything! Just going between different phases or breakers in the fuse box can degrade it (Yep, mine was on different breakers). Different floors of the house as they tend to each have their own ring-main (Yep, mine on different floors). Long distances (Possible, I'm not sure what the length of cables, etc, around the house were, so unsure if sockets were say at the start of the ring or the end). Other interference (Yep, I use X10 and setup an X10 house alarm system, which I know uses powerline technology for their control signals).

So I was starting to worry, had these only worked when we moved in, since nothing else in the house was connected at that time. Next stop, I read that many devices cause interference. Biggest culprit, those cheap mobile phone chargers, computer PSUs, Laptop PSUs, basically anything that was a switch-mode power supply.

My next step of testing was to start switching things off and testing. So I began again with just the two TP-Link adapters plugged in, living room and garage. Loaded up an HD video and sat watching it jump and stutter. I then went round and unplugged all of the mobile phone chargers (wow, we have loads of them, at least 2-3 per person in our house!). Still no different, video stuttering. I then unplugged one laptop, no difference. Then my laptop, and it stopped. The HD video suddenly jumped back to life and ran. I let it run for a good 10 minutes and without stutter. Switched my laptop charger back on, almost the second I did, stutters came back. Aha! This was it. Plugged all the other stuff back in (except my laptop) and it was fine. So looks like that was the problem. Thinking back, this was a replacement PSU for my laptop, and was a cheapo copy, not manufacturer, so that would explain it! Cheap and nasty electronics in there caused it. So now I wanted to fix it, so I could use my laptop. I grabbed a surge protected multiway, and tried with that on a different wall socket, and hey presto that worked! So I still have my laptop, and my powerline ethernet works great!

I hope this maybe helps another individual who wants to use this and has interference problems, etc.

I have to say, I'm a big fan of these units, they are impressive units and do a very good job. At some point I'll run some speed tests and see what I can actually get out of them now, but for now they're streaming my HD tv great.