Archive for the ‘Electronics’ Category
The Return to Rain
After several weeks of flawless weather in Spain, it’s been a struggle getting back into the swing here in the UK where it is raining more often than not. Still I can always look over there using my cameras to remind me of the sun.
Meanwhile, after months off due to a death in the family and then a broken foot (you can’t make this stuff up) Maureen is now back to work and meanwhile I’m about to embark on a series of meetings taking me from Blackpool to Crewe and onto London. It’s going to be a busy week.
Over the weekend I’ve been catching up with emails, finding out what’s going on at work – and doing a little more research into my home controls as well as catching up on episodes of “Cosmos” – which I intend to continue this week as I’ve loaded up the tablet with remaining episodes to catch late at night in my hotel (well, it beats hotel TV). Got the Bluetooth headphones all charged up and ready.
While we were in Spain I ordered a pair of cheap SI 4432-based 4.33Mhz transceivers and I had high hopes for these after the abysmal results I’ve been having with 2.4Ghz radios thanks to interference from WIFI, cordless phones and a thousand other sources of radio crap.
This weekend I tried the PA-enhanced version of the NRF24L01 radio to help me expand my home control setup – one worked – the others failed as they often seem to do – I can’t get to the bottom of it other than to suspect there is an issue with SPI (communication) speed and these radios – as the cheap ones work every time. Others have said similar. Having abandoned the more expensive types, I used my air gun to remove the aerial from one and grafted it onto one of the cheap versions. As you can see in the image below, it looks ok – simply a matter of cutting the original aerial track – 5 mounting holes and a couple of VERY short wires.
I can say for sure that the aerial-enhancement modification is robust and improves range – but I doubt it it even doubles the range which still remains pitifully short in a stone building – and of course the cost to buy these adaptors and aerials individually far exceeds the cost of them as part of a radio!
I then tried the 433Mhz units which came complete with a coiled spring aerial. I carefully put two of these units together using our Arduino look-alike boards. These are not easy to use as the edge connector is 0.05” centres – you really need a fine soldering iron which I just so happen to have. Despite all that, I ended up with one board (apparently) working – it the code was working – but the other remained defiantly dead. So many things could be wrong – the code, the wiring, the interfacing… these are 3v3 boards and my Arduino clones are 5v. I fed the boards with 3v3 and ran the inputs to the radio via resistors. I’m pretty sure that part is correct.
In the process I found a bug in the Radiohead library I’ve been using and the authors fixed it almost immediately which is nice.
The end result looked a little messy due to wiring and resistors – but actually I was quite pleased with the overall fit for a first attempt – not so pleased with one unit apparently dead.
When I checked, the other board had 2 pins shorted – no matter what I did I could not find the short – I can only imagine it was under the 0.05” connector – even a magnifying glass showed no issues – and attempting to remove the connector with the air gun resulted in the board’s destruction. I now have a 2 week wait before I can progress this one (not that it matters as I’m in meetings for over a week). The hope is that these 433Mhz units will have a better chance of going through thick stone walls – I’ll have to wait and see. Next time I’ll nix the connector. I’m also interested in the new cheap WIFI embedded units which can be bought from Ebay as low as £8 – for now however both the embedded software and the instructions are in Mandarin so that will have to wait a while.
In a couple of weeks I’m going to spent time with a friend as we examine the powerful Atmel radios, not in the same price class but it’s worth exploring all avenues.
The “Internet of Things”
As this is now abuzz-phrase you’ll see littering the press, I thought I’d put in my two-pence worth on this “new” subject.
The “Internet of Things” is a phrase used to describe things that can be controlled or monitored (or both) over the Internet.
In 1962 I was too young to be aware of what was happening outside of my own house! but at this time, a fellow called Licklider from MIT was describing what he called a “galactic network” concept in which computers all over the world would talk to each other. By 1969 4 machines were talking to each other in what was called “Arpanet” and the rest is well known… today, billions of machines are connected worldwide… but most folk think of everything from large computers down to mobile phones – what is slightly less well known is the massive spread late last century of “microcontrollers” which are now found in most everyday electronic gadgets (washing machines, industrial controllers etc. and which are often connected together by what is currently called “The Internet of Things”. Checkout Cloudwash if you’re interested in what might be done with domestic appliances. Here is another link to a Samsung phone controlled washing machine, the WW9000.
In 1963 my interest in electronics started with a “Philips E10” kit which started me on the path of building radio receivers, controlling lights and motors.. and I’ve been involved with electronics since then, writing articles, building machines and eventually turning my interest into a business in the 80’s and beyond.
In 1974, the X10 protocol was developed in Scotland (but strangely found much favour in America where, amongst others, Steve Ciarcia made it popular with hobbyists -Steve Ciarcias Circuit Cellar magazine). This was a means of connecting gadgets around the home/office/factory for the purpose of remote control. In this case the signals were/are in fact sent over the mains electricity supply. Other solutions involve WIFI, Bluetooth, general radio, Infra-red and other mechanisms.
That takes care of the local connectivity while the Internet allows that remote control to extend worldwide.
In 1982, students at Carnegie Mellon University created the first ever “Internet connected soda vending machine”. I remember being fascinated at the possibilities this would bring, thousands, perhaps millions of machines of all shapes and sizes being controlled and monitored via the Internet from anywhere in the world. Of course at that time there was not even the concept of an Internet-connected mobile phone so that limited possibilities at the time – but this was enough to start me off and by May 1994 our company had developed a home control system called Appcon which basically let anyone control lights, alarms, heating and more from a PC – and by implication, by remotely controlling the PC, from anywhere.
We used wire control and the mobile infrastructure was simply not ready for this. Today it is and we’re already starting to see simple light and heating control via mobile phones appearing on the market. We’re also seeing what I believe is only the tip of the iceberg in dire warnings in the press about security. While Windows and the Internet in general have had a long time to get used to nasty people trying to break in and destroy – to the extent that virtually all of the public are aware of viruses, trojans and other means of destroying PCs, certainly the home control market has to date not been sufficiently important to attract large scale attempts at disruption – but it will happen – it’s just a matter of time.
Part of the problem is that the sophisticated anti-virus and other techniques used to protect PCs are simply not available to the simplest of controllers you might see in for example a remote light switch. Even HTTPS: which is a simple mechanism to encrypt data over the Intranet is mostly not available to the simplest of controllers.
Gartner reckon that by 2020, 30 BILLION devices will be connected to the Internet and bear in mind that the current IP4 system of Internet addressing allows for only 4.3 billion individual device addresses and that includes PCs and phones etc.!! Newer technologies such as IP6 which allow for a FAR greater number of devices are again not really available to the simplest of devices at this time so there are lots of changes and improvements to be made in the coming years.
In the meanwhile, much fun and entertainment is still to be had in this emerging field – enthusiasts using the likes of the Raspberry Pi, Arduino and other technologies are having a great time coming up with new ideas and new applications. The combination of local networking and remote control via the Internet has chance to dramatically change how we interact with the world in the coming years, offering massive possibilities for saving energy and doing things in completely new ways. Expect to hear a LOT more of this in the coming months.
For my own efforts I’m now controlling my own gadgets in 3 properties including modern lighting technologies and heating and already making savings on heating bills.
Home Control – The Full Mesh
I’ve been working on home control now for many years on and off both professionally and today as a hobby (for now). This blog documents the latest state of play.
My first attempt at home control years ago took the form of a bunch of boards talking to each other around a building by cheap telephone cable. Simple as that may be it can be a deal-breaker when it comes to wives who don’t like wires! Today this needs to be handled as far as possible, wirelessly.
Talking to a home controller via mobile phone is a no-brainer – simply fit Ethernet capability to an microprocessor board and there are solutions out there for talking to mobile phones, one which takes some work but which yields one of the best visual interfaces to date is NETIO. I’ve developed my own Android software and that works well, but for now, visually, NETIO remains my tool of choice – though lack of updates from the designers is starting to grind a little – such is the way of Apps.
To get instructions delivered around the building, for the last year I have been struggling with a low-cost radio called the NRF24L01 – these are readily available on Ebay and are small and cheap – however they do not suffer stone walls gladly and have somewhat restrictive range, due mainly to their choice of operating frequency – 2.4Ghz which just happens to be the same range as everything from WIFI routers to cordless phones and more. Their advantage – cheap.
Within that restriction they are quite reliable – I’ve sent hundreds of thousands of data packages in a row without error. In order to get past the stone wall issue, it’s no good having a controller simply talking to radio units (which is how you avoid wires all over the house), you need some kind of network so that units can pass message from one to another. Because the Atmel Atmega328 processors I use (custom variations on the basic “Arduino” theme) are limited in capacity, as is the NRF24L01 radio, up to now it has been impossible to to manage anything more than a limited form of hopping network where certain “nodes” or slave units act not only independently but also as “relay” nodes, passing messages on to others and hence increasing the range of the system.
What has always been needed was some kind of full mesh where all units can act as gateways to others and where the failure of one unit results in the mesh re-adjusting itself automatically to handle that. Up to now that’s been a dream but the software now exists to do this – called RadioMesh. The nearest anyone has come up with until now was RF24NETWORK, a simple network but not a mesh – in this network up to 6 units could each talk to 6 others and so on – the limitations included the need to specify exactly who would talk to who – so if one unit went down it could bring the whole network down. Accordingly I’ve been spending my evenings and weekends gutting my software to try to accommodate some new software which forms a “mesh”… and the work has paid off – I now have a rig up and running.
As you can see from the above, I’ve used the Atmel 1284p for the “master” unit – I long since gave up on the 328s for this – just not enough RAM or storage memory – and I’m now about 2/3rds through the 128K memory that comes with the 1284. On the other hand, “slave” boards which have no Ethernet can JUST about handle a range of functions and the mesh at the same time.
Each “slave” board has an output to control serial LED strip (which needs a separate 5v supply), 1 Infrared output, 3 normal digital outputs, 3 PWM outputs (again handy for LEDS), 2 general purpose analog (or digital) inputs and 2 temperature sensors. I’ve also incorporated an inexpensive 433Mhz transmitter to replace wireless remote controls – but that’s not 100% yet. The main board has an Ethernet Connection and also an optional output to an LCD display – the slaves also have similar outputs to an LCD display and in each case I made the decision to give the display it’s own intelligence – i.e. it’s own processor – so that I end up using the serial out on the slave boards and the SECOND serial out on the master for this purpose – hence the displays are optional without any software changes.
The master board is able to update Google Docs spreadsheets, send emails and Tweet – I’m currently still experimenting with the above as the email tools have a tendency to take too long to operate (but still work).
If you look up “Scargill home control” on Google you’ll find a host of earlier articles including some in-depth stuff and on YouTube I’ve detailed my experiences with the NRF24L01 radio units. Amazingly this has had well over 20,000 views! https://www.youtube.com/watch?v=VgmVYdSCNLs
Next steps – I’m working with a pal and we’re going to take a look at Atmel’s own mesh software for a chip they do with radio built in – we’ve a very tiny PCB on the way from China to test this out – also I’m pondering putting the radio part on it’s own 328 chip with a slave SPI interface in order to allow it to concentrate on radio reliability while taking a whole load away from the main board. It sounds over the top but given the very low potential cost of a 328 chip and crystal, such a solution would leave more memory and MUCH more program space in the main board for improvements and new features. Watch this space.
This all sprang up from my original article on a cottage thermostat in which I envisaged a very simple controller. Then came the UberBareBoard article about an Atmega328-based Arduino clone, initial attempts to master the NRF24L01 radio. The next article was the first item entitled home control and after this – then part 2 and then the winter update – then the April 2014 update and then things really started to move as I discovered better networks – and better radios in the the September update where I discovered Radiohead, the Si4332 and RF22 radios.
Radio Networks
I had a really interesting conversation this evening with a pal who’s into electronics as much as me. I’ve been messing around with low-cost radio “mesh” networks which essentially give me the ability to read data and control outputs around the house wirelessly…
For some time now, ever since the oil company tried to give us a mobile phone based oil sensor at which point I had to tell them they’d just screwed up for half of the UKs rural community for whom there are no mobile signals… I’ve been wondering how to make a safe remote reading mechanism for the oil tank.
Funny how you don’t put two and two together sometimes… there are available (from China as our lot are too greedy) some cheap ultrasonic sensors – like the ones you have in cars to help you not run people over.. for a couple of quid you get a little board with a transmitter and receiver and you can take the signal and get accuracy of sub-centimetre bouncing off stuff for distance measurement. It occurred to me tonight – why not bounce off oil! So the next step was – how to get that info back to me – well I already have home control measuring temperature – modifying a board would allow me to return how full the tank was – so using temperature as the equivalent if it returned say 10 to 30c – that’s 20 values – that’s a tank accurate to 5% – good enough…. and finally how to power all of that – well – my friend suggested a super-cap – after all it only needs to wake up once an hour – take a reading, report back and go back to sleep – and a little solar panel to keep the supercap charged.
When the board powered up it would talk to my network – which up to now looks like it can reliably send data from unit to unit back to base – I’m looking at a test rig here for the network – I have a board in front of me – the “receiver” – two boards in the garden acting as relays – and one in the living room sending out incremental numbers as fast as it can. Right now I’ve just received 700,000 packages without issue and I plan to leave it overnight on test – hoping to hell it does not rain!!!
Could be onto a winner here… would be nice to add that to the armoury of info I have available at the touch of a button on my phone and tablet…. but it’s late at night – something for another day.
Home Control April Update
The home control system is coming along nicely and after a “weekend of code” has some nice new facilities, not the least being a new test desktop PC program and some new radio error checking. Add to that the recent work on week/weekend temperature program and it’s just about ready to roll to both the cottage, our house and Spain. One of the guys helping me has gone off with the first model to play with.
Firstly the Android/IOS App has been tidied up and some new screens put in the place – the first is shown on the left here and shows temperature monitoring, +-adjustments and hold-off (in days) which puts it on standby – useful for the cottage if it’s not in use. Dusk and dawn times are automatically calculated on a daily basis and any of the on-off controls can now include on from dusk until midnight, on from dusk until dawn etc.
The second page shows some demo NRF24L01 remote units and similar on-off controls with these.
The new internal additions allow for momentary radio failure and will temporarily log out and failed unit and it’s siblings to prevent slowing everything down. This was a major pain before as constant polling of units could slow things down. That is all now history.
The third page here can control serial LEDS – the new type with individual serial control. I’ve not yet implemented a simple means to change the lengths of these LED strips but that will come shortly. There’s no reason I can’t store this in EEPROM.
Note the various colour controls and sliders. The very bottom is just an experiment area.
Below right you’ll see the heating controls which allow setting main and fall-back temperatures as well as weekday and weekend timing controls. You should be able to enlarge these images by clicking on them incidentally.
Below all of that is a glimpse of the new PC testing software – just finished working on that and not yet turned it into stand-alone compiled code but that will come this week hopefully. It works perfectly and includes the ability to save profiles for testing different board scenarios.
What has made a bit of a difference is the discovery of the ease of extracting mains control PCBs from some of the low cost plug-in-the-wall Chinese USB supplies – the newer ones have very small boards capable of giving out over 0.5amps at 5v very efficiently.
So now it’s possible to make plug-in-the-wall radio units and masters no longer needing separate power supplies. Added a nominal level of security
Some way to go before I’ll be satisfied with this but it’s starting to look ok. I now have TWITTER alerts kind of running on the larger boards but the low-cost version still won’t have them – I’ve written off to the guy who designed the Ethernet library to see if that can be fixed.
All of this has come a long way from my early experiments with the NRF24L01 radio boards – which seems to have been a popular video https://www.youtube.com/watch?v=VgmVYdSCNLs but documenting this lot could take quite some time.
The only problem with the NRF24L01 boards is range – they are atrocious. Firstly they are very susceptible to noise and many people recommend putting an electrolytic capacitor on the board at the connector. I suspect this has to do with current spikes when transmitting. This does seem to make a difference. Secondly - they are in the same radio spectrum area as WIFI etc. Thirdly there is no way to gauge incoming signal strength and therefore when used with any mesh network software, it can’t tell which is the best connection to use – and finally – just because of the frequency band they operate in combined with low output, they won’t go through thick walls easily – I’ve seen their range reduced to a few feet in certain circumstances. On the plus side, they ARE cheap and though they need 3v3 to operate, the data lines happily work with 5v logic – most other cheap boards out there need level convertors which at the very least means a bunch of messy resistors.
On the right you see a little stand-alone Ethernet-driven board which is dirt cheap to put together.. that too has possibilities though of course it still needs an Ethernet lead to run. I’ve sent off for some inexpensive plug-in-the-wall mains USB supplies so I can rip them up and get the supply PCB out of them to power these units.
Somewhat frustrating that they are way too expensive when sourced in the UK but hey, at least they’re available.
That’s it for now, got a lot of work to get through before I can devote more time to this and awaiting feedback from various people to fix some minor library issues… but no doubt about it, the next house will be the one to watch for home automation…
Update July 2014: I’m in Spain and working with controllers here – the range of the NRF24L01 boards (or lack of it) is getting to be a severe problem. Investigating alternatives such as the Atmel processor with built in radio and some 800Mhz and 433Mhz transceivers.
This all sprang up from my original article on a cottage thermostat in which I envisaged a very simple controller. Then came the UberBareBoard article about an Atmega328-based Arduino clone, initial attempts to master the NRF24L01 radio. The next article was the first item entitled home control and after this – then part 2 and then the winter update – all the time learning more and more. And after this… July and the full mesh.
At Home with Arduino and NRF24L01
The old remote control is starting to get a little out of hand and I’ve not even started yet. This test page controls 8 digital outputs and 3 fader controls for LED ARRAYS… offering various light-up commands now – as well as turning stuff on and off, I can control lights based on light-up and dawn settings!
Once the technology is out of the way I’m going to have to think of ways to simplify this!
Meanwhile Maureen is walking around looking bashed – the insects have got her again – they don’t half make a mess. I can see her being on anti-histamines to get the swelling down.
Remote controls I left in Spain are working but the radio link isn’t perfect, seems to vary with temperature or more likely humidity as it’s the rocks that get in the way of the signal. (Update August 2014 – all sorted – controllers in Spain operating perfectly).
Next job – throwing out old rubbish – we’re moving shortly (hence the rush to get the home control stuff ready for prime time) – so I’m going to have to be ruthless – if it’s not been used in 3 years – bin!
A very pleasant day
I travelled down to London yesterday for the Internet show in Earl’s court. Long overdue for catching up with the latest due to being bogged down with work most of the time, I took a member of my committee along with me to go see what’s new and hopefully bring home some new ideas.
We started the trip last night at Brick Lane in London -the weather there right now is fabulous – I took the tube from Victoria to Aldgate East and walked the rest of the way with thanks to Google maps on the phone. I met up with the guys at a pub called the Princess Alice where we had a couple of beers before heading off to Brick Lane and the myriad of Indian restaurants therein.
We usually end up at the same place and so it was that we got our free beer, free starters and 20% off – it takes no bartering at all to get this. Cracking night with a fellow techie.
This morning we were up sharpish and off down from our hotel in Victoria – the Double Tree in Bridge Place, to head off on the tube to the event.
Internet World was not as big as I’d hoped – some day I must go to one of those shows in Europe – we managed to get through it in the morning rather than the whole day but in the process, met some good contacts, I certainly gained some great ideas and generally got up to speed with what’s out there. As well as business-oriented stands the people from “The Internet of Things” were there with some fabulous Internet-connected toys.
That left only one thing to do – get back to the office in Victoria… grab some kit and head off home. As we were sitting in Earls Court having a bite to eat for lunch – and being as it was a lovely day, having no idea of distances I suggested a walk to the Thames – and that became the start of a nearly 4 mile walk along the Thames and back up to Victoria – for which I am now suffering.
On the way back I had to walk through the Centre for Life in Newcastle and there was a big sign up advertising Maker Faire this weekend which is all about robots, 3d printing machines and other interesting stuff so I’m sure we’ll end up there at the weekend… but first there’s the slight matter of the Iron Man 3 movie!
Cottage Thermostat
If you’ve been keeping up I’ve spent all my spare time recently getting to grips with the Arduino – which is in essence nothing more than a single-chip Micro with bootloader and a decent library of routines.
We needed a better thermostat for Hollyberry Cottage and decided to “give it a go” – here’s the results so far after MANY blind alleys and the smell of fried plastic on more than one occasion…
So essentially what you’re looking at on the right is a prototyping board with a microprocessor on the right and associated parts (the little long grey chip on the right), at the top of the board – the blue sub-board is an Ethernet (internet) interface, at the bottom a mains relay. Off the board to the left is a control pot (user heating control, to the top are some LEDs and on the right is the cable I use to program the lot – that’s not part of the project.
So the idea is simple enough – the unit via a remote head controls the temperature in the place with two options – normal and standby… in standby the temperatures drop, in normal they are suitable for having people there.. in each case there are 4 timezones and the level of control the pot has is controllable… so we might let people vary the temperature by +-4 degrees from the setpoint for example….
So why the Ethernet interface – well, Maureen and I are out and about, perhaps even in Spain and we need to be able to handle last minute cancellations or indeed last minute bookings. Instead of driving over to the cottage to change the heating, we want to be able to do this from anywhere… and that means on a mobile phone. There are TWO different and incompatible Ethernet Interfaces for the Arduino board and I made the mistake of spending a lot of time working with the cheap one using the ENC28J60 chip – it’s cheap – but it simply does not work reliably. I then moved onto the standard board which uses a Wiz5100 chip – and that worked perfectly except for inexplicable hang-ups which were pretty predictable – turns out the standard library that everyone uses has a bug – that sorted the board is now working utterly reliably (up to now, longest test 24 hours – I plan to give it a couple weeks next).
The interface has to be simple.. As you can see on the left I’ve stuck with large buttons. Typically you would log into the site and press NORMAL or FALLBACK to control the heating – but you can also set up the time, set the temperature zones and even view a graph of historical temperature (stored locally in EEPROM). The graph will get more sophisticated in time but for now it merely shows historical data. The chip has enough spare EEPROM for around 900 points (to the nearest degree, much smaller if you want fractions – though thinking about it I could store to the nearest 0.5degrees just by doubling the figure and getting the 8-bit equivalent – if the temperature hits 128c we’re in BIG trouble – or minus for that matter internally).
Instead of an expensive LCD display at the user end I’ve gone for 3 simple LEDS – red, green and blue. The GREEN light simply flashes to let you know the unit is thinking – when the heating is ON it flashes far more obviously…. the red and blue are optional and give a varying indication of HEATING (red) or COOLING (blue) depending on the setting of the pot.. they may or may not make it into the final unit.
I’ve incorporated delays to stop someone madly fiddling with the controls and setting the relay on and off rapidly….. and the settings will survive a power loss – though right now the time won’t… my next job is to get the board to send me an email if the power dies so I can reset the time – cheaper than using a battery and more useful as I need to know if power cuts occur! Maybe I’ll get it to send a TWEET…. more as things progress.
Update 29/3/2012
The email was not that easy – turns out it’s quite hard to have the board do a server/client on it’s own web pages AND handle something else – so email, even twitter is out (I did get the code running to send TWEETS!) until I can find out how to do 2 things at once. On the upside I’ve now added a real time clock board so it knows the time and can keep it if the power goes off. The board is essentially done, it now needs to sit on test to make sure it’s reliable. NOW I can get back onto working on Maureen’s SAD light… which will also get the real time clock treatment! I’ve ordered more of the Ethernet boards – I can see lots of applications for this stuff.
Update 24/9/2014
See other posts on the subject of home control – amazing how far this project has come on in 2 years! The first follow up to this original article occurs here – my UberBareBoard project.
Life as Normal
I’m looking out of the window and wishing I was in the sun… though to be fair, it’s not that cold today, yet. In-between bouts of database work for the Fed, I had a trip to the docs as my foot keeps giving me trouble, so now I’ve a load of exercises to do, reckons I’ve damaged something.
I’ve been working on my relay board… this is a board that talks to the Internet and serves up a web page by which I can turn up to 8 mains relays on and off at a distance – like – any distance. I need these to control stuff in Spain when I’m here and so it has to be very reliable.
As you can see on the right, the interface (web page) is pretty basic but I wanted it that way as I have to control this from the iPhone.
Progress so far is good… I built a pre-prototype using an Arduino board and this model here is done using a little Arduino Nano. Most of my time was taken up figuring out why one of the pins didn’t respond as normal – I figured it out – CHINA! And so now, all’s well and it’s one test where it’ll stay for a couple of weeks to make sure it’s crash-proof.
Next stop is to add a couple of temperature sensors (inside/outside).