Monthly Archives: October 2015

Drilling into Blynk

zeRGBaYesterday I referred to using DELAY in Node-Red to slow down one of the Blynk controls. To backtrack a little…  We’re talking here about controlling devices such as ESP8266 boards using MQTTT – which I maintain is the best way to have a boatload of devices around the place and talk to them. I do this from a Raspberry Pi 2, using Node-Red which is a visual system, relatively easily fitted to the Pi (see my articles about my script). Once you have this in place, you can use simple (but excellent tools such as MQTT-Spy to send out MQTT messages to your devices and get input from them.

But in the real world who wants to sit there programming a tool just to turn a light on. So there are various options including the rather expensive Raspberry Pi touch display. A better option IMHO for local operation are the Nextion touch displays which work serially. I’ve covered these elsewhere -  a project that is still in it’s early stages but with a little work is usable – so much so that I plan to use them in my place here in Spain and back in the UK as thermostat wall mounts – I’ve covered that elsewhere under “Nextion”.

And so to Blynk. For many months I’ve been trying to get a decent control/display combo for the mobile phone. I’ve written my own in jQuery mobile and used the likes of NETIO and THINGSTUD.IO – all of these are viable methods – another that is coming up is Blynk – again very preliminary and I’ve reported lots of issues with this – but it works.

There are several useful controls – you see in the image above some simple LEDs (which can be set to various intensities though you can’t programmatically set the colour, sadly), some simple status outputs and two buttons (which can be set to ON/OFF or push to operate). They also have a controller called the zeRGBa which is a visual controller for setting RGB lighting. You see 4 of them in use top right of this article. You can basically move your finger over the control – which will then fire out RFGB values. Thankfully you can set the maximums as not everyone works in the 0-255 space. My PWM controls for ESP8266 use 0-99 for example.  This widget falls down currently in 2 areas, firstly you cannot SET it’s position – you can only use it as an output control. Secondly and arguably more importantly it sends out rather too many commands one after another when you move the unit around. I prefer courser control, smoothing the transition in my ESP boards.

So, given a control that fires out RGB sets rather too rapidly, how can Node-Red help. Thanks to the developers who I’m fortunate enough to get lots of feedback from, it’s actually quite easy.

RGB Control

Here we see 3 inputs from the App coming in via the Blynk Node. The first thing I need is a function to convert that data (a simple array of 3 values) into an MQTT statement to fire out.

msg.payload="{rgb:4," + msg.payload[0]+","+ msg.payload[1]+","+ msg.payload[2]+",70,1}";
return msg;

Easy enough – I set the topic for MQTT to my wall RGB ESP8266 board (the format is my own, don’t get hung up on that) and I use a message payload of say “{rgb:4,255,0,0,70,1}” – what the hell does that mean? Again my own format… the braces are there for technical reasons – my ESP boards accept MQTT or serial – and the ESP’s put out some crap at the beginning and debug info – so I wrap my messages in “{}” just as delimiters. So the actual message is “rgb:4,255,0,0,70,1” – which means – using output 4 of the ESP, send out RGB 255,0,0 (i.e. RED), smooth the transition from one colour to another over 70ms – and I can’t remember what the last parameter is – irrelevant here.

If you look at the code, what you’re getting from the Blynk node is an array (msg.payload[0-2]) so a simple substitution.

That one string goes out RATHER TOO QUICKLY on message after another for my little boards and I was wanting to slow them down just a touch. the DELAY node can be used for this..


Absolutely brilliant – so it will not allow more than 16 message a second – and if it gets more – it will drop some intermediates. Works perfectly – the actual rate of course depends on your project. I had utterly missed this – thinking that node was nothing more than a simple delay as suggested by the name – but dig in and it has so much more to offer.

So right now I can control several RGB devices around the house, limited only by the somewhat large size of the zeRGBa widget and the inability of BLYNK right now to handle several pages per project (though as of the other day you can seamlessly move between projects which helps).

In  case you’re wondering – the language used in the functions is JavaScript  - who’s ability to make life easy when it comes to handling different types of data such as arrays and JSON, is a wonder.  I look forward to the day we have a PROPER, fully working interpreter on the ESPs themselves.

Oh – and to run the Blynk server on your own kit – you need Java 8

apt-get install oracle-java8-jdk

And I made my blynk directory and those below it full read/write/execute.


A Better Day

BlynkA better day today. After switching my WIFI to a separate access point, up to now the WIFI is holding – I’m not convinced but for now all seems well. That has allowed me to spend a little more time with Blynk – and after chatting to the Node-Red node designer – and getting an update out of that, I now have Blynk server running on my Raspberry Pi2 – so between that and the Node-Red App I can now control stuff with a decent App – still some way to go with this but it’s starting to look useful.

As you can see in the picture – I have 4 RGB controls (suitably slowed down thank to the excellent Node-Red delay function), temperature and humidity monitoring and a couple of on-off buttons with feedback via LED. All working a treat.

Below you see the Node-Red code driving this – all very simple – the delay function is used to limit the rate of change for RGB and PWM as the App has a tendency to push stuff out very quickly.

Other than that it is all very simple – and when the designers get around to allowing more than one page per project, it’s going to get one hell of a lot more complicated Smile














And with that – an early night I think.


WIFI Congestion?–Help Requested?

Update: See bottom

I have a problem – and I’m going to shamelessly use this blog to see if someone can help.

In the midst of my home control nirvana – I’m having some WIFI issues that I simply don’t understand.

So -  my setup:  Broadband coming in is maybe 6Mb in each direction so no issues of lack of speed.  It comes into a Draytek (PPOE) router from a small window mounted dish to a large aerial in the middle of the village. I have no problem streaming TV or downloading big programs etc.

Indeed I have very few problems with hardwired use – our PCs always connect to the web. I’ve had my little wifi ESP boards talking to a Raspberry Pi for months without issue.. and then a couple of weeks ago it started…

The units would log in but not stay logged in, or be unable to login. I thought it might be my little WIFI control units – but then my wife started griping here phone would not log into the network. The mobile phones suggest this is not an issue with my little WIFI boards.   Sure enough – try to log in – the phone would say “connecting” then just go back to “saved” .  After a while it would connect for no good reason.

I switched the WIFI off for a couple of hours and back on. All was well for maybe 30 hours – and then slowly but surely my little control units would have trouble logging into the WIFI – and so would our mobile phones.  Strangely, though our PCS which are hardwired would have no apparent issues, I’d find it might take seconds to connect to the router with the web interface, something that should be virtually instant. WHY? The router is on a wire as is the computer. What can be so jamming up the network?

So – I reduced the router to factory settings. I altered the DHCP to start at and did some IP-MAC fixing for things like the PI (well, two or three of them) and my PC. This was to ensure that no devices with fixed IPs were in the same range with possible overlap with devices working on DHCP. We’re taking maybe 20 devices all in – some controllers, a couple of computers, 2 phones, 2 tablets, 2 Raspberry Pis… and some ESP8266 WIFI units.

All worked well, my devices operated flawlessly as did the phones and the TV for DAYS on end. Yesterday a couple of times I heard devices logging in to the Pi (I have speech warnings). Might be an issue, might be not.

But this morning, whatever is wrong is back full steam, devices logging in every few minutes and generally not taking any notice of remote instructions – or taking ages to respond.  It is as if something is absolutely hogging the radio network.

And yet… I put checks in to see how many messages were  being passed back and forth between my PI and the devices… one a second if that – no big deal. I’ve looked at bandwidth use in the router – nothing stands out . BUT SOMETHING is gumming up the works.  I have 3 routers acting as access points and yes I’ve spread channels so no overlaps.

I’m missing something here, I have no way to see what it is that is actually going wrong here.  If anyone considers themselves a whiz at wireless networks – feel free to get in touch – – I could do with some fresh thinking.

Update 28/10 – A couple of days with almost no problems – tonight back with a vengeance – WIFI feels “clogged” – attempts to get Wireshark invariably gave me an incomplete download on my otherwise very fast laptop. Went to the (wired) PC and no problem.

Here’s a heatmap of the place with very rough positions of kit.. only the two WIFI access points (actually identical position as both on the Draytek) are mine – others are WAY further away than they look and so unlikely to cause problems.  All but one is nearly a street away.



So after having difficulty loading Wireshark, I downloaded it on my WIRED machine and ran on the laptop in the main room – I’ve no idea how to run Wireshark but I’m pretty sure that screen was showing problems – failures, some stuff in red, retries… After saving the file from Wireshark I turned off the external WIFI coming in – and turned the Draytek off. I left them both off for maybe 10 minutes. I turned them back on – hardly any units logged in and would not communicate (but one did as the Pi replayed the login message that comes from the unit). So any ideas of overheating went out the window (it’s cooler here today anyway than normal).

At this point, I’m sitting with a perfectly working wired machine, a laptop that seems ok and ESP units that are failing to get through – and resetting – after many hours of operating perfectly.  The laptop is seeing my two access points and next doors, intermittently – they are actually disappearing and re-appearing. Next I started to turn off all the ESPs, no difference, the mobile phones – no difference. My wife who by now was in bed reading said that the WIFI said it was disabled.  I even disconnected the Raspberry Pis from the network – no difference, our neighbour’s weak signal and our two strong signals were turning on and off, on and off on my Windows 10 tablet.  I turned off the dish and the router – this left the neighbour’s signal – still turning on and off about once a second. Turned the router back on – turned the phone on and turned on WIFI Analyser on the phone – I could watch the two WIFI signals come on full strength – and turn off – once every few seconds (I suspect even though it has a 1 second refresh it’s response is slower). I turned the entire Pergola off (PWM solar powered lights – actually disconnected the battery – no difference.

I need sleep.


Orange Pi, BAIDU and foreigners

Updated: Do they just have it in for me or is this typical? I’ve been trying to get an account with Baidu for some time as some of the Chinese suppliers often put firmware up there.

So, armed with Google translate, I went off to get an account, filled in the international telephone number so they could send me a code and… received a code – which didn’t work. Accordingly the web form decided that there might be some unusual activity going on here and insisted on sending me a code – but this time, no international numbers are accepted. I’ve tried 0044, +44, my number without a prefix etc, makes no difference.

So now if I start from scratch, I can log in – CONGRATULATIONS – but first we just need to confirm by telephone….

I have a horribly racist tendency to think they really do not want foreigners in there.  So now I’m waiting for the 1000s of responses to say you all have Baidu accounts outside of China.

Meanwhile the point of all of this was, I was looking for a recent (so called) Raspbian image for the Orange Pi – just to see if it is any good. Well, the jury is out on this – but I found it on someone’s Dropbox account if that is of any help to others. 800+ meg.

Looking at the Orange Pi site this version has just been made available although they screwed up the links – hence the address I’ve used.

After three attempts at downloading, I finally managed to blow an SD with the image. The red light came on and shortly thereafter, the screen lit up to ask me for a password. Attempts at “orangepi” failed – but “root” and password “orangepi” took me straight in.

The screen was set to a fairly low resolution with the menu slightly set off my screen which didn’t help. It had an “old” look to it. There was a version of “Arduino IDE” on the desktop – I ran that up – very early version 1.1

I noted under the start menu, QJACKCTL – for audio control – I tried that – it immediately came up with “Could not open ALSA sequencer as a client. ALSA MIDI patchboard will not be available. When I tried to close the message it took a couple of attempts as strange things happened to the screen. I’m guessing this has not been properly implemented. I pressed START on the JACK connection and all mannter of errors came up. I closed the lot. I’m guessing audio is not going to work.

Monitor settings – unable to access monitor settings.

I pulled up a browser and that worked – so the Internet connection (hardwired) was working.

I tried SCRATCH – changing window size resulted in the edges of the program disappearing – as the window resized and the program within didn’t!! No sound.

A check of the Debian release version suggested 7.6 – other commands which might have given more info failed to work.

With the issues I was having – I figured I’d try the other login option-  openbox. That rendered a white screen with no control – only one way out of that.

I’m beginning to see how why the link on the Orange Pi site was blank… but what I don’t understand is.. WHY do people publish stuff that clearly just does not work.

Verdict: Give this one a miss unless you know something I don’t.




The new ESP

In case you missed it – extracts from forum conversation with Swee Ann Teo, CEO of Espressif about the new chip – which I understand will have Bluetooth as well as WIFI and be a lot more powerful. Also in that discussion is a promise to support the existing chip for several years. New chip a little more expensive, existing chip a little cheaper!


“The overall architecture of the chip had been totally changed since ESP8266, and we are kind of relieved that it works….
And performance has been bumped up quite a bit! We are going to have 100Mbps sustained throughput, and EMMC interface as well. There is a lot more RAM, to go with that data rate. The same 7 external component BOM is still possible, and maybe less.
We measured about 400DMIPS on the new chip. WiFi uses less than 30DMIPS. I have no idea yet what the Hackers/Makers/Developers are going to do with that 370DMIPS and 100Mbps of data.….. we have seen hints that it can be very very low power. Low power chip design….. “

So – something to ponder – more when I know more.


Blynk App

Blynk[4]I’ve re-written this blog today – as the people at Blynk have been quite useful – promising to fix some items I’ve griped about/commented on. I hope they don’t mind me pinching some of their imagery.

One of the problems with home control – is making a nice web interface that is also powerful.

and with that in mind…  of my readers recently brought my attention to  - I put the link in as that spelling makes it a little hard to find otherwise.

Now if you look at their site – they show a really nice mobile dashboard – see my screen grab on the right - and that IS achievable – kind of… but I think there’s a way to go before this takes over an utterly destroys the likes of NETIO or my own JQUERY MOBILE efforts. But read on.

So – you get the APP for free (well, for now – if they keep it down to a couple of quid I doubt anyone would mind) and you select gadgets like on off buttons, graphs, gauges, LEDs etc.  a REALLY nice selection of the type that NETIO should have done but wasted the opportunity to do so, such that many of us are moving away from that package and seeking alternatives. So with BLYNK, it’s easy to make a nice page full of buttons and lights.

The next easy bit – take an Arduino or an ESP8266 using the Arduino-ESP development environment and drop in a program with nothing more than code from them…. and a connection to your WIFI – and BOBS YOUR UNCLE – you have an app on the phone and you can turn things on and off or PWM or read the state of analog inputs.

It sounds like NIRVANA but for me that is no good at all. Firstly I’m not interested in controlling on gadget, I’m interested in controlling a BOATLOAD of them.

However, as those of you who’ve been following my blog will know, Node-Red has answers to all the world’s problems and as it happens, there is a set of NODE-RED nodes to let you intervene with Blynk. As of this morning I have most of their controls working alongside Node-Red and the rest of my kit. So essentially you can have Node-Red talk to the APP – and of course Node-Red can then talk to everything else via MQTT – or maybe you want to control pins on a PI – well Node-Red can do that too.

But before you get TOO excited there are currently a lot of issues:

1.  One page per “application” – and switching applications involves disconnecting from one and connecting to the other (2 button presses as well as moving across to another application). 

2. Turn off the power to the end gadget using the BLYNK code and back on – it does not remember it’s original state – and the phone app can’t tell the state.  Of course if you don’t use their code, you could write a little code on your ESP or whatever so that when an output is turned on – you store it in EPROM… yes, but then after power down and up – you restore the state of the output and…. here’s the killer,  there’s no way to restore that state to the button on the phone!!  They’ve said they will fix that – I need to be able to say to a button on the phone “Look like you’re ON or OFF”.

I HAVE discovered a programmable timing READ event on for example the GAUGE  so that when the App page opens I can go get the voltage and update it – this needs to be extended to buttons, lets etc.

3, If you give the app to your WIFE – the apps don’t yet stay in sync. They say they will fix this.

4. There are no small up/down buttons or a small display – so if you want a page full of timing controls for your heating – forget it – I have asked for small, simple up/down buttons and a small display.

5. Currently the only timer available on the APP is elementary – send something at a given time – I’m not sure I even see a use for that.  What is needed is something that will send a signal when the APP or a given page is ACTIVATED – and then perhaps every second (programmable) – because otherwise all your gadgets have no way to know, other than manual button pressing, when to send status info!! There is a PAGE timer apparently but I’ve not found it yet.

6. No haptic feedback – feels odd when you press a button and the phone doesnt’ buzz.

7. Instead of controlling real IO pins as you might when using their ESP or Arduino software, you use VIRTUAL pins. There are around 30 – I’d rather have 100 – especially when they implement multiple pages per application.

8. Some things like the excellent RGB control has a fixed name – not much use if you have 2 on one screen.

9. Buttons etc show the “virtual” or “real” IO number you use – great for debugging – utterly pointless on the end user display – I can see my wife asking “What’s that “V10” on the button for.  They really should have EDIT/REVIEW/RUN controls so you could on the last one turn off that stuff.

10. You have to press the RUN button a lot and you can edit stuff at any time – great for me but do I want a family member messing with this? No. I think really the edit etc should be done under a password or SOMETHING so the default mode is RUN.

App[4]So LOTS of issues and let’s hope they get fixed – I have asked and they’ve been positive up to now.

So why am I even bothering.

On the PLUS side:

1. instead of using THEIR server for the APP and Node-RED to talk to (sometimes there IS an annoying LAG) – you can put a copy of their central server on a PI so you’re not relying on a third party…

2. The App display is LOVELY.  The LCD is great, the LEDs are great, the graphing looks good, the joysticks look good etc.  Needs lots more widgets but in minutes you’re up and running and making your own screens which your non-technical partner will love to use.

So – here is my little test app – and here is my NODE-RED info for controlling lights – notwithstanding some SEVERE restrictions mentioned above – this is actually running and doing things reliably.



Where we go from here is entirely up to the guys at Blynk – this has so much potential – but I need WAY more – multiple pages etc… this only controls  tiny fraction of what I have running right now. Don’t forget if you’re not into all of this – the APP will run with an ESP or Arduino stand-alone.   But WITH this – so much more because with Node-Red functions which are just simple script – you can do so much more.

Oh and thanks to the guys writing in with updates or corrections!!



Pion One

No, I’d not heard of it either but I recently received a parcel in the post with a new ESP8266-based board – and a bunch of modules.  The description on the box says “Iot, CLoud Supported, Plug  & Play Modules, Android App, No Hardware Programming Requirement, API supported”.

Pion OneAnd with that – here’s the board. Measuring around 50mm * 45mm it’s a bit bigger than most of the ESP boards out there – but then it has all the connectors ready to go. The company do a range of plugins – everything from the DHT22 modules (so you get the DHT22 on a board with a lead that just plugs into the Pion 1), a relay board, reed switch, moisture detector, gas detector, servo motor, button, moisture detector… I’ve also included at the bottom a pic with all the modules I have.

And it’s all decent quality stuff – I was about to laugh at the moisture sensor after my previous attempts at plant watering as the solder-based prongs don’t last a week – but these are gold-plated (that’s not very clear in the picture).

So basically if you’re a little hardware-averse – you just plug stuff in and go.

Now- the box does mention and Android App, unfortunately there was absolutely NO documentation with the board, so I went off to their website – and…. ended up with an Apache2 default page. Oh, dear….

I did however have more luck with  which has a load of documentation.   The only problem with THAT is that it tends occasionally to feature the odd Chinese character!  Anyway, within there is an English document file – and recommendations to go get the PION ONE app for Android.

Nothing. And no screen shots  so clearly this is all new and preliminary – when the APP shows up I’ll be sure to give you an update – and I’m just going to point the SEEED people to the blog so they can comment.



Blog Improvements

A little update for you…. I’ve added something new to the blog – user profiles – and I’ve taken something away. Lots of you have taken the time to register for the blog – but lots of folk visit and don’t bother to log in – I figure something for something – so logged in users to the site get an expanded menu – with a new profile system for those of you who like to put your pic in there and a little about yourself. I’ve taken away the about and contact pages for passers by (but not for logged in members) – and generally I think moving that stuff to the top menu makes life a little easier.

I hope you like the changes and encourage you to visit the USER area where you can put a couple of pics in there if you want to.

I’m currently working on my little touch board – the thermostat was yesterday – now I’m working on lighting control and more – seems to me this is a great way to tie the Raspberry Pi controller and the satellite ESP8266 boards together.  When I’m done I’ll document as much of it as I can – I must say that Nextion don’t make it easy to blog about your coding – but Node-Red of course DO. Some exciting new developments therein – keep looking in.



Nextion Talking Thermostat

main page on Peter Scargill's talking thermostatYes, I changed the title. As often happens with these things, I got carried away.

The Nextion display is a touch-sensitive intelligent display.  Essentially, you buy the display and you program it with a free editor serially – which lets you easily place icons, buttons, images, text, gauges and more on the screen. For any of these you can have the unit send serial messages on press, release etc. You have serial control over the display itself and you can have as many “pages” of information as you want.

So for example if I place a text box called “mytext” on page “home” then I can send the serial command home.mytext.txt=”Hello”

Easy. So it can then talk to just about any micro – Raspberry Pi, ESP8266, Arduino etc via a simple 2-way serial link. What’s not so easy is the fact that it is taking them a long time to get the editor and interpreter right and some stuff just doesn’t work – even basic comparisons in it’s internal interpreter. Having discovered that when I first looked at the product, I put the Nextion to one side for a while. You can’t do multiple copy and paste, if you delete a library image you have to change the ID of all other images you’ve used – the list goes on – my suspicion is that one overworked, underpaid guy is doing all the development and it’s the first time he’s done this. I could be wrong.

NOT withstanding the above – the display has tremendous potential and you can work your way around most of the issues.

This week I began to think of the display from another angle. What DOES work is image, button and text placement, serial updating and serial out. So basically if you think of the Nextion as a programmable dumb terminal, then THAT works and works well once you get used to and work around the issues (images stored on the device are stored by number. Get rid of one and all your references are wrong. Just little things like that.

Security on Peter Scargill's talking thermostatI began to ponder how it would be if I used Node-Red on the Raspberry Pi (or on anything that handles Node-Red and serial, really) to do the work – after all, there are no real limits to program complexity on the latter and it works – so use the Nextion for what it is good for!

With that in mind I set about installing the serial node on Node-Red – that went very smoothly (using Raspi-Config initially to turn the serial on).  The first hurdle however didn’t take too long – the Pi crashed whenever I tried to use serial in. It turns out that RPi already has it’s own use for the serial – as a terminal. So this has to be disconnected first.

sed -i "s|T0:23:respawn:/sbin/getty -L ttyAMA0|#T0:23:respawn:/sbin/getty -L ttyAMA0|g"  /etc/inittab
kill -1 1

At a terminal I issued the above commands – in other words commenting out the start-up condition that has the Pi using the serial in interrupt– and also killing it now to save having to reboot.

That done, I tried again – there is still some information in the serial buffer at power up which I’ve yet to figure out how to stop – but matters not, it’s easy to clear out the serial buffer during init in Node-Red.

controls on Peter Scargill's talking thermostatThe next hurdle… the Nextion (quite reasonably) expects normal 8-bit serial strings – and sends back normal 8-bit strings – in each case with 3 characters appended to the end. FF FF FF.   or 255, 255 255 (why couldn’t they use \n like normal people… however…), All of that is great but Javascript, which is the base language behind NodeJS – and hence used in the functions of Node-Red – uses 16 bit strings!!

I had to get onto the guys working on Node-Red for help here – and to cut a long story short, a simple function added to the Serial nodes sorts that problem out. Great support is available for Node-Red on Google forums.

So in my case I wanted a simple thermostat display with up and down controls. I have a property which we holiday-rent out in the summer and that is about as much as I’d like end-users to control.  On the other hand, when we’re at home I want to do so much more.  So I decided that what was needed was a basic stat display page, a login page, a menu page then as many extra pages as needed.

The only control on the home page other than up and down would be a little menu button taking you off to a keypad log in – and maybe an “about” page. That would be the end of the line for our customers who would then have only one option – return to the home page.

For my wife and I, successfully logging in would then take us to a menu – and all pages would come back to that menu – which would also include a log-out button and of course I’d want RGB lighting control, heating adjustments etc etc….

Armed with a dumb Nextion with buttons and textboxes in place, I set about writing code for Node-Red. I would need outputs for serial, debug and MQTT to control things based on key input from the display.

Node-Red flows on Peter Scargill's talking thermostat

One of the things I like about Node-Red is that you can outline things long before you actually put code in – and that helps simplify programs. So as you can see here, I have serial coming in – it gets converted from the format that the Nextion understands – to simple text and back.  In addition you need start-up conditions – and display automatic updating – hence the two inject nodes. Using global variables for temperature and set temperature, I wanted it so that if I changed those variables elsewhere they would update on the display.

Pallette on Peter Scargill's talking thermostatThe Nextion online manual will tell you how to upload fonts and images to the Nextion – you can use buttons – or you can use images and overlay rectangular hot-spots on the image.  Their own buttons are AWFUL and it is hard to get fonts off your PC to look good as there is no anti-aliasing – however – by a combination of static images and using variable text only where actually needed, it is possible to get a nice looking screen or screens.

About page on Peter Scargill's talking thermostatAt some point I will document all of this – the “process commands” function is the most complex and even then, really it is mainly a set of nested switches and little else. The thermostat logic I’ve done separately but may do again to take into account humidity and outside temperature – not rocket science. They key here is that the Raspberry Pi seems to be quite solid as long as you keep SD writing to a minimum. It is now quiet simple thanks to BerryBoot to make backups…. as long as Nextion don’t totally annoy everyone by releasing the editor before it is ready – I see a bright future for this setup. The display I’m using is the 400*240 touch display. I have a pop up page for selecting light colours as I plan to use this for lighting control – not quite there yet but the mechanisms are in place – right now I’m having way too much fun doing the thermostat bit!!

As for the display, well basically for inspiration I went off looking to see what the pros are up to with displays and a particular Honeywell display caught my eye. Next thing I was off to PowerPoint to design the screens – it now looks only superficially like the original – but I liked the way they split up the main screen into sections.

Oh, and these displays are NOT expensive – check out AliExpress for example.

International options on Peter Scargill's talking thermostatNow, you might think “enough is enough” but I’ve also been working on speech for the Raspberry Pi and as of today I’ve pretty much gotten to grips with that – and so I thought – why not. You’ll notice on the “about” page over on the right, there’s a “multi-lingual audio introduction” – and why not – it’ll give the guests a laugh. The stat function has 2 on-off times a day and weekdays and weekends are programmed separately. There is a manual override for the “set” temperatures which lasts until the next change of settings. So if you set the unit for one temperature in the morning until lunchtime and another from lunchtime on – manual override done in the morning will last until lunchtime before going back to the default settings.

My third success of the week – taking my router back to factory default seems to have solved the “race” condition that’s been plaguing me – which means my ESP8266s are working again – the good part of that was that I originally thought it was the ESP8266s themselves causing problems so I’ve tightened up on handling lost of WIFI situations which seems to have made them more or less bullet-proof.  As of this morning the full set of thermostat background controls are in and all that is left to do is implement the actual logic – a little something to stop excessive turning on and off, a little hysteresis…. and we’re reaslider on Peter Scargill's talking thermostatdy to rock!

Next step – web-socket to serial conversion – though I could use MQTT – so that I can have a slave one of these stats powered by a little ESP8266.  Our cottage has upstairs and downstairs and so it would be handy to have both the master control and a copy of that upstairs.

NEXT: Coming up – lighting control…. I have already made the panel (who knew I could design graphics) and there’s a little logic to go to make it work but as you can see here the slider panel is well under way…

Despite the resistive interface, the sliders are quite responsive and should work well as a local alternative to my normal JQuery Mobile panels for local use around the house.


Raspberry Pi Serial and Node-Red issues

SOLVED: Node-Red serial I/O


Looks simple doesn’t it – tie RX and TX together on your Raspberry Pi and press the button – text comes out of the other end – except that it doesn’t. More likely the Pi will CRASH (not something you see every day).

Serial out seems fine – no error messages, you can change baud rate and according to my scope, all is fine on pin 8 of the RPi2.  Input on the other hand, can cause interrupt issues, messages on the console and crashing – and almost never actually produces any output.

So what is the problem?Well, one of the guys at the Node-Red forum set me onto this link.

And therein lies the problem – by default – the RPI uses the serial port for communications. Trying to add another hook to the serial in interrupt – kills the Pi.

The solution is simple – extracted from the above link.

  1. edit the file /etc/inittab as root (I used “sudo vi /etc/inittab”)
  2. change this line: T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100 to#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100. I.e. comment it out, and save these changes.
  3. run the command “sudo kill -1 1” to pick up these inittab changes

And that  - was that  - I now have comms in and out  - the idea being to put a serial display such as the NEXTION onto the Pi with simple touch input commands – and an output display showing status, temperature etc. DODDLE in Node-Red once you have serial up and running.