Friday 27 November 2015

Inside another DC-to-DC 12v to 5v adapter

Thursday 26 November 2015

Inside a cheap car 12v to 5v USB adapter

Monday 16 November 2015

New Video: Inside a cheap chinese LED E15 lightbulb

I've posted a new video to +YouTube "Inside a cheap chinese LED E15 lightbulb"

Sunday 15 November 2015

Dashcam/Reversing camera to Chrysler Grand Voyager - part 2

Briefly to complete my installation of the dashcam/reversing camera to my Chrysler Grand Voyager, I wanted to connect up the 12v 'sense' wires that are attached to the rear camera. These will then switch the screen on and set it to reverse mode (the reversing camera full screen), so I set about trying to connect these up.
The exterior light cluster on the GV comes out quite easily, two clips and the whole assembly pops out, and again the lights pop out from a clip, I can then see the wiring harness disappear into the chassis, typically further back than I'd hoped, so not within easy reach to any of the edges of the plastic boot covers.
So I set about taking the majority of the left-hand plastic covers off. This is additionally difficult as it has the boot opener/closer motor fitted to the chassis, so the plastic covers wouldn't come off completely as I'd need to disconnect the boot motor, which I didn't want to attempt.
So initially you have to take the boot tray/sill off, which is shown below. Just prise it up from one side as it has metal pop-clips on it, and comes off quite easily.

Then, unscrew the two retaining clips (These are what I assume support a boot cover if you have one too, they are crosshead screws inside), then start to prise off the side plastic panel:

These pop open from the back, and you have to slightly lift when doing that as they sit down onto retaining clips. This is quite tricky, as there are so many parts to this piece of plastic. It's a one-piece that goes from the base of the boot, up around the boot motor, round into the car and contains the rear window motor assembly and also the rear speakers, so quite a large piece of plastic with many shapes and fasteners.
I found that this was about as far as I could get, so could just move the plastic around and bend it slightly, just enough to get inside to route the wires and figure out whats going on.

I then discovered several odd things. The first was that a control box had been mounted inside the bodywork, and had a whole heap of wires coming out of it. Then, I noticed one of the wires from the main car wiring loom had been cut, extended and then joined into this black control box. The extension wire you can just see on the photo below, it's the red closest on the picture.

This had been black-taped at the joins, which always makes me think after-market fitting/work, basically because that's something I'd have done! After continuing with the job in hand, I started to test and trace for the cable connected to reverse lights, and found it's white with a light-green stripe. Sure enough, this is the wire that had been cut and extended as shown in the above photo, so now I know what this box was (probably), reversing sensors.

I'd always assumed the reversing sensors on my GV were factory fit, the sensors certainly looked it, and the module was sensibly fitted (It's a small black round circle with about 3 or 4 LEDs from green to red), but perhaps not! So anyway, this meant I could take another branch off this wire and use it for my reverse sense wire.

Wiring that in, the system worked great, when I select reverse the camera switches over and displays on the rear view mirror.

Saturday 7 November 2015

Fitting and wiring a dashcam to my Chrysler Grand Voyager

A few tips and guides from when I fitted a dashcam to my Chrysler Grand Voyager. The dashcam I decided on was a cheap chinese import, It's a Buyee HD 1080p 4.3" Dual lens Mirror dashcam.
Below is the product information from ebay (It was around £30 which seemed a cheap enough price to play around with!)

The idea is you clip the unit over your existing rear view mirror. Normally (when it's screen is off, which is most of the time) the unit is reflective so it acts like a normal mirror. The mirror finish is good, and my only comment would be it's a little 'blue' in it's reflection, but this is pretty good, so as a rear view mirror, no problems.
The power to it is via a supplied 12v cigarette style power plug, which has a really nice long power cable on it so you can thread it around the car. It also comes with a small rear-view camera to put at the back of your car for additional recording, and it also acts as a reversing camera (and has a 12v sensing cable to connect to reverse lights so the screen switches on and flicks to view this when it reverse).
Fastening it around the Chrysler mirror was fine, the mirror was about the same size (and the Chrysler mirror is large) and the camera pops out the side quite nicely (The camera is to the left of the back of the mirror). The issue here is I think this was designed for left-hand-drive, and so the camera swivel on it's mount wasn't quite good enough, I viewed more of the left pavement than of the right of the road (it was fine, but just not covering the right of the road as much as I wanted).
So I therefore decided to install the mirror upside down! This means that all menus, etc, are upside down, and the images recorded were upside down, but it had a better field of vision. I might look to open the unit up and flip the camera at some point, but not yet!

So now onto fitting the cables. Luckily along the top of the front windscreen it is just soft foam padding to the roof so gently pushing the cable up and hiding it was easy. At the left door pillar, same again just gently prise the rubber and plastic fittings and there is plenty room to put the cables in (one for power, one for rear view camera). Once above the passenger left hand door I left the camera cable there, as I was going to take the rear camera cable along the top of the car.
The power, I then fed down the pillar, again just gently hiding it behind the plastic pillar cover, and down towards the glovebox. At the left just above the glovebox was a plastic cover, prising this open (It has those metal pop-clips, so fine to prise open gently) let me feed the cable in and behind the glovebox (Glovebox, open it, gently squeeze the limiters and it drops fully open revealing behind it)
This is the view when the glovebox is completely dropped open (down towards the bottom of the picture).
You can see to the left the black cable is the dashcam power cable I was threading through.

Pass the cable straight through, then onto the hard part, into the base of the centre console (where the old tape storage box was on these cars).
What I was going to do was put a cigarette socket inside this storage box at the base of the centre console, and wire that into the current cigarette lighter socket that was operated via the ignition. Therefore the dashcam would automatically switch on when ignition on, and then off again when off.
I took most of the centre console panels apart (Removing the 'wooden' fascia by taking the top two screws out and prising it out). Here is the cigarette lighter socket removed:

To remove it, you can just about see the small push in clips. So with a flat screwdriver head, gently push this into the top of the socket, between the black plastic and the grey dashboard surround. You should be able to prise it out and it'll drop out like you see here.

Pull it out and you see the connector at the back. Press the release button and the connector comes out. Then I found the problem, this cable is really tight and not much spare. Trying to trace the wire drew a blank, it's in a harness that goes round the right hand side of the radio and I suspect straight to the ignition wires (or at least that harness) so getting 'spare' wire doesn't look an option. I therefore decided to take the whole plastic connector apart and solder straight onto it. The connector comes apart easily, sliding the metal contacts out, I was then able to solder on my wires and a bit of electrical tape for good measure. It ended up looking like this:

However, if you do the same thing, make sure the solder and electrical tape is tight (not like mine!) as when you come to push the connectors back on, they'll struggle as they're too wide for the connector. After a struggle that went back on, and so did the cigarette lighter socket. Testing each time, and all the way to ensure polarity is correct, etc. All looked good. So I know had my extension sockets in the lower tape compartment powering on and off with the ignition.

The socket I chose was also from ebay and was around £3 which included two sockets and usb charging sockets on them too, you can never have too many charging sockets!
All I did then was plug in the dashcam cable to the socket and it was ready to go!

Wiring the rear camera was more of a challenge, mainly because of the wiring route I had to take. I'll need to update this with photos and more info when I can but it got dark so I gave up for the day.
In brief, I ran the cable over the top of the passenger door, round the pillar plastic cover and along the top of the rear sliding door. Again just gently prising it into the gap from the rubber seal as there is a generous amount of space behind these without compromising the seal. Round the very rear window, and up to the roof again, then to the boot. I screwed the camera into the grey plastic of the boot lid so it was sat at the top of the boot window. It was pretty small and not obvious which was ideal.

The next problem was to connect into the reverse lights. The camera cable branches off and gives you a red+black cable to run for this. I prised the plastic around the left rear speaker (just below the electric window housing). I found the hard way, this plastic does prise apart, but it should be removed by sliding outwards, towards the boot. I think, as this is an entire plastic component you are supposed to take the whole piece out together (including the plastic cover around the boot opener, etc), but I just forced it and ended up almost snapping (and bending) the plastic retaining clips. That way, I managed to feed the cable down towards the jack stowage locker.

(red and black wire on the photo above just hanging at the moment, this is the sense wire for the dashcam for when reverse is engaged)

That's as far as I've got, taking the rear light cluster out I found nothing more than a small cable and rubber fitting going into the body, no easy/big access hole to feed the cable to! So I suspect I am going to have to remove more of the whole plastic covers at the rear to get to this, so that's a job for another day.

But for now, I'm happy with the job, the unit powers on and starts recording when ignition goes on, and the view from front and rear cameras is ideal!

Get in touch if you'd like any specific details, etc, or to let me know if you've given it a go too!

Wednesday 30 September 2015

Children and online safety

This is always a hot topic, and I'm probably wading into a hornets nest of trouble, but this has crept up on me as my two children are getting older (12 and 8) and starting to use electronic devices more and more for school, for entertainment, etc.
They've always had gadgets, probably my fault, but as they start to use them on their own and increasingly need to find things out on the big bad internet I'm thinking of further solutions to help keep them 'safe' or at least to help know when they're wandering away into something they shouldn't so we can talk about it.

This is the first issue, do you give unfiltered access to your children (or anyone in your house?) and then tell them off for going onto something they shouldn't, or should you filter the access then explain why something came up as blocked to them and explain? As an ISP network engineer this is a particularly thorny question as various ISPs now apply network-wide blocks on content, which I believe is totally WRONG. I do not agree with external 3rd parties determining what I can or cannot do or connect to. That is because I'm an adult and I know when I choose to view something that is questionable, that it is questionable. I don't need to be told that, nor do I need to be told off for it!
However, when it comes down to children then I believe it is the parents responsibility to help safeguard that child. You wouldn't let your child play on a main road, the internet is comparable (ish! creative/written license here) and so you would want to protect and guide them.
This is where I firmly believe the onus is on the parents. And as such I am taking that responsibility on and looking at how do achieve this in the best possible way. In my case I am lucky, I've worked around ISPs and the internet since before 2000 and so have a bit more knowledge than most on what you can and cannot do practically speaking.

Devices, my children have access to several devices around the house, so whatever protection I use needs to be consistent and also ensure that devices don't slip through the net. They use android tablets (The excellent Hudl2), iphone's (evil devices, but they are must-have's for children now apparently) and a desktop PC running Windows. I have two WIFI SSID's setup at home, one for the children and 'guest' access and another for myself and my wife with unfiltered, access to work, etc.
All the children's devices are connected to their WIFI SSID and using that router I have forced the DNS provided to use opendns (now part of Cisco). They provide very basic category filtering based on your public IP address as an identifier and you can then tick which categories you wish to permit. This is a very simple filter set and not very granular, it's also not 100% foolproof as anybody who works in IT knows, it bases it on the devices accepting the DNS entries given out by DHCP on your WIFI router and that the child doesn't tinker with these settings. It also doesn't fully work around proxies, so this I use as a 'simple' filter point but don't entirely trust it to work fully. An example of how this could FAIL would be, permit youtube access, so opendns will then let them get to youtube but that that point they could search and do anything on youtube, so it doesn't do anything further to protect them. That said, it does log access and will tell you on violations and also the general amount of internet traffic being used (again it's a rough estimation as it's based on DNS queries, not website hits, so it's a rough number). Accounts with opendns are FREE so this is good to get started with.

I'm going to digress here a little and talk about losing devices. Since we have portable devices (android tablets, iPhone) we have the potential of them being lost. For android devices the excellent Avast antivirus solves that so easily. Install the software onto the android device, set it with the right anti-theft and location features and attach it to your Avast account. You then have an amazing suite of tools that will help you locate the device, lock it, erase it, monitor it, etc. This is all FREE and is excellent, I've used it many times and it works perfectly. Even better you can connect multiple devices so I've also protected my own phone, wife's and families phones so should any phone be stolen it can be located, locked and erased remotely. Unfortunately the iphone is a different matter. There is the locate option from Apple, however this has never worked when I tried it and unfortunately Avast doesn't support the iPhone yet, so on these devices I've struggled. I've installed Lookout and Prey which have similar lock and erase features but they don't have a huge capability and I've not tested these in anger. They have a free version which is what I use.

So the next problem is protecting content of websites, youtube and sites that are visited. This is where things get a little grey. I don't want the children to be bothered by the filtering that's taking place, but I also expect them to know I'm doing it and that they should be responsible when it comes to using the internet (It's a privilege not a right. Keep saying that over and over. When I was young, the internet didn't exist!). So I started to look for an application that would primarily log and then do basic blocking. Two seemed to fit the bill, Qustodio  and Kidlogger . I went onto both and they both provide a free trial which you have to sign up for and get an email, etc. I signed up to both and as Qustodio's email came through first I put in my kids details (Which is good, it only took their name and year of birth, nothing else. So no compromise there in security). My details it just needed email, and a password so again no nasty data gathering.
They provide a windows client to install on the machine and then you use separate logins for each child on the PC which then attaches to their Qustodio profile. It was simple to use and easy to install. The client app seems to be a little resource hungry but I guess that's because of everything it logs (and the PC I'm running it on is ancient).
They give you a 3-day unlimited trial which lets you try everything out, and I'm quite impressed. It will log how long they've been logged in/active for, what applications they are using and for how long (word, excel, browser, etc), what searches and search terms they're using, and will log url's they hit and browse+visit in a timeline view which is pretty nice. It also has the ability to log facebook+social media activity separately but I haven't used this as the children are banned from these until they are age appropriate (I can't believe how many people let their children on these systems when it is clearly prohibited in their AUPs). Each website and application used can be individually logged or completely blocked by the application, or you can set it to ignore to ignore that application or websites activity, so it's good in that you can ignore known safe or sites you don't want to track or monitor. Logging is kept for 30 days, history-wise and you can have up to 5 children and 5 devices on the premium account. After the 3-day trial you revert to 1 child and 1 device and a limited history (unsure how long).
All in all, I'm impressed with Qustodio. It looks like it will help me teach the children about blocking, also I'm going to show them the logging it does and explain that almost everything they do on the internet is logged somewhere along the line, which I think is a good message to give to them and teach them.
If they feel that something they do is worrying if it's logged, then my thoughts are they shouldn't be doing it. That is the principle I believe is the one that works when it comes to internet security.

I welcome comments to this as I really do want to know what others think to my stance on this, be it right or wrong as I think everyone has a slightly different view. Feel free to comment below and I'll try and reply if relevant to all of you.

Tuesday 22 September 2015

Asterisk BLF for Queues and Cisco SPA504G phones

I was puzzling over an issue on our VOIP phone system the other day, and have finally solved it so thought I'd share it with you and also for when I forget myself how I made it all work.

The problem: Have an option for users to add themselves in and out of their pre-defined queue, and to have a visual indication of if they are in or out of the queue on the phone handset (I also have wallboards, but it's nice to see on the phone handset itself)

The requirements:
 Cisco SPA504G handset (Most newer Cisco handsets handle this too, unfortunately the older Linksys ones don't)
 Asterisk - Freepbx 12.0.5 or newer (That's all I've tested)
 Queues setup

Firstly, go into your Queue setup via freepbx webadmin and make sure "Generate Device Hints" is ticked for the queue. This will generate the function code *45EXT*QUEUE which is what we need for the phone to dial and jump in and out of a queue.

Then we need to tell the phone to allow you to dial such a weird function code. On the Cisco SPA504G web-panel, go into advanced and select EXT1 and go to the "Dial-Plan" option. You need to add in "*xxxxxx*xxxx" to this. My full dial plan shows "(*xxxx|*xx|*xxxxxx*xxxx|[3469]11|0|00|[2-9]xxxxxx|1xxx[2-9]xxxxxxS0|xxxxxxxxxxxx.)" - this may or may not work for you too, but works for me!

Once you've saved that, try it by manually dialling *45EXT*QUEUE (change ext to be your extension number, and QUEUE to the queue you want to join/leave). You should get the asterisk voice confirming you've been added or removed from the queue.
(If you don't and get invalid extension on the phone screen, your dial-plan is still failing to pass it to asterisk)

Finally you can set the BLF button to show and control this. On the Cisco SPA504G these are the 4 line buttons to the right of the LCD. I'm using the bottom one for this.
Choose the PHONE tab on the Cisco SPA504G web panel, go down to LINE KEY 4 and set extension to DISABLED, then share call appearance to SHARED. In the extended function box, put in:
(Where *45 is the feature code setup in Freepbx, 5150 is the queue name. $AUTHID should be translated to the phone extension number and $PROXY to the asterisk server IP address)

After a reboot the display should show QUEUE against a green light on the 4th button. Press it, and it should log you into the queue (and hear the voice message) and then set the light to RED to show you as being logged in. Press it again and it should log you out and the light go back to GREEN.


(BTW in the photo you'll see I've actually assigned the QUEUE to button 3 as I use button 4 as DND indicator)

Sunday 9 August 2015

X10 listener TIP10RF emulator for HEYU and Linux

This is a little script that I wrote, basically because I was looking for a smartphone application (On my HTC One m8 Android phone) that I could use to simply control my X10 devices around the house.
I'd already setup a web interface, but this was a pain, when I just wanted to turn a light on or off without getting up (lazy I know), opening a web browser, navigating, authenticating then clicking ON or OFF, it's a pain! So I looked for apps already written. There are a few but they are all either chargeable or specific for a particular development.
I then found the TIP10RF application from Marmitek/Haibrain (Haibrain is the new name for Marmitek). This seems to do what I want, you add in your devices to the app and you can then click ON or OFF for each of them. However, this application uses a piece of hardware, the TIP10RF device which I've shown below:
The small hardware device simply plugs into your home router (RF45 ethernet connection, no WIFI) and will convert he commands from the APP to RF messages that are sent to your X10 devices. This device also assumes you have a wireless transceiver such as TM13, CM15Pro or the SC9000 alarm system.
So, based on this I downloaded the free app and set about working out how it communicated. Luckily it lets you set a specific IP and port to communicate with their hardware, so I set this to my linux box, set the traffic to be sniffed and started analysing the data. This was straight forward so I knocked together a small PHP cli script to handle it.
This script simply sits listening on a specific TCP port and will respond to the codes received from the application. When it gets a recognised code, it uses the HEYU application on my linux server to send the X10 commands around the house..

If anyone wants to try it, I've uploaded it to github so you can grab the code at:

And please do get in touch if there are some extra features you'd like or if you spot a simpler way of optimising my code! This was quickly knocked together and does work just for what I wanted.

Thursday 30 July 2015

Hotpoint Aquarius SALT light constantly on, fix!

This is just a quick one, probably more for my benefit than anybody else, but if you have a Hotpoint Aquarius dishwasher this might be handy. (This probably works on others too, as they all use the same principle I believe)

If your salt light is stuck on, after filling up, running a few times and it still won't go out, try this.
Run a cycle as normal, when empty open the salt cap and pour a whole kettle of boiling water down it. The theory is that it uses a hygrometer to measure the salt in the water and this is done using a float and sensor. If the float gets stuck, it'll keep saying add salt when it doesn't need it, the hot water helps the float move again and get back into the right place. Replace the cap and do as normal, fill it back up and run the wash, it should turn out sometime during the next wash.

Sunday 19 July 2015

Old blog posts ahoy! - Importing RSS into blogger

I'm pleased to announce I've finally imported all my old blog posts from Geeklog into blogger, so now all the history/archives are here.

Hopefully they work fine! I've also documented the process so anybody else wanting to import a traditional RSS feed into blogger, which may be of use to others. It uses the Google API so I've learnt a little about talking to this using PHP.
Grab the code at my github repo:

And onto the HOWTO/README:


Blogger (Google API) import script from basic RSS feed
This is a simple PHP script that will allow you to import any standard rss feed into Blogger blog (using Google APIs).
Download google-api-php-client first and extract it along with this script (
A few things you need to do first: Open up a google API/developer account and get it active, go to: Create a project to use for this, create a simple name. Under "APIs & Auth" on the left, select APIs, then you need to enable "Blogger API v3" Under "Credentials" click "Create new client ID" and choose "Web application", Ensure Authorised Javascript and Authorised Redirect are set to your website URL. In my case I added all combinations (with www, without, with full /path/ and without to be sure!) That will then generate you the codes you need to edit into the script. Now create the PUBLIC api code, so click "Create new key" under public API access (for browser applications).
In index.php change "setapplicationname" to be the project name you created in Google. change setClientID to be the client ID show to you in the developer console as client id (will look like a subdomain and end with Change ClientSecret to be the secret shown below Client ID in the google developer console. Change setDeveloperKey to the key in your public API for browser applications. Change getByURL to your blogger website address (either your own domain or Finally you need to find your blogger ID, go into your blogger admin panel (as though you are about to post a blog entry) and in the address bar you'll see the numeric ID.
Once you've done all that, you can put your full.rss file into the same folder and it should upload your pages. Whenn you visit the URL index.php will prompt for authority from Google, confirm that and it will begin importing.
It won't import images, url's/images aren't translated they are left as is in the content.
It doesn't 'parse' XML properly, it uses a few search/find strings and just copy exactly as seen.
All posts are marked as DRAFT so you have to put them live.
Posts are added with the original publish date, so in theory dates are preserved.

Tuesday 30 June 2015

Arduino shed/outdoor monitor, batteries and solar panels

A brief update, I put in place my shed/outdoor monitoring system last weekend, installed the solar panel and monitors, and have so far had to change the batteries already, so at the moment it looks like they are only lasting 3-4 days maximum.

Upon investigating my 9v solar panel is giving out 2-3 volts, which is pretty useless. I'm trying to charge my 4 AA batteries (6 volts).

So my next plan of action is to take the solar panel back down and work out why it's only producing this very low voltage, I'm now wondering if the connections on the rear split the panel into two and I'm only connecting to one half (even so doubling 3 volts isn't near the 9v I was expecting), so a bit more investigation is needed.

(Yes I removed the plastic film cover! But it is inside a plastic box for protection, but even so I'd not expect the voltage drop to be that dramatic)

Graphs were being produced before the power failure though as you can see below:

(note the flat line towards the end is where the batteries died and I'd not written a failsafe into my graphing to 0/ignore results)

Monday 22 June 2015

Arduino ESP8266 1-wire Dallas temperature, soil, rain, moisture, solar power unit

Arduino Uno outdoor sensors project. Here is the first posting for my Arduino UNO outdoor monitoring unit. The idea for this is to act as a small weather station, and also to feedback on the condition of the garden. So this is my second version of my earlier garden controller (several years ago).
I bought a bunch of sensors recently, which included:

  • 1-wire Dallas temperature sensor DS18B20
  • Rain sensor module with LM393
  • Light dependant resistor LDR5528 (+10k resistor)
  • Soil moisture sensor with LM393
  • ESP8266 wifi module
  • 9v Solar panel + 1N4007 diode
  • Water float sensors (x2)

The goal is to setup a stand-alone Arduino that will connect to my wifi (signal may be an interesting problem, we'll come to that) and then feed back a lot of environmental information to my server, that I can then graph/log and alert depending on the inputs.

First job was to get the ESP8266 wifi module working. This was a new item to me, but it's principle was simple, it was a stand-alone wifi module that you could communicate using 2-wires serial (TX and RX), so you could open a serial session, connect to your wifi AP using WPA2, WEP, etc, and then set it to send data in an HTTP GET session. The simple commands made this an excellent add-on for me to include in my project, and the price is excellent (Around £3).
Connecting it up, you need power (3.3v), also you need to pull CH_PD to positive, which I did through a 10k resistor. So my wiring diagram worked out as:
(Credit to enio in arduino forums for image)
I connect VCC, GND, CH_PD for power. then TX and RX to the Arduino. To test the connectivity I used my Arduino UNO, loaded a blank sketch and connect RX to data_rx and TX to data-tx (pins 0 and 1 digital), that let me type into the serial console and it was passed straight to the ESP8266. Various AT command sets are available all over the internet, so a few tests I did:
(Full list on wikipedia
After receiving valid replies I knew the unit was operating correctly, and making a quick sketch to connect to my WIFI using softserial started working (using softserial allowed me to use alternative digital pins for talking to the ESP8266 whilst still having my serial console to monitor and upload sketches).
After some trial and error, I found this wifi module dropped out or didn't respond to commands. Upon checking various forums and information, I found this was probably due to the current this was pulling. Originally I was powering it via the 3.3v output on the Arduino, however this couldn't provide enough power, especially when I added all my other sensors, etc and I started to get issues with no reply to the AT commands. Therefore I decided I needed to power this separately. The solution (since I would be powering this from a bank of AA batteries) was to use a LM2596 DC-DC step-down power supply (also known as a buck converter).
I set this up on my multimeter and set it to produce 3.3v so this would supply the ESP8266 directly. (I'll have to see over time how inefficient this method would be, as I know it'll be wasting energy from the battery packs)

1-wire temperature sensor DS18B20
I've used these temperature sensors many times before, I have one in each of the Raspberry PI's around the house and have created a basic temperature 'network' within the house to monitor room temperatures in previous blog posts. I'm using the same sensor again, so as before simply connecting the 3 pins up and including the "OneWire.h and DallasTemperature.h" libraries into my sketch and it was up and running. PIN connections for the DS18B20 are as follows:
So in my setup (You can't quite see this in the picture unfortunately as it's wrapped in black tape) I have connected GND to ground, VDD to +5v, DQ to a digital pin, and then via a 4k7 resistor DQ is also connected to 5v.

Soil moisture sensor with LM393
The soil moisture sensor is a regular two pin/probe style that you stick in the ground, and then measure the resistance between pins. The unit I bought came with a basic LM393 control circuit shown below:

The pin connections are simple, on the left you connect the soil measuring probe, the right are 4 connections, top and bottom are +VE (3.3v) and GND, then you have an analogue out or digital out. The digital out (high or low) is controlled using the variable resistor on the board, so you can set the threshold. I opted for analogue so connecting to the analogue inputs and then read the values shown. Read this as a typical integer from the digital input.

Rain sensor with LM393
This is the same as the soil moisture sensor and came with the LM393 sensor as above.

9v solar panel
To power my arduino I decided to go with a battery pack and use a solar panel to top the batteries up. I purchased a battery pack, the model I chose had 6xAA batteries so produced approx 9v. This created several problems. Firstly the cheap solar panel I bought only produced 220ma 2 watts at 9v, so even at full sunlight it was producing the same voltage as the batteries, therefore this would not charge them (generally you need a higher voltage to charge) and at low current.
Therefore I decided to modify my battery pack to exclude 2 AA batteries, taking the voltage down to 6v which would be more suitable for the solar panel to charge them, and also will reduce the amount of power lost through the heat dissipation on the Arduino Uno.

(NOTE, I'm not an expert on batteries and power, so please do correct me if I make some glaring errors here!)
These are the solar panels I'm using (A chinese import) and currently with their protective plastic film over them. I'm planning on fitting these into a plastic container, to keep them protected from the elements. Although this will reduce their output slightly it will protect them over time.
I should also mention that I have connected in a 1N4007 1A 400v rectifier diode to ensure no power from the batteries are lost back into the solar panels during darkness, etc.
Below is the power pack that I've put in my two dummy batteries to reduce the voltage/number of cells:

Testing the Arduino Uno and the LM2596 powering all the devices the pack was providing enough power. I'll monitor this for amount of current consumed, etc, later in the testing/implementation.

Light Dependant Resistor LDR5528
This was a simple off the shelf LDR that I connected up to the Arduino analogue input ports with a 10k resistor in parallel (to the 5v feed). I then read this during the normal sampling periods.

The code I've used is a combination of various of my older projects put together with some libraries to control the various input sensors. The libraries I've used are as follows:
#include <LowPower.h> - This is to be used to help reduce idling power consumption

#include <stdlib.h> - for dtoi and related functions
#include <SoftwareSerial.h> - for communication to the ESP8266
#include <OneWire.h> - for the 1-wire temperature communication protocol
#include <DallasTemperature.h> - 1-wire temperature

I set a few definitions near the top of the code (for SSID, WPA2 password and the url to GET when sending data).
Setup involves setting the various input and output pins to their relevant values and initialise the softwareserial.
The main code loop is fairly straight forward, I read each of the sensors in turn, display the output to the serial monitor and then use the ESP8266 to send the data to my webserver.

The code is available in full on my github page, so feel free to take a look, and if you can spot any improvements please commit them as I'd like to get some feedback and improvements on my code:

(NOTE: There are a few extras I've missed off here, I'll post further blog entries with tweaks and changes as I make them and when I implement the final system)

Friday 12 June 2015

Follow up to Marmitek/Haibrain SC9000 PSU failure

This is a bit of a follow up to my previous post on the Haibrain SC9000 X10 alarm unit that I use at home. I decided to bite the bullet and purchase a replacement power supply (£15 so not cheap, but then again not too pricey) and it arrived a few days later. I've finally got round to fitting it and as I did made a few observations and notes for the future.

I took quite a few photos which are all in this post, so apologies for it being graphically heavy.

Firstly, the new unit arrived, and unboxing showed it to be identical to the original, no change to voltage, current, etc. So first thing I did was connected it up as a test and checked, yep the alarm would now sound and all the X10 commands started to flow, so it appears this IS a faulty power supply that causes the alarm sounder not to trigger and the X10 commands to fail. At least I'd now determined the root cause of the fault, it wasn't the overall alarm unit.
Next, I wanted to try and see WHY the original failed and if possible make the new one last longer. One thing I'd always noted was that it ran hot, as most step-down transformers give off heat this isn't unusual, but they generally have vents or at least some way of expelling the heat. This one doesn't, the power supply is a sealed black brick, no vents or anything and when I say it ran hot, you wouldn't want to hold it in the palm of your hand long, it's that sort of heat. So my thinking is I give it some vents before I put the new one into service to help loose the heat, my thinking is most electronics prefer to run cool than hot and it might stop the failure occurring again.
This meant my favourite (ha ha) thing of all time, take something brand new that I've just paid for, take it apart and modify it! But luckily these PSUs have 4 clear screws and a simple case, so taking it apart isn't a challenge. Once opened up, split the two halves of the case carefully as one circuit board stays in one side, the other in the base as you can see from this photo with the case carefully separated:

The right is the "base" which has the main transformer and a circuit board that covers the base, along with at the top right the 2-pin mains in socket.
The left "top" holds a much smaller IC-containing board and the output wire that feeds to the alarm (4-wire). The small circuit board has a single screw in it (just visible on photo, bottom left) so take that out and the top casing comes completely clear. This was ideal, my thinking was to make air vents right along where that bulky transformer sat as that's where the heat was generated, and it was VERY snug alongside other electronics, so a good bet.
I set about the case with my dremel, and here I show my failure as a practical/mechanical/precision person, the air holes are horrible, not neat, but I sanded them down so no rough edges and I think they'll do the job.
As you can see they aren't neat, but should allow a bit of heat to escape. Putting it all back together and it looks like the vents are in the right place, right over the transformer.

Now since I fitted the front of the SC9000 to a wall, and then fitted the cable into the gap between the plaster and wall (inside the wall), the next problem was re-feeding the wire to the right place. So I decided not to, and to simply cut the cables and join them back up using a connector block. That way I didn't have to re-trace the cabling in the wall and make life a lot easier!
As you can see, I was feeling quite neat today and even used a connector block (instead of twisting the wires together and taping them together). I then wrapped the block in tape so it was secure and no potential for shorts or anything getting in there.

Putting it all back together, power on and it all worked fine!
(Note for later, when the batteries are low, the green battery light stays on! I thought the power supply had blown somewhere in the process as the green light stayed on. Seems the green light not only shows it's running on batteries, but also that the batteries are low!)

Next, I decided to properly pull apart the old supply, as I'd like to find what failed and possibly fix it, so in future I have a way of repairing these things with just a few parts.
Below are a load of photos of the teardown, I've not yet had time to investigate all the parts but will do very shortly and probably try a trial and error of replacing parts until I discover the failed unit. However as you'll see there are quite a few scorch marks on components, so I'll be starting work there, which is also where I believe the mains part of the circuit resides, hence this bit will be more susceptible to mains spikes, etc, (which is what Marmitek/Haibrain state as the issue when the PSU fails, it's a mains spike)

The main split board from above

The smaller IC board

The top corner of the main board, no obvious damage here.

 After removing the transformer, some scorching of the main board was clear, I'm now suspecting this is where the issue is.

 Underneath shows more heat damage.

 Closer view of the high voltage components that sit almost exactly underneath the transformer.

After inspection I suspect looking at these components closely, however they are only a couple of resistors, so I'm not hopeful that it would be something as simple as these failing!