Archive for the ‘Atmel’ Category
Home Control September 2014 Update
Streuth.. I’ve just realised I’ve been running this blog since 2005! Doesn’t time fly. My interest in using Atmel technology for home control started with an article I wrote back in 2012 simply called “Home Thermostat”. At that time I was just playing – but messing with prototypes really isn’t much fun so shortly thereafter I design the “UberBareBoard”. That article was followed up by my first attempt at home control over the Internet and part 2 by which time I was starting to see some real potential for not only my home but our holiday cottage business and for our place in Spain. Then came more updates as I got to grips with the more powerful Atmega1284p chip and started to develop my own PC-based test tools. By July I had it all figured out – or so I thought – using RF24NETWORK software providing a mesh-type network of radios still using the NRF24L01 radio.
Amazing how things change. The NRF24L01 boards which – I’ll grant you are cheap, continue to function poorly –they do not like stone walls and the RF24NETWORK is not a true mesh – you have to specify every node in the mesh which makes replacing boards a lot of fun.. and it really cannot handle one of the boards going offline. Finally, no-one has yet made effective use of interrupts when using these radio boards in a network – which puts further limitations on what you can do – as you spend your time constantly polling the radio network.
Over the summer, my pal Aidan and I have been working hard – we now have a decent Atmega 1284-based board to work with – you’ll see it below. Late July I discovered the Radiohead library – the nearest our little processors have come to seeing a proper mesh network.. but that now pushes the 328 chips out of the window – as the library takes them near the limit of their available program memory and as for the tiny 2K of RAM – just not enough. For boards at the end of the chain, perhaps – and I have 3 working installations using these – but for the master board, the 328 is no longer an option.
In August while enjoying the sun, it hit me – the NRF24L01 chips don’t have the ability to know how strong the incoming radio signal is – so how the hell can a network possibly know which is the best unit to route the signal through – and that started me on the hunt for alternatives – which brings us neatly into this post.
If you’ve been following my blogs you’ll know about my on-going work on home control but firstly you’ll see the phrase “Arduino” bandied around. I use this merely for convenience as I use a lot of the Arduino libraries out there – but my boards are home-grown. I’m particularly fond of the Atmega1284p chip because, unlike the standard Arduinos you see our there, this has 4* the RAM – which means it’s less likely to run out. It also has 4* the FLASH memory – so just when Arduino sketches are running out of room, the 1284p is just getting started.
I used to use hand-made boards and there are plenty of those lying around, but these days I’m using a design we put together called the “Aiduino” – so-called because my pal Aidan did the board layout. This particular design has stood the test of time and I use these on everything. It has space for both 3v3 and 5v regulators, the chip, the usual support components and that’s about it.
You’ll see a typical Aiduino above with edge connectors for all the port pins and an SPI connector near the middle. I don’t bother putting the programming interface on the board as the low-cost FDDI interfaces do that all for you – why waste valuable board space. I simply allocate a 6-way connector on the edge of the board for programming.
Armed with these boards, I have LCD display controllers (for wall mount displays), a master controller with Ethernet card and “slave” units to control lighting etc. All of these units talk to each other using NRF24L01 radios which are very cheap 2,4Ghz popular radio modules. There are two problems with these radios – firstly they are very low power and secondly they are on the same radio broadcast range as just about everything else including WIFI – and they DON’T like stone walls.
I’ve looked at the cheap FSK units as used in radio remotes – no-where near powerful enough.
Aidan and I are investigating some Atmel chips with on-board radio – these look promising but getting all of that running in the Arduino IDE and hence keeping access to the Arduino libraries – is proving a challenge but watch this space as he’s working on this right this minute. We’d like to produce (where others have failed) a tiny radio module which runs on SPI and which internally handles all the mesh coding and massive buffering – as well as offering other functions to take the load off the main boards.. Meanwhile…
I’ve looked at the RF22 modules – but these come from the USA and hence are a little expensive (inc. postage).. but only in the last few weeks have I discovered even cheaper Si4332-based radio boards from China which are compatible with the RF22 modules and hence can work with the likes of the Radiohead library for Arduino – a simple but fully functional “mesh radio” library. Not only that but these radios and library combined, unlike the slightly less expensive (but only just) NRF24L01 units, make good use of interrupts to ensure you can actually do something else while the radios are working!!
See the radio on the right – that’s one of them. They are tiny which poses a problem for prototyping as the edge connector is 0.05” pitch – but it’s do-able with care.
Below you’ll see one of my bodged Aiduinos which has the radio board mounted on top of the 1284P chip. If this all pans out I’ll make a board that incorporates the radio… and in the process of research I’ve found out some interesting things about these little radios.
I can say that I’ve had 3 of these running in mesh mode and the range covered by 3 equally spaced units (the centre one acting merely as a message relay in this case) covers from my garage, to my greenhouse – through 4 stone walls and an intermediate lightweight wall – which is WAY better than the NRF24L01 chips can manage.
At first I managing a couple of message round trips a second – I needed to get the speed up to dozens of round trips a second in order to allow me to, for example round-robin poll several units to update the mobile phone.
Well that worked too thanks to some help from the designer of the Radiohead library – a change from the library defaults brought me to 100 package round trips a second – when I say package – we’re talking about, say a 20 byte package going there and back – and with additional maintenance bytes (from, to, ID etc.)
The chip used in these radios, the Si4332 is supposed to handle a maximum +20db output – I managed +17db – but I’m convinced the little spring aerials are now the limiting factor – with full power I can now get through 2 stone walls but not right across the house.. but WAY better than the NRF24L01 chips even when the latter have stub aerials.
To run these radio boards, they need 3v3 power. Our Aiduinos run on 5v but have 3v3 out. You can feed the one output from the radio directly but the inputs to the chip might be damaged by direct connection to 5v logic – one option is a level convertor, another is a resistive divider. I found that for the 3 inputs that need it, 470r series resistors do the job just fine (The NRF chips work off 3v3 but will accept 5v signals directly). Why don’t I just run everything off 3v3? Speed and driving other devices, that’s why.
I’ve now modified the Radiohead library so that I can also get a flag when data is passed THROUGH the unit so it’s now possible to indicate the success of not only incoming packets but those passed on elsewhere – very handy for debugging and there’s nothing wrong with pretty lights anyway.
So there it is – what looks like a reasonably inexpensive radio solution for home control and with a tiny mod, the standard Ethernet library handles the Atmega 1284 chips no problem – it’s detailed in here somewhere but boils down to adding the chip to one of the library conditionals for the Mega boards. I did notice when these radios are running constantly, a slight decrease in range of my plug-in-the-wall mains controller handsets as they are on the same frequency range – but in my application, such all-out non-stop transmission would only occur when say the mobile phone is actually polling the units – otherwise it’s just about occasional updates and checks. As for the handsets interfering with the network – they don’t – maybe thanks to the frequency-hopping technology embedded in the boards. Incredible technology for such a low price.
Far more to come in the future. I plan to add moisture detection for our plants, gas monitoring for the home, I already have lighting and heating control working in 2 of the properties. I also have IR remote control and radio mains control underway. Do look in.
This is the latest to date in my series of articles on home control which started with 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 – then came the full mesh article – by this time I had everything starting to run the way I wanted things but for the radio network – as you’ll realise by now, that issue is starting to disappear.
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.
DIY Arduino–the “UberBareBoard”
Ok, so I’ve rekindled my interest in electronics with a vengeance. I’ve a load of gadgets I’ve been wanting and not finding anything reasonably priced out there I decided to get the soldering iron out and make them myself.
And so it was that I started looking at processor boards out there to make use of the popular Arduino design. I say design, the basic Arduino is really very little more than a manufacturer’s minimum setup – but the important thing is the volume of support software out there – in particular Ethernet software making it possible to create Internet-enabled devices such as my “EtherStat” Ethernet-and-infra-red-controlled unit which has now been on test for the past couple of weeks without a hitch and which will soon end up running Hollyberry Cottage.
None of the boards out there are without issue and so three of us collectively decided we’d have our own board and I took on the design job.
Armed with Eagle PCB package with which I’m well familiar (though I had some catching up to do) and a little imagination I set off putting this together from scratch - I should at this time thank friends Jonathan and Aidan for the encouragement and also the latter for checking my work and generating the “Gerber” files etc.
The result – here it is..I nicknamed it ”UberBareBoard” as it has everything except the kitchen sink in it (feel free to zoom in on any of these images which should expand or “lightbox” if you click on them).
The board follows the same form factor as the original Arduino though that was only by chance as I spotted an open-source version of the board outline and connectors. Having put several commercial boards together into various test projects, I came across the same problems every time – not enough power connectors, regulator getting hot, parts too close together, same pins used multiple times- and so what you see here is fairly simple but with sufficient extra pins to make life easy for lash-ups.
In the bare-board image above you’ll see on the front-left a 10-way connector – that’s for the cheap Chinese radio boards. Lower left there’s a 6-way connection – that’s pretty standard as are the outer connectors giving access to the 19 I/O pins and power and ground. Note top left the regulator is mounted flat on plenty of copper board (both sides) to dissipate heat and there’s room for a standard power connector (standard that is unless you’re Maplins who have a HOPELESS and hopelessly over-priced selection of connectors).
At this point it’s probably better to look at the populated board. Front right you’ll see a LED which is attached to D13, a far better place than making a power led as you can see the board working on power up (it flickers). Over on the right I’ve left room for a 3-pin infra-red receiver and a LED to go with that. Top right is the reset button, left from there the standard programming connector and left again (ie upper middle) you’ll see a power (+5 and GND) connector and a 2-pin battery connector. Relevant diode and charge resistor are fitted. The empty socket is for a 24c256 chip (64K EEPROM) and centre front you’ll see 2 diodes, they’re to drop the 5v supply sufficiently to use with the radio or Ethernet modules.
Mass production? No, we scoured the web for cheap UK prototype suppliers and ended up sending off to China for a set of 10 prototypes at a reasonable price – somewhat over a fiver each – and this for fully tinned, masked, cut to size prototypes of production quality. I’ll be using these guys again – turnover was little over a week.
I’m happy to say that apart from not having sufficiently small 1k resistors to mount them horizontally (that’s what I get for using standard library parts and not checking) and getting the mounting hole layers wrong (hence no mounting holes, quickly corrected with a drill) the boards work perfectly – and I have lots of plans for them.
This article was written as a follow-up to the original cottage thermostat article – and the first follow-up to this is here – NRF24L01 transceiver and Arduino.