Alexa Node Red and SSL

It’s running. I’m very chuffed. Yesterday I picked up my Amazon Dot – which is basically the big ECHO unit without the big speaker – it has a little one instead.

Before I go any further – let me backtrack for those who’ve been in – well, a cave or something – what the hell is Alexa? Ok, you’ve seen SIRI and OK GOOGLE etc. and probably talked to one or the other. Well, this is better. A LOT better. This is the fore-runner of the companion you’ll be talking to when you get old!

So the Amazon Echo is a box with a speaker that plugs into the wall, hooks into your WIFI and you talk to it and it talks back. The Dot is the same thing, third the price – without the big speaker. It has a small speaker, you can plug another speaker into it or hook to a Bluetooth speaker.

So far so good. But why would you spend £45 on that?

The unit has a microphone “array” – all you need to know is that when it is blasting music – it can still hear you! If you happen to have an Amazon Prime account or a full Spotify account – you can say things like “Alexa, play some Pink Floyd”. Now that might not seem like much – but trust me – this is going to be a party trick for MONTHS. No you can’t play your own stuff – well, that’s probably  not strictly true – depends how clever you are.

Ok, so we have a talking, listening music centre? Is that it? HELL NO!!! Alexa can handle everything including  “what is the meaning of life”

But where it gets really exciting and frustrating at the same time is when you realise you can attach it to NODE-RED and have it control your house – securely. Where’s the frustrating bit? The HTTPS: bit… it won’t work without it (don’t even DREAM of mentioning certain sites that only work in America or those who are still talking about deprecated code). Well, the good news is that today we tackled this and cracked it and we have this now working in Node-Red without any special libraries and when you see it you’ll immediately realise the fantastic potential – heating, lighting, security, kettle boiling and other important items – all within grasp. Take a Raspberry Pi and a speaker amp and a microphone array and a power supply and a case and spend £60+ or just buy the DOT at £45 !!! The alternatives simply are not worth it as far as I can see.

No – not easy at first – which is why Aidan and I plan to sit down to document the lot. In reality – it should be possible to reduce the whole procedure to half an hour and the cost to a few quid a year. Right now I have everything in front of me and it is merely down to some trivial coding to get my various heating systems, lighting systems and the rest on voice control. My next job after writing this preliminary blog – is to order another DOT.

About the only down side up to now – is the ATTROCIOUS Amazon music library which is as much use as an Ashtray on a motorbike. No AC/DC – WHAT!!!!?!?!?!?!?!? Clearly if not on a budget – Spotify must be worth the investment.

Alexa – play “I’m not in love”



A Quickie on Itead and CE

I recall a couple of questions in earlier blogs about Itead (Sonoff) and CE. Well, they’ve just written to me to confirm that “CE marking on Sonoff products does mean Conformity European, not China Export.” which should set some minds at ease – they also sent me the test reports.

I’m sitting on a Sonoff Dual, a Sonoff POW and a Sonoff TH16 here. Right now my Amazon DOT has turned up – I’ve just got it hooked into their music system and having great fun – next step is to figure out how to get a cheap SSL certificate running on the Pi so I can use the Node-Red-Contrib-Alexa – that will likely happen tomorrow – THEN I’ll get around to dismantling these Sonoff units and let you know a little more about them.


Another Weekend of Experiments

I’ve just been up to Northern Spain with a friend and our wives looking at some property up there  and when we got to our hotel and got the wine open, Aidan showed me his new toy – Amazon Echo.

The Echo Moment

EchoWell, I was so excited I’ve ordered the new Dot which should turn up next week – after all my failed experiments with Google Now and Microsoft’s  Cortana trying to fire text at Node-Red so I could control things, this might just do the job – but that is something for next week.

FabriqOf course – you could always hang around and wait for the forthcoming  fluffy version called FABRIQ – which appears to be rechargeable – but no mention of microphone arrays so you take pot luck on how good the audio capture is. You could even take the kit route with Seeed’s ReSpeaker – but by the time you add up the cost of ReSpeaker and the microphone array… well, I’m wondering if they’ve lost the plot. They sent me a ReSpeaker to play with minus the microphones – I nearly choked when I saw the additional cost. If you have an Amazon account you can play with Alexa here.

I’ve not had a lot of luck with the Raspberry Pi versions, one only works in the USA, others are out of date and require button presses… anyway I’ve ordered a USA mic any my DOT turns up next week so maybe in a couple of weeks this will start to fly at this end.

We came back to the cave on Friday and yesterday  my friend Jonathan rang me up full of new stuff he’s been playing with.

Glasswire and Divvy

So first things first – for Windows enthusiasts – check out GLASSWIRE. I have it sitting here making pretty graphs of my network – I’m not saying it is any good – I’m saying it is extremely pretty and possibly deserves a corner of your desktop. Something else you might like to play with is DIVVY from MIZAGE. I’ll leave you to look those up. I found them interesting.

Meanwhile as some of you know I’ve been experimenting with Armbian on my little Nanopi NEO. Lovely operating system and I managed to get my script working on it no problem – but for one thing – WIFI  – the NEO doesn’t have WIFI and so you have to stick one of those cheap Chinese WIFI dongles in – and on most of the SBC boards I’ve tried – no problem. However after jumping through some hoops to get the WIFI working on this little Neo board – I was very disappointed – WIFI performance was so poor you could see delays when doing the likes of apt-get update etc. I wrote off to the Armbian forum and the response was along the lines of “you should try an Orange Pi Lite if you want WIFI” – well that’s all very nice but I already have two NEOs.

Well, I was sitting getting depressed  about this when my friend Jonathan rang me up with some new things to try.

WinDiskManager and Etcher

EtcherSo first things first – you know that Win32DiskImager that everyone uses to FLASH Linux SDs – he’s spotted something not only a little faster but a little nicer looking called Etcher – so the first useful takeaway from this blog entry is Etcher. I installed it on my Windows 10 64-bit system no problem – none of your “administrator-only” stuff – and Etcher works  – point it to an image file – and it flashes it to SD!! Mind you that’s ALL it does.  If you need to READ images onto your PC you still need Win32DiskManager.

The DietPi Moment

He then reminded me that before I was playing with Armbian I’d had a go at DietPi for the Raspberry Pi.  It only worked on the Pi itself –  it was a nice, lean installation of Debian – but hey – the normal Pi setup was fine – so I put Diet-Pi to one side.

WELL – take a look at DietPi today – it is no longer for the Pi only – and it can install lots of goodies – kind of complimentary to my script (with a nicer interface).  And in the process of this conversation I noted it has a setup for the NEO and other FriendlyArm boards.

NanoPi NEO using DietPiWell, wouldn’t you know it – there’s a menu driven setup for WIFI – and it WORKS!!! And the funny thing is – the designer credits Armbian – WELL!!  Ok, so there’s a LOT more to this and I’m only at the beginning – I noted that this Diet-Pi on the NEO seems to run even faster than the hardwired version on Armbian – and I’m only at the surface of finding out why – but one reason it seems nippy is you have full control over logging – which by default is running in RAM and at a minimal – a very sensible starting point. 

In the process of setting things up I discovered some sillies in my script (which takes a basic Debian setup and installs a while raft of useful goodies centred around Node-Red) and I’ve fixed those.

I have now run my updated script on DietPi on the NEO and M2 and up to now everything seems to work  – and it’s a small installation for a small board – and nippy… I need to go way more deeply into this –  there is SO much in Diet-Pi now but I’ve no idea how much of it actually works – I DO know that not everything works on all boards but as I’ve only installed this on the FriendlyArm M2 and NEO I’ll keep my mouth shut except to say I’m mildly enthusiastic – my little NEOs are now useful wireless devices – which is a great step forward.

Node-Red on NEO

Experiments above with Node-Red, MQTT and serial – all working.  And below – with a simple mod – a nice colour terminal… all on my NEO soon to be replicated on M2 and T2.


Now there DO seem to be some issues with DietPi – I’ve reported them – on a real Pi the serial port needs permissions altering to work (added to script just for belt and braces) – and on all installations, Mosquitto fails to run at power up – MAYBE starting too early I don’t know but taking a line out of the RESTART bit of the start-up script and putting it in /etc/rc.local does the job. 

Up to now everything seems ok and I’m working with MrShark  to looking toward the lightweight LIGHTTPD..  we’ve already improved my script – and you know how it goes – once someone triggers you off…

More of that soon – for now – I have my script (as of today) running (with the caveats above) on a Pi2, M2, NEO and BananaPiM2 – and that’s only due to restricted time… DietPi has the advantage of making a MUCH smaller footprint at under 2GB compared to nearly twice that on, say a standard Pi – as there is only in there what’s needed.

Oh while I think on, here’s the link to my original Neo article.

Expect to hear more about this in the coming week – I’m off now travelling with my wife and 3 cats ALL the way up Spain – 24 hour ferry – ALL the way up England… you won’t hear anything from me in here as I’ve not mastered blogging on a phone Smile

.By now Aidan has his Alexa turning his lights on and off via Node-Red and so that will be the next job – integrating this whole lot together.


Variable Persistence in Node-Red

It is my understanding that Node-Red will eventually have persistent variables – but while we’re waiting – this is how I do it. Using the global.get and global.set mechanisms, I store a single object.

So – when Node-Red pops up it looks to the SD for that object – if not there it creates and initialises it. If there, it reads it into the struct. There is a countdown timer in the object and the function controlling all of this is called every 5 seconds. If the counter is zero, nothing happens. If the counter is true, it is decremented. If it gets to zero, the object is saved to disk over-writing the original.  It is that simple and it has worked for me for a long time now.

So imagine a Node-Red user function – with a 5 second timer feeding it (the INJECT NODE) – the payload of the latter is irrelevant.

Here’s the function – the object and it’s internal bits are mine – you’d alter them for whatever you need.

/ The purpose of this code is to update an object on change. At power up check for file and create if necessary
// var is "intel" in this case
var fs = global.get("fs");
var fl="/home/pi/";

if (global.get("intel")!==undefined) // Remember - don't use !== with null
        if (global.get("intel.Counter")!==0) // if the var exists - now check counter
         global.set("intel.Counter",global.get("intel.Counter")-1); // if counter is non-zero - decrement it
         if (global.get("intel.Counter")===0)  // if counter drops to zero update file
                   fs.writeFile(fl, JSON.stringify(global.get("intel")), function(err) {
                    if(err) {
                        return console.log(err);
    {   // If no var (powerup scenario) ..does the file exist?
        try {
                fs.accessSync(fl, fs.F_OK);
                // If file exists create the VAR by reading the file into it
                fs.readFile(fl, 'utf8', function (err,data) {
                  if (err) {
                    return console.log(err);
            } catch (e) 
                // Otherwise create both var AND file -  ensuring counter is zero. New bits can be added dynamically
                intel = {
                        Counter : 0
                    fs.writeFile(fl, JSON.stringify(intel), function(err) {
                    if(err) {
                        return console.log(err);




Node Red Sunday

Node-RedIt is Sunday, I’ve done my 4,000 steps down to the village for coffee and back and I’m having a play.

I use Node-Red on a Raspberry Pi to control just about everything in two houses – as my confidence in the setup has grown, I’m currently keeping the Pi up 24/7 with no sign of any issues (well, it could ALWAYS be faster). Normally I control the likes of ESP8266 boards with this to do everything from monitoring temperature, pressure and humidity to controlling heating, fans, lights and more.

It occurred to me, as I’ve also had success with my script in getting Node-Red, Sqlite, MQTT and other software running on other SBCs including the really cheap new ones coming out of the woodwork that it would be nice to be able to talk to them with the same software especially those running Armbian as I’ve had a lot of success with that personally.

So I’ve made a start. I thought you might find this preliminary effort interesting.

In my controllers, MQTT is at the heart of everything and facilitates utterly reliable message sending from device to Pi and Pi to device (indeed there is no reason I could not do device to device really). I thought it might be nice to start off with a little bit of code that simulates what the ESP8266s do constantly – turn things on and off.

So typically, given a device called fred, I might turn a relay on or off using MQTT messages:

topic: fred/toesp
payload: {out0:1}

Let me first explain why I do it this way. So MQTT typically works by sending simple messages back and forth – they have a topic (address) and a payload (data).  My devices, for example fred, listen for two topics:


That way I can send a message to a SPECIFIC device – or to all of them at once (OTA for example)

If the device needs to send messages back they will always be of the form:


in this case the payload returned would be the current state of out0.

So that represents the basics. Here I will show how a cheap controller running Node-Red can accept commands – I won’t go into the actual mechanics of turning a light on and off because for example the GPIO commands used in a Raspberry Pi won’t work on a NanoPi NEO – alternative methods are used. I’ll simply cover how to get to that point.

So here is the simplest possible setup on the Pi, to turn a couple of outputs on and off.


This is nothing more than 4 INJECT nodes dropped onto a flow along with an MQTT output. Typically the content of one of these nodes might be:


Simple enough. When pressed the node outputs a topic of nanopineo2/toesp and a payload of {out0:1}

This would work with one of my ESP8266 units to turn output 0 on. “nanopineo2” is just the name of one of my NEO units running Node-Red.

Here’s what’s at the other end to make this work.

Nanopi Neo

Two MQTT inputs feeding a function. So the function will work if either the generic “toesp” is called or a device-specific version. In that first function I check out the command – really simple – and will be dramatically improved soon.

// An attempt over time to emulate my code in ESP8266 - taking commands from MQTT
// and processing I/O
// for example message {out26:1}

var m=msg.payload;

if ((m.charAt(m.length-1)=="}") && (m.charAt(0)=="{")) // ignore if not in braces
    m = m.substring(1, m.length-1);
    var breakup=m.split(":");
    var getname=breakup[0];
    var sendto=breakup[1].split(",")
    switch (getname)
    case 'out0' :  msg.topic='out0'; msg.payload=sendto[0]; node.send(msg); break;
    case 'out1' :  msg.topic='out1'; msg.payload=sendto[0]; node.send(msg); break;
    default: break;

The output is reduced to the actual command “out0” for example – and a value. So the next item is a switch in this case selecting “out0” or “out1” and ignoring everything else. The outputs from that switch go to functions which simulate actually controlling something – like a LED for example and in my demo the colour of the black dot changes from black to red when you send a command to turn that output on.

if (msg.payload==1)
      msg.payload="lamp1.val=100"; node.send(msg); 
      msg.payload="lamp1.val=0"; node.send(msg); 

And that is it for now. As you can see, this can RAPIDLY be expanded to cover every port bit available on your micro, it could control PWM etc. The next step will be to take {command:arg1,arg2….arg6} and parse the arguments into an array. That will then allow PWM and other kind of controls. If you really don’t care about pricing you could do the whole lot with a bunch of Raspberry Pis… but with new Orange Pi boards coming out at under a tenner, the options are endless.


IOT Manager Revisited

This started off as a very short blog some time ago – you’ll see  comments below but I’ve re-written it. I occasionally like to revisit stuff I have reviewed or played with ages ago because, well, things change. Had I not persevered with ImperiHome I would not now have a perfectly good IOT controller on my phone as originally it did not support Node-Red (Peter Oakes and I soon fixed that – documented elsewhere) and that package is now my preferred central control tool (the fact that it is now bog-standard fitment on the world’s most popular SBC – the Raspberry Pi – is another good reason to stick with it).

(Some regular readers may ask – what happened to BLYNK? – well,  it is still running back in the UK reliably – has been doing so for nearly 6 months – I just happen to prefer Imperihome).

IOT ManagerSo, IOT Manager is a weird one – the programming is different to many of the systems out there which try to be all things to all people – supporting endless devices many of which will no doubt bite the dust in time and it is not yet as advanced as either Blynk or Imperihome, but the author is keen – has done a LOT of changes for me and is rapidly approaching the point where it will compete with the likes of Imperihome.

Let me say that at the time of writing you need the BETA version of IOT Manager to get the best out of it. Joinging the beta program is trivial.

So on first revisiting IOT Manager, could I HELL remember how to use it.  One of it’s original “features” was support for websockets for MQTT – fine – but it ran rather slowly and I think that’s one reason I abandoned it – so when I noted that it now also supports MQTT directly – with username and password – and figured I’d give it another shot.

So I loaded up the Android App and filled in my MQTT broker details and… nothing. Try as I might I could not figure out how to add a widget. All I had was a screen that said “no data” and a green indicator showing that it was indeed connected to my MQTT server (public address). It didn’t help that the website went on about Arduinos and stuff and really didn’t seem to get to the bottom of how to quickly get started if you didn’t have one of those. The documentation has still not quite caught up with developments.

ChartHaving loaded up IOT Manager there are no settings on the phone to create widgets  – instead, MQTT messages tell it what to do and YOU send those from, for example Node-Red! It’s really easy once you get past that hurdle.

So how the package NOW works is to initially send out a request for updates on the number and details of pages needed – and to ask for details of widgets required.

From then on the phone will request updates on specific page widgets as and when a page is selected or focus is lost. This minimises the information that needs to be sent.

When a button is pressed the info is sent back from the App by MQTT. I’ve chosen to process all of this with Node-Red. Plain NodeJS would no doubt do just as well.

Here is a list of the current widgets which includes sliders and power buttons as well as toggles…

  •       anydata
  •       simple-btn
  •       display-value
  •       small-badge
  •       power-button
  •       range
  •       toggle
  •       SteelSeries
  •       fillgauge
  •       chart

The CHART widget is new and I’ve not yet had time to test it but here’s an example on the right above.

In the example below I have three pages (named page1, page2 and page3). On the first page are two switches and a slider (range7). On the second are 3 level gauges and on page 3 are a couple of thermometer-type displays.

IOT Manager - my Node-Red code - Peter Scargill

This is what they look like…

1[4]  2[4]  3

What we have here is an APP that connects to your MQTT server (or a public one) and at that point sits and does nothing.

Essentially once the phone is connected it is listening to an MQTT subscribe. Your controller – say, Node-Red on a Raspberry Pi or even a simple ESP8266 (but you still need an MQTT broker either locally or a publically-available broker)  when it turns on and connects to the same MQTT broker, sends some init code and magically a bunch of controls appear on the phone – you can then use the controls and they send out info back to Node-Red or whatever you want to use as a central controller. What is great about this is that it could be dynamic – as this is set at the control end, not the App end.

I centralise everything via Node-Red which of course can publish and subscribe to MQTT and then control my devices from there. I decided to write the code for Node-Red to give others a starting point.

So you can see in the diagram above the two SUBSCRIBES. That info is passed to a couple of functions – here they are…

var topic=msg.topic.split("/")[3];
global.set("IoTmanager_" + topic,msg.payload);

And now the second function…

var prefix = "/IoTmanager";
var deviceId = "bedrock";
var config = [];

var pagesList = {
    pages: [
        { pageId: 10, pageName: "page1" },
        { pageId: 20, pageName: "page2" },
        { pageId: 30, pageName: "page3" }

var id = "0";
var widget="toggle";
  config[0] = { 
  id : id,
  page: pagesList.pages[0].pageName, 
  pageId: pagesList.pages[0].pageId,
  descr : "pump 1",
  widget : widget,
  itemstyle : "",
  itemclass : "",
  topic: prefix + "/" + deviceId + "/" + widget + id,
  color : "orange",
  style : ""

  id = "1";
  config[1] = {
  id : id,
  page: pagesList.pages[0].pageName,
  pageId: pagesList.pages[0].pageId,
  descr : "pump 2",
  widget : widget,
  style1 : "",
  class1 : "",
  topic: prefix + "/" + deviceId + "/" + widget + id,
  color : "blue",
  style : ""

  id = "7";
  config[7] = {
  id : id,
  page: pagesList.pages[0].pageName,
  pageId: pagesList.pages[0].pageId,
  descr : "range 1",
  widget : widget,
  topic: prefix + "/" + deviceId + "/" + widget + id,
  color : "blue",
  style1 : "\"style\":\"range-balanced\"",   
  badge1 : "\"badge\":\"badge-balanced\""

  id = "2";
  config[2] = {
  id : id,
  page: pagesList.pages[1].pageName,
  pageId: pagesList.pages[1].pageId,
  widget : widget,
  class1 : "item no-border",
  style1 : "",
  descr  : "Water level",
  class2 : "light text-center",
  style2 : "font-size:24px;font-weight:bold;padding-bottom:5px;",
  topic: prefix + "/" + deviceId + "/" + widget + id,
  width  : "150",
  height : "150",
  class3 : "text-center",
  style3 : "",
  widgetConfig : {

  id = "3";
  config[3] = {
  id : id,
  page: pagesList.pages[1].pageName,
  pageId: pagesList.pages[1].pageId,
  widget : widget,
  class1 : "no-border text-center col-xs-4",
  style1 : "",
  descr  : "Fuel level",
  class2 : "assertive text-center",
  style2 : "font-size:14px;padding-bottom:5px;",
  topic: prefix + "/" + deviceId + "/" + widget + id,
  width  : "70px",
  height : "70px",
  class3 : "text-center",
  style3 : "",
  widgetConfig : {
    circleColor : "#FF7777",
    textColor : "#FF4444",
    waveTextColor : "#FFAAAA",
    waveColor : "#FFDDDD",
    circleThickness : 0.2,
    textVertPosition : 0.2,
    waveAnimateTime : 1000

  id = "4";
  config[4] = {
  id        : id,
  page: pagesList.pages[1].pageName,
  pageId: pagesList.pages[1].pageId, 
  widget    : widget,
  class1    : "no-border text-center col-xs-4",
  style1    : "",
  descr     : "Water level",
  class2    : "energized",
  style2    : "font-size:14px;padding-bottom:5px;",
  topic: prefix + "/" + deviceId + "/" + widget + id,
  width     : "70px",
  height    : "70px",
  class3    : "text-center",
  style3    : "",
  widgetConfig : {
    circleColor : "#D4AB6A",
    textColor : "#553300",
    waveTextColor : "#805615",
    waveColor : "#AA7D39",
    circleThickness : 0.1,
    circleFillGap : 0.2,
    textVertPosition : 0.8,
    waveAnimateTime : 2000,
    waveHeight : 0.3,
    waveCount : 1

    id = "5";
    config[5] = {
    id     : id,
    page: pagesList.pages[2].pageName,
    pageId: pagesList.pages[2].pageId,
    descr  :"Steel 1",
    widget : widget,
    topic: prefix + "/" + deviceId + "/" + widget + id,
    widgetConfig : {
    width  : "auto",
    height : 100,
    type   : "Linear",
    titleString: "Thermometer 1",
    unitString : "temp C",
    threshold: 90

    id = "6";
    config[6] = {
    id     : id,
    page: pagesList.pages[2].pageName,
    pageId: pagesList.pages[2].pageId,
    descr  :"Steel 2",
    widget : widget,
    topic: prefix + "/" + deviceId + "/" + widget + id,
    widgetConfig : {
    width  : "auto",
    height : 100,
    type   : "Linear",
    titleString: "Humidity 1",
    unitString : "% Hum",
    threshold: 90

// extract command and param
var msg2 = JSON.parse(msg.payload.toString());

if (msg2.command==="getPages")
     msg.topic=prefix + "/" + deviceId + "/response";

else if (msg2.command === "getPageById" && msg2.param > 0) 
                 pagesList.pages.forEach(function(item, i, arr) {
                // it is one of our pages?
                if (item.pageId === msg2.param) {
                    // node.warn('Request is for existing page "' + item.pageName + '", pageId="' + msg2.param + '"');

else if (msg2.command === "getPageById" && msg2.param === 0) 
            //node.warn('Request is for All pages.');

function pubPage(page) {

    // check all widgets and pub widgets config from requested page
    config.forEach(function(item, i, arr) {
        if (item.pageId === page || page === 0) {

            // pub config for one widget
            msg.topic=prefix + "/" + deviceId + "/config";
            //node.warn("Page " + item.pageId + " id " + i);
            // pub status for one widget

function pubStatus(i) {
var status;
switch (i)
        case 0 : status=global.get("IoTmanager_toggle0"); break;
        case 1 : status=global.get("IoTmanager_toggle1"); break;
        case 2 : status=global.get("IoTmanager_fillgauge2"); break;
        case 3 : status=global.get("IoTmanager_fillgauge3"); break;
        case 4 : status=global.get("IoTmanager_fillgauge4"); break;
        case 5 : status=global.get("IoTmanager_steel5"); break;
        case 6 : status=global.get("IoTmanager_steel6"); break;
        case 7 : status=global.get("IoTmanager_range7"); break;

msg.topic=config[i].topic + "/status";
msg.payload=JSON.stringify({ status: status });

As for individual items – well, to turn on or off a switch is as easy as…

var fred=msg.payload;
return msg;

Depending on whether you fire the string “0” or “1” at that function it will turn on or off the switch.

The main function above is comprised mainly of definitions for the various items and you can find out more about them at the author’s site – indeed that IS the place to look in case he changes anything and expect him to add more in future.

So – do we have an up and coming competitor for Blynk and Imperihome? I’ll leave that for you to decide.


Sparkly new Pi

Just a very quick one (and somewhere to park the conversation)– there’s a new Raspberry Pi update out promising a new smoother, simpler look, better video etc. Up to now it looks like the claim is correct.

I have several RPI installations…including TightVNC and so I didn’t want to lose that. I did however, want the Chromium browser. I’m not interested in PI-HATs and similar so here’s all I did to get the upgrade…

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install -y rpi-chromium-mods

That’s it – nothing more –takes a few minutes all in – there is one Y for confirm and a reboot – and Bob’s your uncle. To test things out I went to the BBC website and of course got the usual message about Flash – things haven’t change there much – but with a signup for the BBCs “beta” HTML5 version (it’s a bit late for a beta, isn’t it? HTML5 has been out  for longer than I can remember) all is well, videos no problem!

New Pi Interface

The new interface is to be given it’s own name “PIXEL” – that’ll make searching for information about it a whole lot of fun… they could have picked something unique like “PIXL” or something – however it all seems to work – more modern appearance – slick – file manager is nice and apparently if not faster it is at least no slower than it’s predecessor so really no reason not to go for it.

Here’s the link in case you need more info. Given this new look – with hardware graphics support – which likely means you could be using your Raspberry Pi 3 for a media centre… AND the best backup program out there which can replicate the system even on a different size SD  -something as far as I’m aware NO-ONE else has – one has to ask – what are the other SBC board manufacturers going to do now!!!


Arduino STM32

Having decided I needed a more powerful generic peripheral board than the Arduino, I sent off for some STM32 boards to China – they got lost in the post. Meantime my friend Aidan sent me a nice little black board marked “JM ELECTRONIC STM32F10XC8 SYSTEM BOARD”.

STM32It came complete with miniUSB connector so I plugged it in.  A red light came on and stayed on – and a green light flashed on and off regularly. Always a good start.

I found this link… which suggested I install Arduino Zero into my existing Arduino 1.6.9 IDE setup. Life is never that simple – the nearest I could find in the Arduino boards manager was “Arduino SAMD Boards” – which mentioned Arduino/Genuino Zero.  I installed that.

From here I grabbed the Arduino_STM32 directory from that link to put in \users\pete\my documents\arduino\hardware folder… I’m familiar with this idea as I have my mighty-1284p folder in there already to program the 1284p chips – a powerful more-or-less Arduino compatible chip which sadly never really took off.

I closed the Arduino IDE and re-opened… lovely – except – Windows 10 does not recognise the USB device. I loaded the drivers to no avail… it simply was not having the board yet I had no reason to suspect there was anything wrong with the board itself.

MrShark in here did his best to convince me that the USB connector was not for serial – some places suggested it was – anyway – I decided to assume he was correct on this and instead of using the USB connector, used one of the end connectors which has ground, 3v3, serial in and serial out – attaching them to my normal FTDI.

This PDF document got me part of the way because the board featured within is exactly the same as the board I have (courtesy of Aidan Ruff who bought it from AliExpress – mine is still floating about in the post, is slimmer and half the price – generally it looks like we are talking about 64k of FLASH and 20K of RAM and a BOATLOAD of peripherals).  The connectors indicate that there are various ways to boot  the board. Interestingly you can boot from FLASH, or boot into programming mode or boot from RAM (that’s interesting).  I selected boot into programming mode and sure enough – reset the board, send the program instruction – voila – one programmed board – no warnings, no error messages.

Elsewhere I read that there are 15 pins that can be programmed as 16-bit PWM – a step up from the Arduino. Sure enough I tested this out in the examples – the pins were numbered 0,1,2,3 etc and these equate to A0, A1, A2 etc with 16 being B0 etc.  I tested all 15 pins – and they all do PWM!!! (0, 1, 2, 3, 5, 6, 7, 8, 9, 11, 12, 14, 24, 27, and 28). The instructions in this link refer to the “Maple” – so it may be this is a good source to get started with. The only real difference up to now between this and the Arduino apart from superior PWM is the need to actually set the pin up for this – i.e.

pinMode(9, PWM);

This entry will evolve as I learn more – assuming I can get this board to be an I2c slave it could well be quiet useful.


A busy Week

tostadaIt has been a busy week here in the cave and as well as reviewing the likes of the new Sonoff TH16 units I’ve been doing various improvements – not to mention getting to grips with the VT100 terminal commands, squeezing the best from the somewhat dwindling Spanish heatwave and getting annoyed because the tracking notice says that my highly anticipated STM32 board was delivered weeks ago – which it wasn’t!

So – to the HC2016 home control software, for example, I’ve added a new toggle function for the Sonoffs – and a general toggle function to any of the outputs. I’ve also made the button toggle for Sonoff permanent (i.e. if you toggle a light on – lose power, reconnect – the light will come back on).

On top of that I’ve been working with Aidan on the little NanoPi Neos which are a fantastically cheap little board but FriendlyArm don’t supply Debian for it – thankfully the fellows at Armbian do and we’ve been updating the script to take into account Armbian for the Neo – as of last night (as well as sorting an issue with Webmin that needed updating anyway in the script and adding in some other stuff) the updated script can produce a working NEO (from Armbian (Debian) Jessie base) complete with all the usual tools including Webmin, Node-Red with lots of nodes including my own BigTimer and others, SQLITE3, NPM, MQTT with websockets and a ton of other stuff – see the updated script on Bitbucket. (27/09/2016 both script and blog updated. I now have two working NEOs (by name – nanopineo and nanopineo2 – so I don’t have to worry about IP numbers).

I’ve also been resurrecting IOT Manager – now that the Russian author has eliminated the need for websockets – this Android app has promise and I’ll be blogging about it shortly – for now there’s a  refresh problem and I spoke to the author about it at the weekend – he’s aware and has made some fixes to the BETA but it still has a couple of minor items that need fixing before it is ready for big time. It would help if I spoke Russian. Just back from a short break to Seville. For now, hopefully there are enough links in here to keep anyone new to the blog busy for a while.

I need to get my hands on an ESP-32 dev board – the limits of .TEXT RAM on the ESP8266 are getting on my nerves.

Have a nice weekend!


Sonoff TH10 and TH16

You will have seen me write about the excellent Sonoff ESP8266-controlled mains relay switching devices in the past and I went into great detail as to how to program them using the HC2016 software, the only caveat being they don’t have enough FLASH memory for OTA (well, not with my software). Oh yes and I HAVE added that “button control” that people asked for.

Well, here are two new boards – the Sonoff TH10 and TH16 – if you look on their website – full information including schematics etc. are freely available.

Itead Sonoff TH10[6]

Before we start – here are my previous blog entries Sonoff

Slampher and Sonoff
More Sonoff
Even More Sonoff
Sonoff to Mains Block
32Mb ESP01 and Sonoff

Compared to other boards, several of us have discussed that the Sonoff boards are well made with good clearance on tracks for mains power etc. Some doubted whether their small relays would truly handle the loads claimed.

Well, it looks like ITEAD have taken this on board as I’ve just received both TH10 and TH16 modules.  As far as I can tell the only difference is that the TH10 has a 10 amp relay, the TH16 has a 16 amp relay.

Side View of Sonoff TH10First impressions? Solid. They are bigger than the original Sonoff modules (which I use on a daily basis for controlling lamps etc) but also  much more substantial looking – the programming button is much easier to access as it is intended to be used rather than looking like a reset button.  I’ve made good use of this as an output toggle (which also works on the previous Sonoffs).

As usual I’ll leave it up to others to tell you what you can do with the Sonoff software – first thing I did was to reprogram the boards to handle my own software.

So – the output control is identical to the older models – but they’ve also added in a temperature port. They have very kindly made the input port compatible with my software (see settings below) and options are temperature only using the Dallas temperature sensor which they can provide on a waterproof lead complete with stainless tip – or the DHT22 which also handles humidity – I’m pleased to see they did not use the inferior DHT11 which isn’t that accurate.

PCB for Itead Sonoff TH10

So – see the original article – you’ll see there how to program up the board – this time – the ground and power connectors are blindingly obvious on the end of the board – that’s 3v3 not 5v – I got away with using an FTDI at 3v3 but you may want to consider a proper 3v3 supply for programming.

Itead Sonoff TH10

If you set wifi_button to 0 – sonoff to 1, temp_type to 0 (Dallas) or 1 (DHT) and temperature_port to 14 (these are non-volatile)   you will be able to control the output on out12 (i.e. out12:0 or out12:1), you will be able to read the temperature AND you can toggle the output on and off with the external button on the Sonoff!

The CE and ROHS stickers should keep those who care about such things happy – the important thing for me is looking at the PCB around the mains it is clearly obvious that thought has been put into this. Well done.

Sonoff connectorsOh yes, the FLASH – like the unit before it – we’re looking at an 8Mb FLASH – that is 1MB –  I don’t really support that for OTA though everything works except OTA. I am pretty sure that like other boards, this FLASH if you really must, can be replaced but be warned my soldering isn’t bad and I’ve done lots of Sonoffs, ESP-01s etc – but the little tracks came clean off when I tried it on one of these boards, immediately trashing it – so do so at your own risk.

As for the push connectors for mains in and out – not everyone’s cup of tea and I did have a chuckle that they’ve gone to the effort of avoiding using a screwdriver for the cables – but you have to use a screwdriver to get the cover off !!!!