Category Archives: Uncategorized

Life

movement sensorI was just getting settled into my new office when BANG – a flood –not the global warming type but the crappy plumber type. So – right now the place is a bombsite and we’re sleeping elsewhere at least for tonight – indeed could be longer if they can’t get the water partly running.

Meanwhile a couple of items turned up in the post this morning which might interest you. Firstly I’ve been looking for small movement sensors – most of them are WAY too bulky – and I picked up a couple of these IR movement sensors from Banggood! 3 for a fiver. You can see how small the thing is comparing it to my normal size hand!

I already have a larger and slightly more obnoxious sensor inside. I need to put a light sensor in as well because I have lights coming on in my office during the day when it’s just not necessary.

nscopeSo tonight I decided to give it a go (I have half the mains on – including my office which fortunately has electric heat). I hooked one of the units up to 5v and ground – (the outputs are ground, output and 5v in that order. Ground is obvious – lots of tracking and a minus sign). I hooked a LED to the output, switched on and… zilch.

Fortunately a little while ago I was fortunate enough to become the owner of a little NSCOPE – a USB low-bandwidth scope with breadboard – a wonderfully useful gadget. Well, that WORKED and on close inspection they have a 20k resistor in series with the output – clearly not zmotemeant for a LED but just fine for an ESP8266 or Arduino. The units pick up movement several metres away and at a range of angles… I’m thinking…. hole in the door frame – unit inserted in there somewhat recessed to reduce it’s angle of operation… picks up people near the door….

zmoteMeanwhile, one of the other competitors on the esp826.com annual ESP8266 competition (which I do not expect to win – mine is item 75 – vote if you like it) send me one of his units – it’s called a ZMOTE – a neat little infra-red learning remote. 

I’ve not gone into it yet due to the flooding but you can find out about it on the ESP8266.COM website – I’ll do a write-up when I’m not running around with buckets.

Facebooktwittergoogle_pluspinterestlinkedin

Node-Red Thermostatic function

So – I was asked recently if I would go into detail about the Node-Red thermostat node I wrote some time ago.. I was at pains to point out that I’ve not developed this further because I’m finding FUNCTIONS to be more useful. With the latter it is easier to just “dig in” and make changes – important when you’re developing..

The whole flow of my Thermostatic controls with add-ons, bells and whistles is way too much to go into – however the central function – the bit that controls the temperature is really quite simple.

 

thermostat

There it is – so every 10 seconds it runs, reading some global variables and outputting an MQTT message to turn the heater on and off. As you can see it gives a summary underneath (I know the Node-Red guys are not keen an adding visual elements but that status display was a GREAD add in to functions).

And so the output just goes off to an MQTT node to turn the heat on and off. But what’s inside the function?

I originally put it in here but it is so long it will bore the PANTS off anyone only vaguely interested so I’ve put the entire code into a snippet on Bitbucket.

https://bitbucket.org/snippets/scargill/erRdk

So just a couple of things to help with anyone wanting to look at this – PLEASE don’t ask me to support this as by the time you read it I’ll probably have changed the original – it’s a work in progress.

However reading the code above you’ll need a little help.

var stat=context.global.thermostat;

The above is just me being lazy – “stat” allows me to access the global var and it’s bits without having to type in the long name – I’ve a large object full of things like 5 sets of times per day during the week, same again for the weekend – each with an accompanying target temperature, there’s a manual offset to the temperature and last but not least, in the ESP board (MQTT) that is sensing the temperature I also control some serial LEDS to light it up blue when the heat is off and orange when it is on  - that of course is totally over the top but I like going over the top.

There is also a frost temperature setting in there… most should be fairly obvious and if anyone wants to cannibalise this for their own use – by all means.

Facebooktwittergoogle_pluspinterestlinkedin

Updates

Just some minor updates…

If you’re using Blynk server locally for your IOT there is a new update – a fix for crashing with Raspberry Pi 3 and some other fixes by the look of it – link is here. Incidentally I just rename the server file to server.jar and restart Node-Red when they come out with a fix. I should say that mine is running on a pair of Raspberry Pi 2 boards and I’ve not had one error out of it in the last couple of months. I’m using the node-red-contrib-blynk-websockets library which continues (unlike the non-websockets version) to operate flawlessly. Now if only Blynk would get rid of the fixed on/off titles on buttons…

MQTT – TuanPM version – I noted a minor fix in there which explained some issues I’d had with retries on bad connections. About a month old but just in case you missed this - https://github.com/tuanpmt/esp_mqtt 

Thanks to David Miles for alerting me to this cheap cat poo sensor – ordered a couple of China as no-one in Europe seems to be selling them on Ebay - http://www.ebay.co.uk/itm/272041590945  that should alert me to any cat-accidents – I’m wondering if it will pick up on kitchen smells – I’m thinking for our holiday cottage rental it could be useful to long-term monitor the air.

The code we use for our own IOT which is featured in Home Control 2016 and the Serial Nextion project (don’t forget to vote – item 75 in the ESP8266.com competition) has been updated to handle multiple SSIDs and is something I keep going back to and improving within the limitations of rapidly decreasing .TEXT memory in the ESP (my one gripe about the chip).

Still finding success with Imperihome Android App but the lack of general purpose buttons, sliders and LEDS is beginning to get to me – so many people putting in requests for specialised hardware, it seems to me that providing generalised inputs and outputs seems a more sensible route – I guess they must get a lot of mail as I’ve had no feedback from my requests. Hence I still need Blynk and node-red-contrib-ui to perform certain functions like setting on/off times and heating schedules for my thermostat.

And that’s about all that is new for now.

Facebooktwittergoogle_pluspinterestlinkedin

The Saturday Update

OmegaFor those interested – I’ve been quiet the last couple of days as we’re ploughing ahead getting the new office up and running – got walls up and ceiling almost done – got power and Ethernet in last last night and today we’re off to get wall sockets and worktops. I have to say I have never known joint aches like it!

The dangers of controlling stuff over the Internet became apparent last night as the heating went awol. At some point we realised we were roasting to death at about the same time as the Sky box indicated it has no Ethernet. It turns out that in the process of wiring up Ethernet for the office, we’d uncovered a flaky connection to the main access point which provides all the ESPs with connectivity and feeds the Sky box. 

Still – though it took until 1am in the morning to find the problem, at least it’s a clean problem with a clean solution – replacing an RJ45 connector.

Anyway a package turned up for me yesterday which I’ve not had time to do anything with yet - the Omega and a bunch of peripherals – so expect a review coming up soon.

Facebooktwittergoogle_pluspinterestlinkedin

Nextion Progress

Things have come quite a way since my first stab at using the Itead Nextion displays with an ESP8266. I now have a fully working thermostat display running on MQTT – but I’m beginning to wonder if 56KBaud is pushing it a bit for the software UART. Now that I’m pushing a reasonable amount of information onto the little display, I’m very occasionally seeing small glitches in incoming information when pushing buttons. Not enough to worry about but perhaps drop the speed down a notch.

Original Nextion Display

New Nextion Serial Display

Facebooktwittergoogle_pluspinterestlinkedin

Coding the Nextion

At the risk of repeating myself (apologies to regular readers for this first para) the Nextion display is in fact a range of touch-LCD displays from small to large.  The thing they all have in common is a a complete programming environment where, by downloading a desktop graphical tool, you can lay out the display, what it will show and how it will respond to button presses. All of this happens serially so that you program it serially via, say an FTDI (usb-to-serial interface) and when you’re done and a button is pressed, serial output is sent back out to your application and you do what you want with that.

 

So first things first – what it IS, is an excellent low-cost way to get visual controls onto your IOT device. What it is not, is fun to program. There is a language interpreter built into both the display itself and the desktop “debug” simulator – and I would summarise by saying that it is probably the worst interpreter I have ever experienced since Bill Gates 5K BASIC back in the 80s.  However, it works – and with a little effort you can soon bypass the inefficiencies of the interpreter and get the job done.

NextionA friend of mine and I have been looking to use these in our IT projects for some time – and while a serial interface is great, it isn’t much use if you just want to stick a thermostat control on a wall 2 rooms away from where your controller is.

As many of you know I’m a Raspberry Pi/MQTT/Node-Red fan and so everything I do is oriented towards making peripherals that will talk via MQTT protocol, wirelessly back to the Pi – hence my interest in the SONOFF units as they are a VERY cheap mechanism for controlling lights etc – using my own software or that of others which you will have seen in here.

And so it was that Aidan and I set about making a little board to go on the back of the Nextion – the first one came back from the Chinese supplier with the top grounding disconnected – that gave us the opportunity to do a MKII which we’re expecting in a week or so which we actually think will make a GREAT general purpose board for experimenting with the ESP-12… but more of that later.

So – we’ll not concentrate on the communications angle here but on how I managed to get the nice buttons.  That entire display is actually put together from TWO images – thanks to a feature of the Nextion called CROPPED IMAGE

In the Nextion EditorOne apparently BIG problem with the Nextion displays is their inability to handle transparent PNG images – like round buttons. On the surface this might be fine if you have a static background colour and can match it around the edges of the button  -but this is often not the case. In order to work with limited processing power (and I suspect the limited programming ability or program space if the interpreter is anything to go by) they like to handle rectangular areas – these are easy to move about at high speed.   But they have come up with a good solution to this – the cropped image.

So let’s say you make 2 images – one with everything turned OFF and one with everything turned on.  A BUTTON can be a rectangular area with text on it – which looks ABSOLUTELY AWFUL – or it can be a CROPPED IMAGE – showing part of the chosen image depending on the state of the button. So a rectangular area over a round button showing a window into the overall ON image or the OFF image will give the impression that only the rounded area is changing – and you don’t have to worry about gradiated backgrounds etc.

Two imagesYou’ve seen the video – now here are my two images used to construct the display.

In essence you use a basic image with everything shown turned off – i.e. the buttons are nothing more than a single image – in my case a pair of Powerpoint images – I use Powerpoint as it is easy to align images,

Use of the second image – with everything turned on – is controlled by the Nextion itself – that is selectively showing parts of that second image as needed – of course this is just a very BASIC example – you can have multiple pages, you could programmatically select more than just 2 alternatives (3 state button or LED… and the Nextions – if you get TOO ambitious – can handle an external SD for even more images. A cheap throwaway 256Meg SD holds quite a few images.

Thanks to advice from friends and people in here I found quite a few images – I put a link in the comments to a previous article – any transparent PNG images can be pulled into Powerpoint or similar to make up your basic pages  - the cropping ability of the Nextion makes it possible to turn this into a dymamic display.

And so we come to the Nextion interpreter which is HORRIBLE.   How do I get a button press (dual-state button) to send out the right info – this might look like a mess but when you get into the Nextion editor and have a go – you might thank me for this  - no it isn’t my lousy programming that makes it look like this and no you can’t put it all one one line and yes, amazingly you can’t have a space after the IF statement – I’ve thought of volunteering to go over and help them with the interpreter!!! But it works so once you’ve done one – it’s a copy and paste job.

printh 70
print "nodered~tog4="
if(bt0.val==0)
{
print "0"
}
if(bt0.val==1)
{
print "1"
}
printh ff ff ff

As that data comes out of the Nextion, my ESP software picks it up, sends the message out over MQTT and triggers a timer for the little cheap phone buzzer for haptic feedback.

When we get our new boards and I get my office put together – I will endeavour to go into that side of the project – as I see a lot of future in this as a high quality, wireless touch display.

Facebooktwittergoogle_pluspinterestlinkedin

Free Dials and Buttons

I wonder if we can all do each other favour here.  Every time I go looking for buttons, slide switches, gauges etc for my projects – like the Nextion – at least 90% of the so called FREE ICONs and PNGs – by the time you get to it – it’s owned by Getty and Corbis or similar and they want ridiculous amounts of money for them.

Can those who have links to DECENT, free home-control/IOT style icons please put links in here so they’re all in one place… 

I found these,,

http://www.graphicsfuel.com/2012/10/toggle-switches-ui-elements-psd/

But they are PSD and I’m afraid GIMP really does not like them – large transparent PNG files like this would be marvelous – the first set of on-off buttons on that page look great – and free but I for one don’t have the tools to turn them into transparent PNG……

Facebooktwittergoogle_pluspinterestlinkedin

Enter the Pixie Pro

This morning I went off to the post office to pick my new new Pixie Pro – making sure that the tax man got his share and that the post office got their rip-off “handling fee” of £8 – yes that’s £8 pounds not dollars.   Not that you have any alternative but to let them “handle” the package. You’d think the government would give them some of the duty or VAT!

Anyway I digress with my deep-seated dislike of being ripped.. Opening video – well, you have to have an opening video..

 

 

The Pixie Pro – so firstly – this is NOT one of the cheapest small PC boards  indeed for the cost of it you could buy 2 or more of the others – but then it is not just another Raspberry Pi!

Heatsink on the Pixie ProMy Pixie Pro came with a HONKING great heat sink – which bearing in mind that my Orange Pi could cook eggs, is a welcome addition. This will end up in Spain with me where it gets very warm and so a cool running board is a good start. 

Taking a look at the specification, not 512meg of 32 bit RAM, not one gig but 2GB of 64-bit DDR3 RAM!! The processor offers a quad-core ARM Cortex A9 running at 1Ghz plus 2D and 3D GPUs. The wireless interface is described as state of the art, offering 802.11b/g/n/ac. Bluetooth 4.2, NFC, GPS and mobile broadband interfaces.  Not your average Pi then.

Underside of Pixie ProThe board measures 52mm by 91mm and has 2 USB type A ports, one OTG port, a micro-HDMI output, 2 microSD slots and a 3.5mm line out with TOSLINK optical.

No, I’m not finished – Gigabit Ethermet, PCIe, SDIO, 2 MIPI, SATA II, RGB555, USB2.0 HS, CAN, SPI, 2 Uarts, 2 I2c and several GPIO ports.

I’m done now.

So there it is – a veritable powerhouse – but is it any good – that will be the subject of my next related blog – you can have as much power as you like but without the software -  what use is it?  Now, normally I tend to put Debian on these things but I’m half inclined given the claims above, to start with Android.  Until the next time.

Facebooktwittergoogle_pluspinterestlinkedin

Monday Update

Node-Red-Contrib-UI: Just a quick update … not heard anything from Andrei re: node-red-contrib-ui recently – I could not get his experimental version to work and I’ve heard nothing since. I do hope the project is still alive. I have high hopes for it but right now the display is a bit messy.

Blynk:  the one remaining issue with that UI for me was the fact that when paused it was unaware of changes to your target board. So my assumption is that the designers figured you would ONLY control, say your Arduino or ESP from Blynk itself – the reality is that you might have a second user on Blynk – or a completely separate set of control instructions going on – so in my case I have Node-Red controlling the boards – and talking to the local Blynk server. The SERVER is aware of changes – as logging into the APP updates the display – but when the app is paused it seems unaware of changes when brought back online.  I say WAS – because as of this evening – there is an update to the APP – and you need the updated server.jar file if you’re using a local server. I’ll do a new blog on this but it all seems to work just fine… Could this be the one??

Coming soon a review of the Roseapple Pi which looks to be very powerful with 2GB of RAM and USB 3!

And that’s it for now.

Facebooktwittergoogle_pluspinterestlinkedin

Orange Pi PC Setup

Here's a new  video  as we've changed the script since the one I had up here yesterday - it takes a long time to do the install and so here is what you get when you've done the install.

The script now does it all. So - take a look at the previous blog on the subject where I refer to a Debian installation  which you need to put onto a microSD - and then copy 2 files over before utilizing it. Once you start the Orange Pi PC up - it will appear on your network as "orangepi" - you should be able to access it without referring to the IP number.

On it's own it will come up in graphical mode but I did not use that - instead I used winSCP to open it up and started a terminal session - at which point it asks you to type something in to re size the image - and reboot. Do that and come back to the terminal.

https://bitbucket.org/snippets/scargill/Md4jr

Grab the above script and put it in the /home/orangepi directory on the OrangePi - go in as that user (password orangepi) - don't vary from this - don't set up a root user or use other images etc....   once in - change the permissions on the script to give the owner execute permissions.

Then run the script in the terminal ( ./orangepi.sh) -  at the first set of questions select a for all - and then grab coffee you will need it.  Occasionally you might be asked to select directories - go with defaults - you will also be asked for passwords - if it is the orangepi password it is orangepi - if it is for something that has been installed I suggest the same but you can use any password - I use the same one throughout.

Don't deviate - it will take over half an hour likely.  At the end the unit will reboot and you are all set - other than password security on Node-Red which you may not need anyway.  Everything should just work - ignore WARNINGS and some daft npn errors.... they look awful but it all works.

The only thing I've not been able to get working is node-red-contrib-ivona - it anyone wants to work on that I'd appreciate it.

As for ports – well I’ve installed GPIO and so this can be called from an EXEC node. Here’s a simple example:-

image

On power up – initialise a global variable (let’s call it context.global.pinstates) to 0.

When trying to output to a port – (lets’ say 14 -  where the command is GPIO WRITE 14 1) check first to see if it has been used and if not – send a MODE command first (ie GPIO MODE 14 OUT).

Here is the code for that function.

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

if ((context.global.pinstates & (1<<msg.topic))===0)
    {
        context.global.pinstates |= (1<<msg.topic);
      var tmp=msg.payload;
      msg.payload=" mode "+msg.topic + " out";
      node.send(msg);
      msg.payload=tmp;
    }
    
    msg.payload=" write " + msg.topic + " " + msg.payload;
return msg;

[/pcsh]

Simples.

Update October 2016 - Bill Price wrote in to comment that someone had fixed an issues with audio and so I'm including this link....

 

Facebooktwittergoogle_pluspinterestlinkedin

Raspberry Pi hanging on reboot

PiOk, this is a favour for my pal David Miles. He’s struggling with a PI which stops right at the last minute when powering down or rebooting – as per the image here.

I’ve never had this trouble so I’m not a good one to comment – anyone struggled and overcome this issue? If so, if you leave comments in here I’m sure he’ll spot them and respond accordingly.

And before you ask, no – still no sign of the little ESP8266/Nextion boards we ordered from China to play with.  I think they’re all on holiday over there.

Facebooktwittergoogle_pluspinterestlinkedin