Category Archives: Raspberry Pi

Thoughts on RAM

These are just thoughts – hopefully someone is going to write in and tell me I have it all wrong.

As regular readers will know I have reviewed (and messed with) MANY small Pi-type boards including the Raspberry Pi, Banana Pi, NanoPi etc etc.  I’ve also had a go with some power supplies and even made up my own solutions at board level. We’ve had discussions about the issues with FLASH and minimising writes and so mentally it all seems to be coming together. What is needed for our home control central control projects is:

A cheap SBC with enough RAM to be able to lose some for LOG2RAM and buffering for datbases etc to utterly minimise writes to FLASH – so ideally maybe once per day, stuff in RAM would be written to FLASH.

To go with the above then – clearly a power supply is needed that will not fail – i.e. with battery backup.

Sure, if you through enough money at this – there are solutions for everything but at a budget?

Firstly, RAM – just not enough – some of these boards have 256Meg and 512 Meg  - enough for normal use but if you start stealing some of it to run Log2RAM and RAM-buffering databases (RAMDISK) then you start to run out – it seems to be that 2GB of RAM would be a nice figure yet I’m only aware of a small number of these boards that have this much – if memory serves me well, the Odroid C2 – and a board I’ve only just recently heard of – the FriendlyArm NanoPi K2. There will be one or two others I’ve long since forgotten.  The Raspberry Pi people for example apparently have no intention of moving to 2GB in the near future. We see people using these boards for media management yet if you look at the notes from the designers of such software they usually suggest 2GB minimum RAM!  I don’t do media management but our chats about FLASH have me using Log2RAM and RAMDISK and depending on your needs you could be looking at losing 512Meg or your precious RAM.

Power supplies – especially important given the above - recent testing has shown that we don’t seem to have a single low cost unit available that can handle the battery going down to zero – and recovering gracefully while the the load is connected or having to press a button or some impractical manual interjection – and bearing in mind that several of the better boards need  2amps+.   Looking back through the blog there is not one – there’s one on Kickstarter but that is now way, way late in appearing and for all we know THAT might not do the job.

What are people’s thoughts – am I talking nonsense? Am I missing some products? What do you think? Do people have low-cost solutions I’m not aware of?

Facebooktwittergoogle_pluspinterestlinkedin

Raspberry Pi 3 Serial

Just bought a new Raspberry Pi 3 with WIFI and Bluetooth?  Using it in a project with serial? Happy?

Well, you might not be so happy when you find out what I just found out.  I had my Node-Red project that has been controlling the house for around 18 months on a Pi2 and I was starting to have issues -  I thought it time to upgrade. So I made a new installation, faithfully copied everything over, plugged in the board… everything was fine.

Except it wasn’t – nothing was coming out of the serial port. Well, it turns out they stole the serial port for the Bluetooth. There is a second port – of a kind – which can be set to work with the GPIO pins 14 and 15…  but Node-Red serial node was NOT having it – I put a scope on the output – nothing.  I followed instructions to use an alternative “serial port” – which appeared and – the Node-Red Serial port input would not recognise it.

Anyway, it isn’t all bad – thanks to Dave at IBM who put me onto this link…

http://raspberrypi.stackexchange.com/questions/45570/how-do-i-make-serial-work-on-the-raspberry-pi3

Ignore most of the content and head to the end – Answer number FIVE.  This got me back up and running with a high speed serial port – but – no Bluetooth of course. I’m assuming I can just stick in a Bluetooth dongle – time will tell.

Essentially assuming an up to date Pi3, the key line is the one where you add

dtoverlay=pi3-miniuart-bt”"

to the /boot/config.txt file.

I’m liking FriendlyArm more and more (I’d like them even MORE if they’d put more RAM in their boards) but at least, for today, I’m up and running.

Facebooktwittergoogle_pluspinterestlinkedin

Alexa Enlightenment

Last updated November 16, 2016: In a recent blog entry I told you how we’d been playing with Amazon Echo (Alexa) and got it working. Well, nearly. It turns out that what SEEMS obvious in the system is not all it seems - but read on as we've had success.

What is Alexa?

Actually the device is called an Amazon Echo – or for the cheap version and Amazon Dot. It is a box requiring power and WIFI that you can talk to and which will control things. It can automatically discover certain (and often expensive) commercial devices, it can play music, it can answer questions, set diary appointments, make shopping lists – all by voice. And with a little effort can talk to Node-Red to open up a whole new world of DIY possibilities.

Listening for specific words

For example in the Amazon setup pages, you can define variables that will only accept a certain amount of options – so for example – you might say “Alexa, tell computer to turn kitchen lights on” where “lights” could be, say, light, lights or heater.

And that’s fine – but you can’t TRUST that. the word “flights” works equally well and Amazon makes it clear in their documentation that you must do your own tests – any similar valid word in the dictionary could have been accepted (which seems utter madness to me but there you go). Indeed when we tested this – we found all sorts of irregularities – there is no way to say “accept ONLY these words”. And, if you say something that is not at all acceptable, the system will wait to time out – and that takes several seconds – which would annoy the hell out of the spouse. So – if you’re going to have to do your own checks anyway, we reasoned you may as well just try to get the basic words out of the units into Node-Red and “do your own thing”. To be clear then, the Amazon unit is no-where near perfect at word recognition and you have to consider that when designing a solution. I wonder if Google will be better.

Wemo Emulator

A slight diversion here: If ALL you want to do is turn things on and off with Alexa and Node-Red – you COULD just ignore the rest of this article and go grab node-red-contrib-wemo-emulator or read other posts here describing my modifications to FAUXMO.

tmpDE0A

No – REALLY – drop it in – give it a name – like Orange – and define topics and payloads (which might go off to, say, MQTT or may be used to trigger direct port control on a Raspberry Pi or similar) for each of the two commands ON and OFF. Tell your Alexa to go looking for devices – it will find orange – and THAT IS IT – no HTTPS, no NOTHING. It really doesn’t get any easier.  But only ON and OFF which is a bit restrictive - and for heaven's sake don't use the word "shed".

How about controlling your TV. Well, the Anymote Smart controller for Android will talk to Alexa and then hence control stuff by infra-red  – except I can’t get it to talk to Alexa. I’ve written off to the guys at Anymote and will report back. But that takes care of all sorts of Infra-Red stuff as long as you leave your phone on!  Not ideal really.

The Bigger Picture

And now – back to the bigger picture!

Before Alexa, all Aidan and I wanted was something that would listen to requests and then fire speech out so we could handle it ourselves in Node-Red – and that is exactly what we have now achieved. Some will shrink in horror at this having already done it another way – but it looks to us like a great general way forward provided you’re happy with writing your own simple,  high level code to handle a sentence like “kitchen lights on” which could be as simple as a string comparison.

tmp4405

What we’ve done here – is to simple make Alexa collect up to 15 words (arbitrary number) after “ask computer to” – where “computer” is whatever word you want to be (the “skill”) and put them in an array, that function above, called “Alexa” does all of this and strips out words like “eh” “and”, “please” etc. – and you can add more exclusions.  If you forget to actually say anything – the second output of the Alexa function handles it all for you automatically.

So in USER FUNCTION – you get an array – msg.word – with up to 15 lower case words – with the rubbish stripped out. You also get msg.combined, a simple string with everything in one string. If your requirements are simple – the latter might be the way to go.

If you merely want to have Alexa repeat the salient points of what you said so that “Alexa tell the computer to turn the lights on” – the output will be “you said: lights on”

msg.payload = "You said. " + msg.combined;
return msg;

Alexa tell the computer to turn the lights on”

So above, Alexa reads the words in purple and passes on the rest. The simple Node-Red Alexa function strips out the words in red – and passes on the remainder in both an array of words and a simple string.

So clearly you might want that USER function to have outputs for MQTT and EMAIL and whatever other stuff to control your kit – that, of course, is easy and up to you. If you have 2 outputs from the function (set the number of outputs at the bottom) you can write to both at once – or separately by returning an array of messages -  or just one and a null etc. When you send a null – nothing goes out.

Now – I don’t want to go TOO heavily into this because simply string comparisons is probably not the way to go for any kind of sizeable setup… but here is something I’ve used as a test and it absolutely works a treat.

tmp27C1

The code in the user function (note the extra output) is trivial to say the least.

var msg2 = {};
switch (msg.combined)
{
    case "office lights on" : 
            msg2.topic="mains3/toesp"; 
            msg2.payload="{out12:1}"; 
            node.send([null,msg2]);
            msg.payload="The office lights are now active";
            break;
    case "office lights off" : 
            msg2.topic="mains3/toesp"; 
            msg2.payload="{out12:0}"; 
            node.send([null,msg2]);
            msg.payload="The office lights are now off";
            break;
    case "thank you" : msg.payload="No problem, to be sure."; break;
    default : msg.payload="You said: " + msg.combined;break;
}
return [msg,null];

In the example above, I have the function react to “Alexa tell the computer to turn office lights on” by sending an ON command via MQTT to one of my ESP8266 boards. Off has a similar effect, different parameter. The final command it just a bit of fun.

Really – so to get all of this fun, you have to set up your SSL (which I found incredibly painful but in retrospect it was dead easy – another of life’s hurdles out of the way) so that Amazon’s servers can talk to a secure connection (your Raspberry Pi or whatever you are using – FriendlyArm Neo or similar would be just as good running Debian), you need to update some stuff into Amazon’s site – and from there on you never touch the Amazon site again –which is of course the point really -  you only have to concern yourself with your USER FUNCTION in the cosy and quick-to-alter Node-Red environment. What you do with that is up to you.  In my case I’ll add another output to go to MQTT and whatever comes in is processed and maybe does something – any message in msg.payload (you HAVE to send something back) is spoken by Alexa when you’re done. It really doesn’t get a lot easier.

In a really trivial case you might, with TWO outputs,  (the first should be used to return a message;

say

if (msg.combined==”lights on”)
{
msg.payload=”Ok, light is on”; node.send([msg,null]);
msg.topic=”kitchen/toesp”; msg.payload=”{out0:1}”; node.send([null,msg]);
}

Ok, I know, create another object and send them both out at once – I’m trying to keep this simple.

But of course, in reality, you’ll be likely to do FAR more than this and hence having the separate words in an array is useful.

So - on Amazon - you need an intent!

{
  "intents": [
    {
      "intent":"inputIntent",
      "slots": 
        [
          {"name": "wa", "type": "LITERAL"},
          {"name": "wb", "type": "LITERAL"},
          {"name": "wc", "type": "LITERAL"},
          {"name": "wd", "type": "LITERAL"},
          {"name": "we", "type": "LITERAL"},
          {"name": "wf", "type": "LITERAL"},
          {"name": "wg", "type": "LITERAL"},
          {"name": "wh", "type": "LITERAL"},
          {"name": "wi", "type": "LITERAL"},
          {"name": "wj", "type": "LITERAL"},
          {"name": "wk", "type": "LITERAL"},
          {"name": "wl", "type": "LITERAL"},
          {"name": "wm", "type": "LITERAL"},
          {"name": "wn", "type": "LITERAL"},
          {"name": "wo", "type": "LITERAL"}
        ]
    }    
  ]
}

and a "sample utterance"

inputIntent  {LITERAL|wa} {LITERAL|wb} {LITERAL|wc} {LITERAL|wd} {LITERAL|we} {LITERAL|wf} {LITERAL|wg} {LITERAL|wh} {LITERAL|wi} {LITERAL|wj} {LITERAL|wk} {LITERAL|wl} {LITERAL|wm} {LITERAL|wn} {LITERAL|wo}

All we’re doing here is telling Amazon, for the “intent” “computer” – to collect up words and fire them off. And that's it for the Amazon end apart from the usual details they need about you and the https address of your website (the node-red exposed point).

As for Node-Red itself - the example above:

We have an http node which has nothing more than POST and “/echo” as the URL - then our ALEXA function contains the following - it may well be far from perfect but for now it works.

var doStuff = {payload: msg.payload.length};

switch (msg.payload.request.type)
    {
    case "IntentRequest":
    if (msg.payload.request.intent.name   === "inputIntent")
        {
        var word = [];
        
        word[0] = msg.payload.request.intent.slots.wa.value;
        word[1] = msg.payload.request.intent.slots.wb.value;
        word[2] = msg.payload.request.intent.slots.wc.value;
        word[3] = msg.payload.request.intent.slots.wd.value;
        word[4] = msg.payload.request.intent.slots.we.value;
        word[5] = msg.payload.request.intent.slots.wf.value;
        word[6] = msg.payload.request.intent.slots.wg.value;
        word[7] = msg.payload.request.intent.slots.wh.value;
        word[8] = msg.payload.request.intent.slots.wi.value;
        word[9] = msg.payload.request.intent.slots.wj.value;
        word[10] = msg.payload.request.intent.slots.wk.value;
        word[11] = msg.payload.request.intent.slots.wl.value;
        word[12] = msg.payload.request.intent.slots.wm.value;
        word[13] = msg.payload.request.intent.slots.wn.value;
        word[14] = msg.payload.request.intent.slots.wo.value;
        
        var thisone =0, processed = 0, total = word.length;
        
        for (;;)
            {
            var nxt = "";
        
            switch (word[thisone])
                {
                case "cancel" :
                        msg.payload = "";
                        return [null, msg];
                        break;
                case undefined:
                case "the":    
                case "to":
                case "thanks":
                case "thank":
                case "and":
                case "turn":
                case "a":
                case "please":
                case "you":
                case "er":
                case "erm":
                word.splice(thisone,1);
                break;
                
                default:
                ++thisone;
                break;
                }
                
            if (++processed >= total)
                break;
            }
            
        msg.topic = "";
        msg.payload = "OK";
        doStuff.word = word;
        msg.word = word;
        msg.combined="";
        for (a = 0; a < word.length; a++)
            {
            msg.combined += word[a] + " ";    
            }
        }
    return [msg, null];

    case "LaunchRequest":
    msg.payload = "You need help";
    return [null, msg];
    
    case "SessionEndedRequest":
    msg.payload = "Session Ended";
    return [null, msg];
    
        
    default:    
    msg.payload = "Unrecognised Intent";
    return [null, msg];
    }


Note I've added a check for the word "cancel" which simply returns nothing, immediately. This is a vital addition as sometimes you just talk gibberish and want to get out of it!

The format response function looks like this…

tmp9E6A

The other blocks don’t have anything in them – other than the user function in which you can make use of msg.combined and msg.word.  When you are done be sure to send the message out – payload containing text of your choice – as Amazon does need a return value even if your text is blank.

So:

Set up an Amazon account – get PRIME if you want their music – if you’re rich get a Spotify account as the Amazon music selection is naff.

Get HTTPS so the end point of your Node-Red page (no real page exists) in my case http://whatever.com/url

That domain or subdomain needs to point to your building – and your router should redirect port 443 (ssl) traffic to port 1880 on your PI or whatever you are using. Why 443 - isn't that a pain for routers which have SSL management and VPN - yes it is - you have to move those to another port. WHY Amazon absolutely insist on port 443 for SSL I don't know - because any port will work but they won't accept them - please by all means do take it up with them.

If you have passwords set up on your Node-Red and your Node-Red UI (which I do) you’ll have to pass them in the  Amazon website string – and I recommend you do this as clearly you don’t want any old Tom, Dick or Harry logging into your Node-Red

Once they are set up is a matter of going to the Amazon developer site with your account – the Alexa tab, setting up s skill including letting it know about your URL – filling in the bits above – and soon thereafter your DOT or ECHO or whatever you are using should be sending text over to you – to do whatever you want with.

Clearly, this will develop – splitting text up into words like this is useless for email addresses – so “Alexa tell the computer to send an email to pete@scargill.org” is simply not going to work – and as for “Aidan” – it makes a complete mess of that Smile

For reference – we made up some notes from our efforts to get an SSL certificate – if you have proven, better ways that cost less and don’t involve re-signing on every now and then as some freebies do – and which you know Amazon will accept as genuine – by all means give us blow by blow info. If you have a better, more complete, simpler description – please do let us know.

From our notes on setting up SSL – https – which may or may not be useful…

You need a trusted certificate to work with Alexa if you want it to talk to your Node-Red setup. Aidan has emailed the Amazon developer guys and eventually got a reply to say they had an issue with self-generated certificates, now resolved - sadly my router setup appears ot have an issue with them and so I can't test this (the router setup in Spain simply WILL not pass through port 443 to an internal unit).

With Node-Red typically you would have separate username and password for external access - this can be re-used with https: and the https: url can bypass the username and password requirement which means you can continue to use UI (dashboard externally).

Obtain SSL from – in our case, https://www.ssls.com

So, the procedure is to pay your money and then use openssl to generate a certificate request (.csr) file.

openssl req -out my.domain.name.csr -new -newkey rsa:2048 -nodes -keyout my.domain.name.key

Enter all the details that are asked for, but when it comes to the ‘Common Name (e.g.server FQDN or YOUR name)’ bit, you must put in the domain name of your server (without the ‘www’ as you get that anyway), so enter ‘my.domain.name’ into the ‘common name’ section and you will be verified for my.domain.name and www.my.domain.name

Before you start the above process, make sure that you can access your Pi (or whatever) externally using your domain name to avoid unnecessary delays.

When you have your .csr, then edit it and cut and paste the full certificate request into the ssls.com request box when it asks for a certificate request.

It will then generate a small text file for you to place in the www/html root of your Pi. Make sure that you can access it externally by cutting and pasting the file name into a web browser, such as http://my.domain.name/AB5678DEF.txt (or whatever the file name is). When you enter that into a browser, you should see the contents of the file appear.

When you’re happy that works, then click continue on ssls.com and it will verify your website and generate your certificate and bundle which you can then get by clicking ‘download’ to get a zip file.

Store this all safely (including the private key file  that you generated with the .csr file) – i.e. make a backup!

You can use a subdomain - so that if you use www.fred.com for something else you can have https://mysub.fred.com for Alexa and Node-Red (verified – I am using a “things” subdomain without issue while my basic root www address is going elsewhere).

Using advanced DNS or similar function with your provider, point mysub.fred.com to your site. In your router, take 443 and point to the 1880 port of your node-red Pi.

We checked and you definitely can’t use anything other than port 443.

Temporarily route port 80 (website in our case) to Pi - as you'll be asked to dump a file in the root folder for verification..... once complete this can be restored to whatever you were using it for in the first place.

Some files need to go into a folder i.e. /home/pi/ssl (our choice) and your info set up in node-red settings.js needs to know where they are...

Need to setup certificate in settings.js (https://... And uncomment ‘fs=’ …etc.

NOTE: I’ve just had to move the lot from one Pi to another – because I messed up the installation of the Pi and had no ports to play with. I can confirm – ALL that is needed is to move the certificate files (in any old directory) to the new Pi and make changes to the Node-Red settings file – uncommenting FS and adding two lines for the certificates - that’s it – all up and running – this is no-where near as complicated as I initially thought it would be.

Also, if your certificate isn’t from a root CA then you need to copy your base certificate into the certificate chain, mainly because node-red doesn’t give you any option to use a certificate bundle file. i.e. edit your .crt file, copy the contents and paste to the top of the ‘my.domain.name.ca-bundle’ file -  this will add your certificate to the chain file.

Use SSL CHECKER  https://www.sslchecker.com/sslchecker  to check validity

Make sure that the certificate is verified all the way up to the issuing root Certificate Authority or Amazon will reject it

When all working - put your port 80 to where it was. After everything works - reboot your router to be sure.

And if I have not said it before – Amazon’s music library is SHITE!

Facebooktwittergoogle_pluspinterestlinkedin

A Brighter Node Red

Just today  – an upgrade notice for Node-Red appeared in my in-box. Upgrade details are here.

What is Node-Red?  Details here – if you’re not using it or at least investigating it – you may be missing out.

Now, the support guys (Google groups here) are VERY clear about required versions of NPN etc. so I suggest you read that update page carefully.  Because I had 2 identical machines (NanoPi M1 as it happens) I thought I’d go for broke. Don’t copy me unless you have a reliable, easy to get to backup – it may well go wrong (mine didn’t) and you’ll be on your own for not precisely following the instructions.

sudo npm cache clean
sudo npm update -g --unsafe-perm node-red

I had already installed the latest (previous Node-Red – maybe a couple of weeks old) – not the default Raspberry Pi version but a manually installed version – along with NPM and the latest NODE and that is NOT what they recommend. I turned Node-Red off (node-red-stop) and used the above commands as PI user (I know, not on a Raspberry Pi but to make my life easy I always make a PI user who belongs to all the PI groups including SUDO)  - I then turned Node-Red on (node-red-start).

Voila. It worked first time.  0.14.0

Now – so what’s special – well, one of my issues with Node-Red has been initialisation of variables – sometimes a global variable can get used before it has been defined!!

The team told me a while ago that the LEFT-MOST tab gets run first – of course that’s no good if your inits are not in the left most tab (I have a tab called “init”). Well now it is because you can SLIDE the tab order about with the mouse – how neat is that!

The DEBUG panel now lets you see message from all over – or just the current tab – which is nice and there are some new nodes and other improvements – I’ll let you read all about them here. The big one that stands out is the LINK node. I HATE making large tabs that are really complicated – but to split them up involves passing messages between tabs – and until now that had to be done the hard way – by global variables (not ideal as you have to poll them) or MQTT or similar. Well now there is a node for THAT as well.

Then I spotted a bug – the exec function would no longer take numbers as arguments – only strings (which is what you’d expect but it had always accepted numbers).  I reported this early evening. Meanwhile someone reported an issue with MQTT…  so the guys amazingly quickly fixed all this.

sudo npm cache clean
sudo npm update -g --unsafe-perm node-red

Erm, no – this time no messages, just accepted my commands but no update.  It was a bit late to expect answers out of anyone… so KNOWING I HAD A BACKUP and stopping Node-Red first then restarting afterwards…

sudo npm cache clean
sudo npm install -g --unsafe-perm node-red

Worked a TREAT – I’m now sitting on version 0.14.3 with all my flows intact. The exec issue has gone away and here we are the next morning, after a few more checks I’ll progress with updating my other installations.

The team are to be congratulated on the work they’ve done on this tool – it costs us nothing but opens up entirely new possibilities to both beginners and seasoned programmers.  Very different image of IBM to the one I had when I was a kid (huge buildings, everyone talking in abbreviations, obscenely expensive leased servers) – at least that’s what I remember  - probably wrong Smile

Marvellous.

Facebooktwittergoogle_pluspinterestlinkedin

Background Beavering

You could be forgiven for thinking I’ve gone off the boil as I’ve not written much in here this week… far from it in fact. This week I’ve been working on my ImperiHome setup and the new Raspberry Pi software.

ImperiHomeImperiHome: In case you don’t know, ImperiHome is an app for Android and IOS that enables remote IOT control. It does this by trying to appeal to just about every system out there, none of which I use.  I’ve taken the approach of having IBM’s Node-Red control everything – and thankfully ImperiHome has a generic API to allow control if you don’t have ANY of the devices it supports.

I’ve written more than one item on this subject and I have to say despite a rather lacklustre approach to answering people’s questions by their team and something of a lack of generic controls (such as a momentary push-button), the product actually works and works quite well. I have RGB lights, relays, sensors and a host of gadgets attached to Node-Red. Those which are required to just come on and off at varying times of the day are controlled by my BigTimer (which, recently updated, works a treat – or rather, it does if you remember to set the time zone when setting up the Pi as I found out last night when all the lights were still on at 2am, defying all explanation until my wife said “did you ever set the clock on that thing?”).

Those gadgets which require interaction are controlled by ImperiHome on my HTC Smartphone.

On the subject of Node-Red, we are promised non-volatile global variables in future by the Node-Red team and I for one can’t wait – but for now I’ve just completed a function to save a global object (buffered in time) when any change is made. That global object forms the variables used in my ImperiHome project – so now at last, the phone is always aware of the state of my lights – a handy thing. Essentially the object contains a counter which is set whenever any other variable in the object is altered. This is monitored by a timer which also kicks in on power-up.  If the counter is true, it is decremented – if it hits zero I update the file on SD which contains that object.  I also check to see if the file exists – and if not, I create it. If the file DOES exist and the object doesn’t – I populate the object.  So now, my lighting and other settings can survive power-cycling.

Raspberry PiRaspberry Pi: On 10/05/2016 the Raspberry Pi foundation put out a new release of Jessie (Debian) and with it, items you might expect like better support for Bluetooth etc., but then something I wasn’t expecting – a decent backup program. After (what seems like) years of struggling with arcane Linux commands some of which I never really got to grips with and hence never achieved a satisfying backup solution, at last, a simple push-a-button backup program that not only allows for live backups, but also allows for the use of varying size SDs both larger and smaller.

WHY did this take so long…  I can’t tell you how this has changed things for me – backup time is reduced, no need to shut the house controller down when I’m doing backups, the use of smaller SDs, running multiple copies of the same software on different boards – the list goes on.

But for days I’ve been struggling with upgrades – the backups just did not want to accept upgrades (apt-get-upgrade) and when they did, invariably Node-Red would fall over with missing nodes etc. I didn’t know if it was the backup program or what…  (I knew it was not the SDs as I use only good ones). Well, it turns out that my script was in need of bringing up to date. I still scrap node, npn and node-red and re-install to get the very latest but I’ve done it a different way, more by trial and error, but I got there in the end and now my backups and restores are working perfectly. I’ll publish the updated script soon, replacing the older one and I’ve added some tricks I’ve picked up along the way from readers like you.

Tiny part of my controls

I started this blog entry before our BBQ yesterday and here I am up early on a Monday morning finishing off the job. The lights worked a treat last night now the clock is set correctly – thanks to NTP it will now stay that way.

Coming up this week hopefully – a couple of new boards from Friendly Arm, the new Nextion display and more. But first things first, some supply shopping,  I’ve lost a filling and Maureen’s done her foot in – this should be good – dentist and hospital – in Spain (and not in the tourist areas where they speak English).

Facebooktwittergoogle_pluspinterestlinkedin

Visual Interfaces for IOT

Hollyberry BlynkSo much happening right now – the new Raspberry Pi 3 once again sets the bar with improved performance, Bluetooth and WIFI as standard. With up to 10x the speed of the original Pi we can do even more serious work with these devices.

Please note before proceeding – apparently the Blynk team plan to charge for the use of this app – it is not clear if this means using their server, using a local server or both? And they claim that new widgets will be included in a monthly deal – but WHAT new widgets and in what timescales? – as the Blynk app moves from free to paid I think they will find people want more definition of what is included and when. A one-off fee is one thing – an on-going payment is altogether something else.  http://community.blynk.cc/t/blynk-will-introduce-paid-subscription-in-q1-2016/3177

The ESP8266s are looking (depending on which software you use) to be very reliable to – so that is both the central control and peripheral activity side of things more or less in place.

Where we are still falling down IMHO is the visual interface side – that is – remote control by phone. I’m interested only in Android but I’m sure the same applies to IOS.

At the turn of the year it was looking like a neck and neck race between a small number of systems, node-red-contrib-ui for those inclined to doing a spot of programming and Blynk for those who are more concerned with the visuals.  I’ve looked at several other packages but to be honest either the visuals were just pretty poor or the technology not too well thought out etc.

We’re not there yet.  To my mind the one with the most hope was, until recently node-red-contrib-ui but since January there has been little or no sign of the author and no further developments that I am aware of (though I did hear a rumour that it might become a permanent part of Node-Red – let’s hope this spurs major new development) – this is a great shame as there was a heavy conversation going on with big improvements almost there – and then it all stopped. This is not new – I was convinced at one point that NETIO would be the brave future but development on that seemed to stop some time ago despite being commercial.

That leaves us with Blynk and a few others. Blynk is almost there. It works with the concept of a central server which knows the states of various devices, accepts updates and relays that to the APP. I pushed hard on this to make sure that regardless of whether the App was on or off, the state would be stored and the App would reflect changes when brought back to life. This was considered an edge request by the designers but they implemented it anyway and between that, improvements to the local version of the (small Java) server (which can run on a Raspberry Pi) and some sterling volunteer third party work to bring websocket-based communication back to Node-Red, the App is looking like a clear leader – but not perfect yet.

Blynk[4]I recently contacted Blynk and was assured that at some point they will fix the current issue – that being – they expected people to use buttons for ON and OFF scenarios.  I’d not twigged to this issue until recently when I finally started putting together a set of Blynk controls for my various gadgets.

One of the items I use a lot in my Node-Red applications is my own BIGTIMER (node-red-contrib-bigtimer) and that can set, say a light, to come on and off at set times during the day – for example coming on at lighting up time and off at midnight.  But like all timers – one must have an override facility – and so it is with bigtimer – I can inject text “on”, “off” and “auto” into the input to manually override the timer or send it back to auto.

Well as you can imagine – that is simple to implement with 3 buttons – but having them say “ON” or “OFF” just does not apply – similarly for heating control you might have “up” and “down” buttons.

Blynk say they will not only implement variable text in the buttons but also icon graphics… well, can I put a request in now – if these are to be fixed icons – we need a full set of remote control icons – ie stop, pause, start, ff, rw etc.   For text the best option would be freeform…. or NOTHING – text in momentary buttons just doesn’t make sense to me. A change of colour when being pressed is good and they’ve implemented that.

It would be nice if they had a smaller button as well – and the RGB control is just WAY too big – but looking at the alternatives – Blynk are to my mind still ahead of most.

I’ve looked at several alternatives – but right now most just not cutting the mustard. Either too complicated to setup, too limiting, unreliable or just not finished – and that happens a lot. There is just one out there that might just blow Blynk out of the water and you’ll see my videos and this blog commenting in the future – the app is called Imperihome and thanks to a small number of us working together, there is now good support via Node-Red for this App which is available for both IOS and Android – on the surface it blows even Blynk out of the water. Time will tell.

Facebooktwittergoogle_pluspinterestlinkedin

Raspberry Pi 3 Spoiler

While waiting for my new Raspberry Pi 3 board to arrive so I can blog about it – I thought I’d jot down some thoughts following a conversation with a pal of mine in Canada.

Today, a new Raspbian release came out supporting the 64-bit Raspberry Pi 3.  Hopefully it will be completely backwards compatible – the first thing I’ll be doing is trying out my script and I’ll report back if there are any issues.

The new board has both Bluetooth and WIFI – and of course the thing here is that they are not using any of the 4 USB ports – which means you could be using a Bluetooth keyboard and mouse – and STILL have 4 USB ports available – that pretty much blows away most of the competition – just a shame none of those ports are USB3.

The new NOOBS installer, should you go down that route – now has Windows 10 if that’s your thing. I saw a preview today and it looks ok – apparently both released and insider preview versions are available.

The new 64-bit Arm A8  Raspberry Pi 3 looks once again to have set the bar – it could be that many will be looking at their newly acquired alternatives and pondering putting them in the bin.

Until the postman arrives tomorrow…

Facebooktwittergoogle_pluspinterestlinkedin

Cheap Raspberry Pi

Now before you say anything – they don’t even know I’m writing this!!  Remember when I was in Chicago a while back (well, you’ll only remember if you’re a regular reader)… I bought a Pi Zero and a Raspberry Pi dirt cheap at somewhere called MicroCenter in Chicago.

Well they’re at it again.

http://www.microcenter.com/single_product_results.aspx?sku=586644&utm_source=EMAIL&utm_medium=eNews%26%2332%3BSpecial%26%2332%3BEd%26%2332%3B20162017&utm_content=5134390482&utm_campaign=E3400

So my question to British dealers is – when are you going to get your fingers out and offer us Brits deals like this – that’s £21 for a Raspberry Pi 2  all in…

I didn’t think so. PC World £29.99, Gearbest £27.28, Amazon £29.99 –

Facebooktwittergoogle_pluspinterestlinkedin

Pi Zero Wi-Fi Automatic Reconnect

WIFISometimes I wonder about the thinking processes involved in Debian setup.

Why for example would you NOT want the Wi-Fi to reconnect on failure? What is the point? Yet, that does seem to be the default scenario, particularly odd when it comes to the Pi Zero – which has no option BUT to use WIFI.

I generally attach Raspberry Pi devices to the Internet via a hardwired Ethernet as connectivity is very important to me – not much point in having a super-duper setup miles away only to discover you can no longer talk to it, right?

Yet that is EXACTLY the scenario people will no doubt stumble onto when getting their new spiffy Pi Zero – I’m not going to say low cost because by the time you realise you need a USB hub and WIFI adaptor the price suddenly shoots up towards the cost of competing devices.

However, having had my Pi Zero sitting on the shelf for some time and having now received more than one WIFI dongle (including one with a decent external aerial) I thought I’d give it a go. The little number you see here on the right was £2.59 from Hong Kong and is in keeping with the low cost of the Pi Zero. I also spent £5.59 in the UK on a cheap powered USB hub because article after article suggested that running the WIFI without a hub was not a good idea (since verified and further backs up my doubts about the benefit of having a Pi Zero in the first place).

USB HubSo I took an old-fashioned Pi B and set that up with Wi-Fi (without the hub) – copied the FLASH from its rather large original SD to a micro SD and plugged it into the Pi Zero. Plugged in the cheap USB powered adaptor  – plugged the WIFI dongle into that and applied power.

Worked a treat. Lovely. Tried without the hub, no joy. But of course this is when people normally stop only to discover often days or weeks later that this is NOT a good enough solution.  I did note that very occasionally the Pi Zero would reset – the cause of this was a very long, thin USB power lead – funny that this never had been a problem with the Pi2 – but shortening the lead very definitely solved the problem.

So with everything working, To test reliability, I simply pulled the Wi-Fi dongle out – and put it back in. The Wi-Fi was DEAD. After 5 minutes still no connection.  So I rebooted the Pi and back came the connection. The next test was to pull the power to the router (does anyone REALLY live in a place where none of this EVER goes wrong?). Router back on – waited 5 minutes and… sure enough – absolutely NO Wi-Fi.

I started to scour the web – BOY are there some convoluted solutions out there – one might suggest  some were written by sadists. Come on guys – this is a tool, not life itself – something SIMPLE is needed.

And so it was I stumbled onto this page.

http://raspberrypi.stackexchange.com/questions/4120/how-to-automatically-reconnect-wifi

Here’s the important bit – no new files.  I was talking to the Pi via winSCP and of course as Pi user you don’t have permission to wipe your nose so I made a slight mod to the Pi connection – in winSCP, under advanced, SFTP I put “sudo /usr/lib/sftp-server” into the SFTP SERVER panel – and reconnected – this gave me elevated control to actually let me edit files without needing a degree in Linux using one of the many awful command line editors therein.  

As per the link above..

In /etc/network/interfaces I put:

allow-hotplug wlan0

iface wlan0 inet manual

wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface default inet dhcp

I saved that and rebooted – all was ok. I pulled the WIFI dongle out – winSCP griped. I plugged it back in, 1 minute later, winSCP reconnected automatically. I turned off the router – winSCP griped. I turn the router back on – just over a minute later, winSCP reconnected automatically.

Now why isn’t that the default setting?

For my next trick – in Debian Jessie and with the graphical interface set up, I tried swapping routers – I have 3 access points as my home has lots of thick walls.  I swapped from one to the other and was asked for a password. Ok, fair enough. But then when swapping back to the original, I was asked for the password again. WHAT?? I’d already given it the password, why would it want it again?

Well it turns out that all is ok as the graphical interface had actually saved both settings in /etc/wpa_supplicant/wpa_supplicant.conf

I’ve obviously altered my two SSIDs and passwords.  I guess you could put as many of these as you like in here manually.

network={
    ssid="aaaaaaaa"
    psk="xxxxxxxxxxxxxxxxxxxx"
    key_mgmt=WPA-PSK
}

network={
    ssid="aaaaaaaa"
    psk="xxxxxxxxxxxxxxxxxxx"
    key_mgmt=WPA-PSK
}

Lovely.  It really is worth asking however, is it really worth the saving of having a Zero when it needs a USB lead and hub for it to be of any use, not needed with a P2 which is also faster.. or one of the alternatives out there. There is also no 3.5mm jack for audio on the Pi Zero.

Still at least I can now use this for something…

IanChilton on Twitter just sent me this link – which I have to say on the surface of it is pretty damned interesting for the Pi Zero – any thoughts on this? The price is stunning and it would seem to be JUST what the Pi Zero needs? Does not seem to come with a power adaptor – but it does have a little hole for one in the back!

http://www.aliexpress.com/item/Hot-marking-Micro-USB-to-Network-LAN-Ethernet-RJ45-Adapter-with-3-Port-USB-2-0/32544477817.html?spm=2114.30010308.3.2.YZfEDZ&ws_ab_test=searchweb201556_3,searchweb201644_3_505_506_503_504_301_502_10001_10002_10016_10005_10006_10003_10004,searchweb201560_3,searchweb1451318400_-1,searchweb1451318411_6450&btsid=7667f665-95f8-487d-9525-af3aa4c3a948

So.. do we actually NEED to use WiFi in the ZERO or is this a viable and practical alternative?

By the way if you see that 4 port USB hub I photographed above on Ebay – avoid it  - we were sitting watching TV tonight when the little plug-in-the-wall power supply that came with it – blew up!!

Facebooktwittergoogle_pluspinterestlinkedin

Pi Zero and the USB Problem

The £5 Raspberry Pi Zero has great potential as a cheap gadget but it has one major problem – lack of USB. So it has no ETHERNET – your ONLY option is WIFI – but will the WIFI work and how the HELL are you supposed to figure that out when you only have ONE USB socket. You can have mouse, or keyboard but not both.

IF you happen to have a USB hub lying around you’re all set – but if not, here’s a GREAT idea from a pal of mine…   if you happen to have an original Raspberry Pi (ie NOT the Pi2) – plug the WIFI into that, set everything up on that – then transfer the SD and the WIFI over to the Pi Zero.

SIMPLES – I really don’t understand why I didn’t think of that first – well done David. I just happen to have one old PI lying around and I was looking to giving it a job! Node-Red on a Pi Zero? Keep an eye out for further news.

Facebooktwittergoogle_pluspinterestlinkedin