Monthly Archives: November 2016

The Mighty T3

FriendlyArm NanoPC T3Some time ago, I wrote about the FriendlyArm NanoPi M1, a simple, low cost board which seems to hold it’s own against the Raspberry Pi2 in all but GPIO control – that’s not to say there is anything wrong with the GPIO but you have to write your own stuff for it as there is (so it would seem) nothing remotely like PIGPIO for these or similar machines. PLEASE prove me wrong.

See updates to this article at the end….

So that’s all fine but what if you need something more meaty? The FriendlyArm NanoPC T3 is a 64 bit octa-core board of similar size to the Pi and where the M1 scored a benchmark similar to the Pi2, the T3 is nearly twice as fast and has a lot more going for it – but then, it is also more expensive. When I say TWICE as fast – that’s doing the same benchmark – if the benchmark made use of all eight cores then the difference could be considerably greater. I've also reviewed the NanoPC T2 but my recent conclusions on that, at least for Android were not too good, certainly not for media consumption. In fact, as of now, I would say NOT to use the T2 as a media centre. See later comments in here.

Like the M1 I’ve managed to get Debian with all my usual tools running on it, really without any great problems. So what’s so special about this one?

It has an A53 Octacore processor, running at 1.4Ghz, with 8Gb of eMMC internally and of course you can use an SD. Unlike most other boards it has 1Gbps Ethernet along with WiFi 802.11b/g/n and Bluetooth 3 dual mode.

Along with that we have 1GB RAM, the facility to handle one of the company’s inexpensive LCD touch display boards, serial debug, RTC interface, 4 USB ports, camera interface, HDMI and supports Android 5.1 (yes with Playstore, unlike the M1 which for some inexplicable reason also support a much earlier Android but with no Playstore – so I just ignored that option - pretty useless really), Debian and Ubuntu. A 2GB version is available which is called the NanoPC T2 Plus. This would be my preferred option.

I set mine up with Debian as usual, used my script to put all my usual stuff on and left it happily sitting in a corner running Node-Red for days - worked a treat.

On the GPIO front – there is some C code available and accessing the ports is fairly straight-forward but it requires root access and we really do need a better way.

Incidentally the unit I have, has a heatsink. Recommended.

There is a microphone input as well – and audio output can go to hdmi or the 3.5mm stereo jack. I already have a T2 model sitting running Android and ImperiHome as a kind of desktop status display – this one may end up doing something just a little more processor-intensive (read on). NOT cheap however so you might want to check total cost including postage.

WiCDAbout the only thing I really did not like about the Debian setup for the T3 was wpa_gui which not only looks naff – but also fails to report the status of WIFI.  It would connect no problem but then still say “connect” – which is a worry.

Now, as it happens I have one of the FriendlyArm M1s again running Debian and that has wiCD Net work manager which does work. So I figured, in for a penny, in for a pound.

sudo apt-get install wicd

I had to tell it about the connection at first as it didn’t have my wifi details stored… and then

sudo apt-get remove wpagui

Problem solved. Now – getting the GPIO to work – it’s not an H3 so I can’t use WiringOp…. out of ideas on that one for now.

One issue with the T3 – is the eMMC itself. All of the above was done using eMMC and in an attempt to copy that to SD, I blew the lot. Why was I doing that? Because I can find no simple way to back up and restore the internal eMMC. I can't actually see much use for 8GB of EMMC especially as it is a pain to back up.

I spent ages getting onto the Baidu site trying to get an SD version of the software as the Google Drive link on FriendlyArm’s website just would not work. I don’t know if you know but if you don’t read Chinese – getting a Baidu account can be a treat. Anyway I finally got one.

Update: I contacted FriendlyArm at least twice about this as their Google Drive link does not work – I don’t know what BAIDU is like inside China but it is ATROCIOUS outside of it. This is my third attempt took well over an hour… I would normally get such a small file in a matter of minutes at most.

Baidu SLOW

When I eventually got the file – I realised I could get it to run – but I could not expand it – I tried various approaches including with support from FriendlyArm and the SD simple would not expand – I wanted to use an 64GB SD yet could access only a tiny amount of available storage – which seems awfully silly.  With Android up and running the first thing I tried was a media player – but because there is no information on the infrared remote control, I thought I’d try WIFI control by my phone – but THAT requires root access and the Android provided is not rooted – worse – Kingroot simply will not root it.

Meantime, FriendlyArm sent me some information on expanding the board - info that they had previously put out on the web and it simple would not work - I've now checked and there is nothing out there on this - HOWEVER - their solution works - they just missed out some important info.

When you blow their image onto SD - BEFORE you start playing with Android AT ALL, stick the SD into a Linux PC or a Raspberry Pi or similar (or a Debian machine on one of their boards) - and do the following exactly... firstly check that SDA is available (/dev/) and if not - maybe it is SDB??

So to recap, flash the Android SD - put it straight into a Linux computer - and run the commands below - do not "try it out" in the T3 first or you will fail.

Replacing SDA with SDB etc if  necessary (I've done several installations and not had to change this)...

sudo parted /dev/sda unit % resizepart 4 100% resizepart 7 100% unit MB print
sudo resize2fs -f /dev/sda

Now This isn't EXACTLY what Friendlyarm said in their instructions - but then their exact instruction didn't work - this does. Once done, take the SD out - stick it in your T3, hold the BOOT button, turn the power on and after a few seconds release the BOOT button. Might take a minute or so for Android to come up - originally I was getting a 4GB Android which is about as much use as an ashtray on a motorbike - now  I have one set up with 32Gb and another with 64GB of internal memory - no problem. All of this this will work in a NanoPC T2 but overall I found that to be sluggish.

From there I've put KODI and several other programs in there and it all works very well - the hardware Ethernet being a boon if you're streaming TV shows etc. and the video runs smoothly.

Now all I have to do is figure out how to get the board to boot into Android on SD without having to press the button... I did try just holding the button down and that works so worst case I could see a link coming on.

Update November 29th 2016:  As you’ll see elsewhere I’ve been playing with the Nanopi M3 – a great little board with a nice heatsink and fan that makes for a good media centre… the only issue is – the noise of the fan. It is something one can deal with but it was enough to have me do one last test of the T3. There is now an image for the T3 that will boot up and let you have your choice in a menu of Ubuntu, Debian or Android 5.1.1  - now, I have commented in the blog that I am not stunningly impressed by either Debian or Ubuntu on these devices – at least not the FriendlyArm version and I really would like to see an up to date Android available – however – I thought I’d try this all in one SD image – which lets you easily blow code to the EMMC.

Well I have to say – M3 on SD – or T3 on EMMC – the results are quite clear – the T3 is FASTER.  Running Kodi I noticed that videos play smoothly on the M3 until you pop up the menus – and running the video with all that guff overlaid onto it makes for a very SLIGHTLY jerky movement – but enough to notice it. Not so on the T3 which runs, to use a local phrase, as smooth as a baby’s bottom!  Also Android is one hell of a lot easier to tackle for overscan and resolution changes than the other options and I was soon able to turn the mighty T3 into quiet a reasonable stick-on-the-back-of-the-TV media centre and I am more than happy with the results!


A Little Dashboard Something

tmp11D3Something for the weekend sir? How about a simple means to get visual and tactile feedback from node-red-dashboard buttons?

Or rather than large buttons – icons you may create or obtain yourself in a node-red-dashboard template.

To backtrack: For my own home control endeavours, I’ve been using a number of visual interfaces over time as some of you know – we’ve discussed in here – Imperihome and Blynk for example.

Recently I’ve been taking a look at Node-Red-Dashboard. Originally called Node-Red-Contrib-UI this has come a long way in recent months and I think is worth more investigation because of it’s ultimate flexibility.

I needed a set of controls for my thermostats – you’ll see an example in the image on the right. As well as turning heating up and down (and I have two separate systems for my office and home) – I have for some two years now had Node-Red handling 5 time-zones during the week and 5 at the weekend as well as frost fallback and holdoff controls (so we can turn the heating to frost setting if we pop out for the day (or for 6 months in one case)). Also as one of our properties is holiday rental, on the odd week it is not in use, it is handy to be able to stop down the heating for a few days, secure in the knowledge it will automatically turn back up when the time interval is done.

At the user end, I’ve used Imperihome for this and Blynk – and neither are ideal as I need so many controls.  Blynk controls are just too big and the slider values are not separately programmable – that is I can’t get them to show hours and minutes. Imperihome has controls for every imaginable device – but very few “generic” controls.

setup windowsThe Node-Red-Dashboard template has always been my favourite option but in the past seemed complicated and control over I/O was limited. Not any more. As you can see, it came to the rescue with a little coding. The standard  numeric up-down control in the dashboard is BORING with an awful pair of up-down arrows with no kind of feedback. History.

The controls you see here are my own effort – all in one template – and hence I have more control over the vertical spacing without which this would take several pages.

So – for any given control you are looking at programme time, temperature for that programme, up and down controls for the programme time and temperature. A feature of the template control (un-tick both arrows in the setup window) separates inputs from outputs – so you can fire information into the node and use that for display only – and buttons can fire values back out – but the standard buttons were WAY too big – so – I used images. Each section here is nothing more than a standard DIV with 3 spans – the final span holding four images.

[pcsh lang="js" tab_size="4" message="" hl_lines="" provider="manual"]

<div layout="row" layout-align="space-between" style="padding:0px; text-align: left; margin:2px; border:2px solid black;">
<span style="width:28%;padding-top:5px;padding-left:5px;">{{"P1: "+ msg.payload.p1}}</span>
<span style="width:28%;padding-top:5px;padding-left:5px;">{{"T1: "+ msg.payload.t1 + "c"}}</span>
<span style="width:44%; padding-top:3px;">
    <img class="lightup" src="https://xx/icons/timed.png" ng-click="send({payload: 'p1dn' })" height="24px"/>&nbsp;
    <img class="lightup" src="https://xx/icons/timeu.png" ng-click="send({payload: 'p1up' })" height="24px"/>&nbsp;
    <img class="lightup" src="https://xx/icons/tempd.png" ng-click="send({payload: 't1dn' })" height="24px"/>&nbsp;
    <img class="lightup" src="https://xx/icons/tempu.png" ng-click="send({payload: 't1up' })" height="24px"/>


I’ve shortened the URL for the images (any old publically available place) to fit onscreen. I put them on my website in a folder called “icons”- but that’s arbitrary.

So – you’ll see the “moustaches” {{}} surrounding incoming information – my first ignorant thought when using one of these templates was that you were limited to msg.payload – but no you are not – you can send an entire object in there.  Hence the page is a series of the above DIVs. Each image (used as a button) sends out a unique message and a simple lookup table decides what to do with them.


So above, the blue template is the page you see up at the top – the output is passed to a function in which you can use a case statement to decide what you want to do with each button press.  The second function is triggered every couple of seconds and formats your various settings into an object for injecting into the function (in case these values are altered elsewhere, you want to see changes appear on your phone display). The output from the first function ALSO feeds that function so any changes you make with the buttons – once processed – show immediate changes in the values you see in the topmost image.

So – all very nice – press the anti-clockwise time or clockwise green images – the times change (in my case in 15 minute intervals but they are actually stored in minutes – hence the second function does a bit of formatting).

But it is all very boring – you get no visual feedback from the images – and no tactile feedback from the phone. Well, let me say that I’ve spent several hours going down blind alleys – and learned a lot today. The end result – visual “brightup” icons when you press them – AND full tactile “vibrate” feedback on mobile devices.

[pcsh lang="js" tab_size="4" message="" hl_lines="" provider="manual"]

function restore_icon() {

$('.lightup').on('mousedown', function() {


And it is SO easy once you know how.

It turns out you can use jQuery inside the templates – which is awfully handy – and a modern line to control the buzzer.

When you create or use a (.png) (transparent) image you want as a button – make another with a suffix “_b” for bright. The code below on press replaces the image with the bright version and shortly thereafter with the original.  At the same time the excruciatingly simple vibrate line makes the phone vibrate briefly.  You have no idea where I’ve been with this – but note it is a recent addition but modern phones and tablets should handle it.

Note the class=”lightup” in the above img definitions. Stick this code at the top of the template and all will work magically..

The second part of this code changes the image to the bright version and starts off a short vibrate – while setting a timer at the end of which – the original image is replaced. It is that simple. Because I don’t refer to the actual image – you can have several different images which will operate in the same way.

I’m no CSS expert but with a little care and reading up you can make a pretty control page all in one template completely under your control – and of course – making the alternative image brighter was just my idea – you may chose another path. “Blynk”-type controls should be a doddle.

Have a nice weekend.




Dazzling LED ESP8266

Itead LED controller

So… the other day, a parcel turned up for me – some samples from Itead. One of the boxes contained 4 strips of LEDS and a controller. The strips are maybe 20mm wide aluminium with staggered SMT LEDs on them – first a warm LED, then a COLD LED then.. etc.  Each strip is 500mm long and very thin.

The controller takes in 120-240v and gives out – wait for it…96-140v.

Itead LED controlller

I must’ve stared at them for 20 minutes wondering why an EARTH anyone would want to have a set of lights working at such high DC voltages (I still remember as a VERY small child having one of the first battery power valve radios which had a pair of 90v batteries. I also remember being stretched out on the floor in front of the fire, having a great time playing with this new toy until I stuck my fingers across the battery connector, putting 180v DC straight across my chest – not nice).

Itead LED controller

Then there was the fact that the wires to the mains needed to be soldered to the board rather than screw fittings – and I put the thing to one side until one of our readers wrote in to say that he had figured out that the ESP8266-based controller had one LED on GPIO12 and the other on GPIO14. Well, I really could not be bothered to figure out how the default software on this WIFI-controlled lighting controller works) – so I made a change to my house control ESP software to allow GPIO14 to be an output (it’s on the source code and the OTA update elsewhere in the blog). I could do PWM but that is for another day, for now I simply added on-off control – and when testing I realised there’s a green indicator light in the unit which operates like a SONOFF – ie +v is OFF – my “sonoff:1” command makes that flash the right way.

Itead LED controllerSo all well and good but I was still wondering what is wrong with ordinary LED STRIP. As this is serial you need a terminating connection at the far end taking the two ends from the lights to ground. I just used a blob of solder as somehow mine was missing out of the pack.

Over on the right you see the little stand-up processor board with the reset button and 4 way programming connector (3v3, serial and ground) – don’t try this at home with the mains plugged in!!

Itead LED controllerIt was not until I turned the unit on complete with LED strips that I realised the point of the high voltage! BOY is that bright – and in the example you see above, only the COLD lights are on as I screwed up somewhere and the WARM lights are not on  - I’ll fix that in daylight tomorrow. With both on, you could perform surgery there is so much light.  In short – if you need overall lighting for a shed or small office – this absolutely does the job. They have screw holes all along the strip length – but I simply stuck double sided adhesive on the 4 lengths of strip and they’re holding onto the ceiling along with the controller, just fine.

If I could just convince Itead to use 32Mb (4MB) FLASH parts on all their products…


Amazon and the UK

I thought you might like to see a communication with Amazon and my responses.. I am pretty annoyed as it is not the first time an American company has launch stuff around the world – keen to get sales going but not so keen to provide international customers with the tools they need.

So - I’ve spent some time working on the Amazon Echo product and had some issues along the way. Here’s one reason – I wonder if American companies are even remotely aware of how ANNOYING this is? And all of it would have been so easy to avoid just by better communications.

Amazon: Thank you for contacting us. I understand that you have a couple questions. First that you're being referred to the Alexa skills store to find a particular Alexa skill, but it cannot be found. Additionally, you're having some trouble testing your own flash briefing skill. I can certainly help look into both of these issues today.

1. AnyMote Skill

It sounds like the skill you may be referring to is "AnyMote Smart Remote" made by AB Mobile. If that's the case, then yes it is currently only available in the US Alexa skills store, which would explain why you may be unable to find it if you're located in the UK, and thus signed into the UK Alexa skills store.

Peter: Thank you for this - in the meantime I've heard from Anymote - they claim they put in the Skill for the UK Amazon ages ago and were less than excited by the time it Is taking Amazon to process this - you might want to investigate - when something exciting is launched the LAST thing you presumably want to do is cheese off developers adding value to your product!

Amazon:  2. Flash Briefing Skill

Similarly, flash briefing skills are only available in the "English (U.S.)" language, which as far as Alexa is concerned, is a separate language from "English (U.K.)". In order for a skill be accessible on a given device, that device must be in the same language as the skill, and available in the country you're physically located in.

In this case then, your own flash briefing skill is inaccessible on your Echo device because the Echo device in question is signed into the English UK marketplace, and using the English UK language, whereas the flash briefing skill is in English US, which is currently the only available option for flash briefing skills.

Peter: So why are you doing this? Deliberately (so it would appear) disadvantaging British users and developers? In both cases what you seem to be saying is - had we been American we'd be fine. WHY don't you have a British Flash briefing skill? The link you have provided explains what you've told me - thank you - but it does not explain why we are being disadvantaged in the UK?

And if I cannot develop and test a Skill because it won't work in the UK, why on EARTH does Amazon let me go through the WHOLE process of putting the skill into the forms on Amazon UK when you know fine well it won't work?

I really would appreciate some feedback here - I write a blog and am recommending people to use Echo - having developed a general skill here which does work but which causes issues because of Amazon's absolute insistence on using port 443 for SSL ...

Should I be telling British followers to wait for the Google unit because Amazon are not interested in the UK at this time?

Amazon: For more information on international skill distribution and availability, please see the help article below:


New This Weekend

Over the weekend I have added a new MENU item to the blog – COMMENTS – thanks to MrShark for that idea.  Menu top right. The page shows the last 100 comments which will hopefully be useful.

I’ve also added an experimental e-newsletter (again on request, several people said they’d like a weekly summary) for those who like to be informed of new items – the plan being to send out an email maybe once a week or less with simply a list of new entries and short description.  On the RIGHT side of the blog – you’ll see a new form needing only name and email – if you want this newsletter – simply sign it  - you’ll get a confirmation email. No this info won’t go out to anyone else and the emails have an unsubscribe link at the bottom.  This email will ONLY go to those who subscribe.

Much as I like my own software, it is always nice to look and see what others are doing – accordingly, over the weekend I’ve been playing with this software with my Sonoff products -  - and providing feedback to the author AND getting suggestions based on my own experiences, implemented pretty quickly.

If you like programming with Arduino/ESP environment and want software for Sonoff TH10/16, Sonoff DUAL and Sonoff POW, this might be one way to go!  Right now a Sonoff DUAL with this software (MQTT communication of course) is running one of my heaters. Not seeing any issues yet.

Hope you’re all having a nice weekend.



How Not To Do PCBs

tmp21AEMy usual stance is to be nice to Itead, I’ve been dealing with them for some time and although I have absolutely no commercial or personal tie up with them, they do send product samples from time to time as do many others - and I usually end up writing decent reports about their products – especially Sonoff controllers which I think are miraculous given the price.

Well, there’s always an exception (but see the new note at the end)

Yesterday I received this neat little board and accompanying radio handset.

tmpA51So over on the top right you see the board, a really neat little 4-relay WIFI-and-radio controlled board complete with spring aerial and on-board test buttons.

This is the kind of board that could end up all over a hobbyists house, turning lights and other devices on and off. And that’s what worries me as hobbyists aren’t necessarily experts in electronics and mains power use.

So – why would I have a problem with this.


Ok, take a look at the underside – which is clearly left-right reversed from the upper view. The clearances around the relays are fine for mains voltages and they’ve made up for track width with some heavy soldering – not pretty but functional. But here’s the rub – look at the two vertical tracks on the bottom right of the photo – that’s mains power coming in from the connector – to the little power supply.A close inspection at the power supply end shows that the gaps between pins are close – but in practice ok.. but here’s the rub… notice the light green nature of the bottom half of the board – that is ground plane flooding – most commendable – keeps electrical noise down – BUT – what the HELL is it doing right up next to the mains wires??

Those of you from the states might think this is bad but hey, not too bad.. but in countries using up to 250v (we have 250v here) – that is downright dangerous – the slightest damp or circuit board fault or solder beading and BANG.  I am not one of these perfectionists – far from it – I could not tell you how many times I’ve electrocuted myself over my many years messing with electronics (around 50 years amazingly) – but I’m not going near that with 250v mains! So – apart from the fire risk there is also a risk of electrocution from messing with the on-board buttons.

Now – to be VERY fair, I did immediately contact Itead about this (as did Peter Oakes as he has one) and in very strong terms told them my views on this given the high quality of their other stuff. Well, it turns out that in fact that this product is a third party board simply using their little cute power supply left middle) – and they are going to contact the manufacturer.  If you see these boards – I would check that you get a revised version – OR un-solder that power supply – swap the leftmost connector to the spare holes and feed it with 5v instead.

All this REALLY needs is the ground flooding removed from the area around those two tracks – maybe leaving 3mm all round.. and I’d be inclined not to solder the unused middle connector (but that’s just me). Clearly these are early production or even prototypes by the hand soldering – I’m hoping our comments will mean the final production will be useful, SAFE products.

As for the board ITSELF – there are 4 buttons for on and off – and a neat feature – a button to select one of several non-volatile modes – so, for example, the 4 buttons/remote/WIFI might turn individual outputs on or off, or allow only one of 4 to be on at any time, or monostable mode where delays close momentarily only etc. Very good!

Update December 2016: Now, I have to tell you that following on from comments that Peter Oakes and I passed back to Itead, they have, I believe, dropped this product and are working on their own version. I have to say, HATS OFF!


Size Matters… Neo AIR

tmp897DWhen it comes to size, this one is as good as any… the FriendlyArm Nano Pi Neo Air.

You’ve probably read my blog about the Nano Pi Neo, a device I can only describe as “cute” because of it’s really small size - but powerful non-the-less. Well, the AIR version takes things a stage further. No video, no USB (well, no connector anyway) and no Ethernet connector which makes it EXCEEDINGLY THIN.  But it DOES have Bluetooth and WIFI including a socket for an optional external antenna (it also has on-board antenna).

tmp39E7So – H3 Cortex A7 Quad-Core processor – which means that a variety of alternative operating systems to the default Ubuntu will work (just as well as I for one have no interest in Ubuntu). The board is 40mm square and the highest point on the board before you (optionally) fit the (provided) connectors, is the micro-USB connector, which could make for a MIGHTY small controller!

The Neo AIR comes complete with 8GB of on-board  eMMC loaded with Ubuntu. I really don’t see the point of this as it is so hard to fully make a copy as against just replicating SD cards. Aside from anything else – all these boards call themselves or refer to PI – and the PI comes with Debian – not Ubuntu!  However – reporting this for the record. Idling power (depending on operating system as little as 1 watt (i.e. 200ma at 5v). Headers for 3  USB 2.0 ports (but no connectors) 512MB RAM and finally a DVP camera interface. Connectors include UART, SPI, I2C, GPIO, IR, SPDIF and I2S (though actually making use of these will be down to software support!)

Here’s a handy pinout:


The whole thing weighs less that 10gms.  I’m thinking this could well make a minimal system for talking to Alexa DOT – perhaps with some IO all in one tiny box!!

tmp23CAA heatsink was provided but no box – but then again any box would probably be of a height to accommodate connectors and I’d really like to see this in a super thin box – or even on the back of a Nextion display.

I note that another blog has covered the use of the board with the Ubuntu operation system so I won’t get into that here.

Note the micro SD connector bottom left in this photo and the power connector/ OTG port top right. There is also a separate 4-way connector for serial debugging.

I tried to use one of my NEO SDs with DIETPI but the software worked – but without WIFI – I could not see a way to fix that and have written to the  DIETPI site in case their software can be updated. That would be good.

Meanwhile I’ve just tried the latest ARMBIAN – blew the SD – popped it in – it works – (serial monitor) – went into NMTUI (command line WIFI etc. etc.) – works a treat. How there is NO mention of Bluetooth in that setup but as I don’t need that right now I’m not too bothered. One of our readers has already commented “No Bluetooth” so I’m guessing that remains off the table for now. I could of course use FriendlyArm’s image but that means re-jigging my script with umpteen installs which probably would not work. Erm, no.

Right now I’m in the middle of running my script from the serial terminal. WinSCP works with an IP address (it would be so much better if Samba were installed from the start so that the domain name worked) and I have noticed that when bringing up a terminal, it is SLOW – I suspect that is down to the WIFI signal – I noted when using Armbian in the past that the WIFI was not that hot on other boards – using DIETPI on he NEO it was marvellous – but that’s not working for the AIR so far.

I did note earlier that the TIME was wrong on the unit (no doubt an issue with Armbian) as it said the last log-in was November 1st – it is November 7th and I’ve only just installed Armbian.

Accordingly my script has been sitting here in a loop complaining that “binding.gyp has a modification time 180293 in the future” and it looked like it was going to sit there and wait that long! As I write this I’ve used the DATE command and all came along nicely if slightly more slowly than normal. First time I’ve ever had that date issue.

And while all of this was going on – the board was only just warm, certainly not warm enough to warrant a heatsink.

HOWEVER – initial impressions – once my script was done.. WINSCP – slow as a DOG. Not remotely in the same league as a typical Raspberry Pi – or even the NEO - HOWEVER - According to TKAISER of Armbian this is because the board needs an external aerial – which begs the question – why didn’t that come with the board!! On close inspection there is no internal aerial… dohhh…..

Update Nov 08, 2016: Ok, aerials on the way – I’m using it with a GPS aerial which is hardly ideal and the WIFI seems solid enough. I hope the proper aerials are small!! I read elsewhere that the chip used is the Ampak AP6212 as used on  Raspberry Pi 3 and there’s a link to more info on that… ( Still running cool enough to NOT need a heatsink.

Update Nov 11, 2016: While waiting for the aerials – and in another blog, TKaiser of Armbian just happened to mention they have a utility to copy an SD setup to eMMC.  It is part of the standard installation and is:


So I ran it in a terminal and after a while – it told me to reboot without the SD. I did that and LO – not only a working AIR but a much faster AIR. I took the SD, inserted it into the other board, booted up – repeated the operation – and lO – TWO working AIRS– a quick change of name of one of them and Bob’s your uncle! Well impressed!

Update Dec 20, 2016: Here's a thing. After not using the Neo for a little while, last night I decided to do an apt-get update/upgrade. The update failed due to inability to contact some sources. I tried 3 or 4 times - no joy. I decided that either the WIFI was in trouble or a source was offline and to leave it until this morning.  I got up this morning and the update was fine.. but when it came to the upgrade, I got a message to say the disk was full.  8GB of eMMC - i was sure I'd only used half of that.  Anyway I went off searching - and discovered several large LOG files - deleted the larger onces and now all is well - I've recovered over 2GB of log space. Hmm.


I2C Expansion for Pi and ESP8266

Pi ExpansionWant 64 GPIO pins on your ESP8266 or Raspberry Pi? Read on.

If like me you are not THAT familiar with I2c, you might find the results of my  experiments interesting and perhaps even useful.

If like me you are not THAT familiar with I2c, you might find the results of my  experiments interesting and perhaps even useful.

PCF8574TSo I bought a couple of these i2c port expanders from China – mainly because I wanted something simple to mess with i2c on the ESP8266. It occurred to me that if I could get these working on a Pi, so I was sure of the addresses and commands etc., then on the ESP, I’d then get the confidence to do something more dramatic on the ESP8266 with i2c.

So ignoring for a minute the interrupt capability, these are pretty basic devices – using up 2 port bits (SDA and SCL) on your Pi or ESP, send an i2c start to them followed by an address then a byte to them – and the outputs light up accordingly. Set the outputs to 255 and read back a byte and you get the state of the pins as inputs. It doesn’t get any easier.

Well, not unless you completely mis-interpret the addressing as I did and spend ages chattering away to the wrong address. Anyway, let’s not dwell on that.

I noted that the outputs are HIGH by default.  Also note that in my experiments I have set the 3 DIP switches to ON (NOT as in the photo above).

Armed with the latest version of Raspbian Jessie on a pi2 or Pi3, connect ground on the device to ground on the Pi, VCC to 3v3 on the Pi, SDA to SDA (blue) on the Pi, SCL to SCL on the Pi. Simples. The boards have built-in pull-up resistors for i2c (which could pose an issue if you parallel a bunch of them up of course) so that’s it – no other new components needed other than a LED for testing. I used a 470r resistor in series with the LED.

Open a terminal on the Pi and type:

sudo pigpiod

That starts the new GPIO library daemon running in the background.

Now here is a short file that will set all the outputs to 0 – running Python…

import pigpio

pi1 = pigpio.pi()
pi1.write(18, 0)


Nice but then my pal Peter Oakes pointed out to me that I’d end up loading the entire Python environment  every time I wanted to change an output.. so I started experimenting with C code… just turning GPIO18 (on the Pi) on and off for starters…. see the line that says gpioWrite(18,0);  that turns the port off. Substitute a “1” to get the opposite effect.   All of this worked a treat.. “b” here ends up containing a handle.

#include <pigpio.h>
#include <stdio.h>

void main()
if (gpioInitialise() < 0)
puts("erm no"); // pigpio initialisation failed.
gpioSetMode(18, PI_OUTPUT);
// pigpio initialised okay.
gpioWrite(18, 0);

The code above once compiled failed the first time – I realised you must NOT have the daemon running when using this. so a quick reboot later and I was in business.

Oh, here’s how to compile a simple C program like that – make sure it’s a text file, say in your /home/pi directory.

gcc -Wall -pthread -o prog prog.c -lpigpiod_if2 –lrt

See where it says “prog” – change that to the name of your program. Takes seconds.

Anyway, I was just about to set everything up in C for i2c etc. when I discovered… PIGS

sudo pigpiod
pigs w 18 0
pigs w 18 1

Note – no sudo needed for the commands and presumably one would run that daemon (pigpiod) at startup. This looked like a nice simple route – dead easy for Node-Red as you can just issue the commands in an EXEC function and pass the parameters in the payload – so next would be to try i2c….

pigs i2co 1 39 0
pigs i2cwb 0 0 0
pigs i2cwb 0 0 255
pigs i2cwb 0 0 1
pigs i2cwb 0 0 2
pigs i2cc 0

The first command visually returned 0 – hence my use of 0 later in the code as the “handle”. I order, I set the expander to all off, all on, then the first bit only on – then the second bit only on and finally I closed the handle.

Something to note is that I2c lines need pull-up resistors – and this board has them already built in – unfortunately they are 1k pullups – fine if you only have one board, not a lot of use if you want to put several in parallel. After discussion we think that possibly the two relevant resistors might be replaced by 10k in which case you could then run several in parallel (with different addresses) but we’ve not tested that.

Oh, making that daemon permanent… I did that with a command line edit “sudo nano /etc/rc.local” -  and added the line “sudo /usr/bin/pigpiod” – and rebooted…. no problem.

Update November 9, 2016

The final stage of this experiment gives my ESP8266 software the ability to achieve the same thing, losing 2 wires to get 64 new ones (YES, 64), a net benefit of 62 I/O lines, could be worthwhile as the ESP8266 isn’t exactly brimming with IO lines.


Above you see (blue) our ESP-12 board, fastened to an FTDI for power, and wired by jumper to one of the PCF8574T boards - clearly you'd need 8 of them to get 64 lines and I'd be wary as they have pullup resistors on the data lines. I'd remove them on all but one.

With a typical Chinese PCF8574T board which includes pullups, I’ve added new commands to the ESP8266 Home Control software as of my software version 1.6.52 – the xport command.



sets the lowest bit of the first (address 39) expander high (the 0 is a mandatory argument above – see future blogs) whereas:


returns the state of the first (LSB) bit of the first of up to 64 bits.

On power up these devices are HIGH - and the software defaults to high on power up. If you mess with a port bit, you need to set a bit high before you can use it as an input. Here is the datasheet for this chip – and here is a typical Chinese expansion board.  With GPIO4 on our little boards hooked to SCL and GPIO5 hooked to SDA – the new commands work a treat.

In the above photo – address 39 equates to all DIP switches set to ON (that’s high or 7). If you set number 3 to off – that is address 38 (bits 8-15) etc. (simple binary selections – you can make the device work as anything from 32 (all switches OFF) to 39 (all switches ON) but before you go connecting eight of them up – bear in mind the comments about pull-ups above.

I’ve been doing a little more on these as you’ll see in other parts of the blog – but the upshot is – you have to ask yourself if these are worth the money. In my original blog I pointed to an Ebay price of £2.35  - but in fact from AliExpress they are only £1.20 and so I’ve amended the link in the blog accordingly.  However as you’ll see in other blog items – as I’ve learned I’ve realised they are not necessarily the best bet. I’ve now made a simple “Nano i2c peripheral” from a Nano board – and they cost just a few pence more – but you can make  NOT only an 8-bit expander but also get some A/D, some PWM and some A/D thrown in – hell I’m even putting an LCD display driver in just for the sake of it – and I’ll call it the kitchen sink peripheral.

However if you do like the look of these chips, you’ll note they say they work on 100Khz I2c. That of course is true and I’ve not experimented with anything other than close up – lets say less than 250mm away – but I’m currently running them a HELL of a lot faster than that. I’ve only speeded up the clock for writes and reads – note the wide bits around the edges but still – quite nippy.

faster I2c

Hope you found the above useful. For more information on the ESP software – go to the relevant page on the blog. There is of course the main Home Control 2016 page.


Toying with HA-BRIDGE

Thanks to readers in here I’m having a play with HA-Bridge to act as a device gateway between my home control (generally ESP8266) devices and Amazon Echo.

I’m only scratching the surface and haven’t gotten past “Alexa, turn X on”, “Alexa turn X off” and “Alexa set X to 30%”  but it’s a start and hopefully someone in here will fill in the blanks.

So, assuming you have an Amazon DOT or Echo (at £49 the DOT is the best toy I’ve bought for ages – just bought another one for the house – as this one is hiding in my office)…

The BEST way to control gadgets by voice up to now IMHO is using our own Node-Red software and an HTTPS certificate – but then – it’s not trivial as has been discussed elsewhere (unless you’ve done it before) to get the HTTPS and Amazon talking to each other.

So I played with simpler solutions (I like to try everything) but just recently decided to have a go at HA-Bridge – now – this IS EASY if you don’t go to the wrong repository etc…

First things first – Aidan was playing with this and he could not get anywhere as he had an old version of JAVA on his Raspberry Pi – he solved THAT problem as such. I found that I had to use root access for ALL of the code below.

[pcsh lang="bash" tab_size="4" message="" hl_lines="" provider="manual"]

    echo "deb xenial main" | sudo tee /etc/apt/sources.list.d/webupd8team-java.list
    echo "deb-src xenial main" | sudo tee -a /etc/apt/sources.list.d/webupd8team-java.list
    sudo apt-key adv --keyserver hkp:// --recv-keys EEA14886
    sudo apt-get update
    sudo apt-get install oracle-java8-installer


So that's Java up to version 8. On a NEO AIR I got an error message when running “java –version” until I rebooted.

Now to install HA-Bridge - easy -  go to your PI directory on the Pi or similar - make a directory - called, say, "habridge" - and enter that directory. I grabbed the JAVA file directly in Windows and copied it across-  giving it execute permissions - not sure if that was necessary but I'm just repeating what I did.

All I did was grab the JAVA file from here.

So the general idea is that this Java file will run - and give you a web page in which you can create and run "devices" that the Dot or the Echo will recognise. But it will want to use Port 80 by default (normal web page port) and I of course have a web server there...  I tried running it - failed due to lack of permissions - so I ran it as ROOT - that failed due to the port being in use.

sudo java -jar -Dserver.port=82 ha-bridge-3.2.2.jar

I ran this - note the reference to port 82 - and lo - it works - ok - another matter getting it to run from power up but we’ll come to that.

Ok so THEN I discovered that my MQTT installation – Mosquitto did not include the client tools… so…

sudo apt-get install mosquitto mosquitto-clients -y

Off I went to a browser :

HA Bridge

Ok, here's the bit that floored me - this might save you a little work. I used MANUAL ADD to add these devices - here's one of them... these will respond to on, off and a value - and send MQTT messages accordingly. That's it - all you then have to do is tell Alexa to search for new devices - and use them.

So what we have here is only marginally better than the simple node-red node - i.e. we now have % lighting control - who is going to show us how to develop this to do temperature and other stuff!

HA Bridge

If you don't need user and password for your MQTT  (-P and –u) - don't use them.

The only thing that appears fairly useless is the middle item - intensity control - which could be used for lighting or heating. So "turn office television to 25" works - you get the value 25. "turn office television up" or "down" shifts the value by around 25% - and that's GREAT for lighting but no use for heating - I would want an actual value to set the heating to that value - but up and down to shift the temperature by - maybe 1 degree.

You can in fact say “turn X up by one”.

SO - easy voice control - create lots of devices... this whole operation other than blogging it took merely a few minutes and thanks to readers who pointed me in this direction.

This software does not seem able to control responses – you get “OK”  - how then would you ASK the thermometer to return it’s current value!?!?! Well, you can’t so there is still life in our HTTPS solution – but this is VERY easy to set up.

Having now followed the instructions here and here (see “writing a unit file in the latter link) made a “unit” startup file – I now have the whole thing running from power-up on the same Pi that runs Node-Red and Mosquitto.

Essentially here’s what I ran having created a UNIT file as per the first of those two links above.

sudo systemctl enable habridge.service

sudo systemctl  start habridge.service

That’s it – program runs – survives power cycle.

Here’s another explanation of how to do this!

So much to learn, so little time.



This is NEAT – reader Jay brought this to my attention this afternoon – here’s the link. So Netdata is a system monitoring tool – but better than any I’ve seen up to now – certainly on the Raspberry Pi – so I simply followed the instructions in that link, took all of 5 mins and no effort and….. at port 19999…


Noooo, that’s not all – there’s miles and miles of it… live data. CPU, load, disks, ram, networks, processes, interrupts, softIRQs – the list (on the right – not shown here) goes on and on.. Really nice web display of useful info. Enjoy (It isn’t Raspberry Pi specific).




Ok, this entry will be in 2 parts – I’ll do some digging soon – but as I’ve had several requests for this…

POW, TH16 and DUAL

So what you’re looking at above are the Sonoff Pow, TH16 and DUAL mains controllers. These are ESP8266-based low cost controllers to turn things on and off. The TH16 has a sister product, the TH10 and we covered these a while ago. Now complete with CE markings (which we are told does NOT mean China Engineering before anyone steps in to defend British manufacturing…. and looking quite spiffy.

POW, TH16 and DUAL

Ok, critical bits first, I’m not convinced about the push to connect stuff inside – I know it is fashionable to do away with screwdrivers but hell, you need a screwdriver to get into the thing in the first place  and those push to fit jobs work GREAT with single-core wire – not quite so well with multi-strand, depending on the thickness. Also due to the case design the connectors at the ends could be a tad tricky to sort in a dark cupboard – however, generally very well built.

Note that all three have a proper fuse inside which is really nice to see – and two of them have 16 amp relays – the DUAL having a couple of 10 amp relays.

POW, TH16 and DUAL

Note also that they all have the 4 way programming connector at the top left in these photos. Vcc I should note is 3v3 and not 5v. I usually manage to reprogram them straight from a 3v3 FTDI but it is pushing it a bit.

The ESP8266, FLASH and other bits are on the underside of these boards but if you’re just programming them – then you need go no further as the large button on the top is GPIO0 and hence you can use that for programming. I have programmed the TH16 and 16 extensively, the Dual and the POW are delights I have yet to tackle – the POW in particular as right now I’ve no idea how to read the power chip.

But of course you can use these out of the box with the Expressif cloud to control things. We’ve had the discussion in the past about power, I would not take the 16 amps too literally nor the 10amps – maybe keep the maximum power 25% under what is being claimed – though the tracks are quite thick. Of all the boards of this type I’ve seen – these seem to be about the best put-together.

POW, TH16 and DUAL

on the rightmost image – I’m pretty sure that piece of copper in the middle is the power sensor and there appears to be an 8-pin control chip above it and to the right. Other than that they are much the same… note the nice cutouts in the board, decent spacing and thick tracks for power. A lot of designers could learn from this.  My only gripe is their continued use of a tiny FLASH chip… HOWEVER, here’s a thing – in the old boards, the FLASH chip was on the top – partially obscured by the programming button – NOW it is on the bottom – which should make it one hell of a lot easier to replace – WHEEEEEEEE. I do note two different sizes of FLASH – note the two boards on the right – topmost right 8-pin chip. Last time I tried updating a TH16 I ripped the tracks to bits – now – I might just be able to do it – and the chips I bought are the bigger size. Mind you my biggest problem is more basic – having shipped all my stuff from Spain to the UK for the winter I now have to FIND my supply of SMT flash chips!

More soon on this one but I thought I’d give you a head’s up.  To give you an idea of pricing – here’s the page for the TH10 and 16 -   - they have gone up in price since the early days so just under £7 plus postage for the TH16 – probably a good idea to buy a few – but WAY less than anywhere else as far as I know. I have one of the original boards controlling an electric heater in my office and another controlling the likes of salt and room lights at home and they’ve been happily working away all summer.

As for pricing – with this link you get discount (don’t worry I don’t get anything) – and by the look of it – a shipment of one POW to the UK is (in dollars as their site screws up pounds) $8.62 for the DUAL and $4.62 postage… You are better off buying TWO as the postage is only another dollar..  all of this if you translate to Sterling – even with the atrocious state of the pound – is still cheap.

There is a link for the POW but I think they are out of stock right now.

So – you have these  - and you can use their built in software – or you can roll your own. Our own software handles the TH10 and TH16 but not yet the DUAL and POW (note that the DUAL for reasons best known to ITEAD has a 4MB Flash whereas the others have smaller FLASH). If you’re in a hurry – here’s a link to a fellow who has done the hard work – and who is very responsive – if you’re an Arduino/ESP type – this might be of interest. 

4 Channel WiFi Wireless Switch  IM160920099 – blogged elsewhere

And coming up soon – writeups on:

Sonoff Touch EU
sonoff LED


The Light Fantastic

CY-30 Light SensorThis morning, a long-forgotten package turned up for me – a cheap but accurate light level sensor from China – claimed to be around 1 lux accuracy and giving a direct output in lux. A small board is available here in Britain for around £4 or the identical board from China for 98 pence. I chose the latter. It is called the GY-30 board.

The tiny board comes complete with connector which takes seconds to solder on (I put mine on the underside). There is an address line which does not need connecting and the I2c has pull-up resistors already in place so basically you provide ground, 3v3 and I2c.

I plugged this into one of our ESP826 boards and did the I2c search – it came back with device 35 (0x23).

The documentation has various modes but unless you are power saving (in which case the ESP8266 might not be your best call) you can just leave the thing on converting at high resolution 0-65k. I wrote two functions – one to initialise the I2c and to start the conversion off – the other function to read back the 16 bit value from the device.

tmpC1DBAt maximum resolution, you have to leave around 180ms between readings and of course it won’t start the next check until you read it so the best thing to do is just grab the readings maybe every few seconds depending on your application (once every 15 minutes would do me) and store it away somewhere.

Anyway I’ve added the code to the house control code – boards suitably updated (v1.6.50 or higher) can issue {gy30_init:35} and {gy30_read:35} commands. If you cover the sensor with your hand you will typically get a value of 4 or less. Ambient light in my office produces around 80-100 and pointing the unit up to the lights produces a reading of around 1000. Don’t ask me to do a sunlight test – wrong time of the year here in the frozen wastes of the Northeast of England.

I do plan to stick one in the window and log it – so when I’m off in Spain and people back here are saying “oh, it’s lovely and bright here” I can tell if they are telling fibs. Check out the blog entries on home control 2016, flashing the code for more info.