Category Archives: General

Odds and Ends

Just a few odds and ends… we’ve arrived safely in Spain and I’m not getting quite as much blogging time as I’d like as there are repair jobs to do – but I managed a little item on Node-Red earlier – I’ve had people in here asking for simple-use examples – so that’s the first.

Gauge Progress: I’ve not forgotten my HTML5 Canvas gauge – it’s coming along nicely but along the way I’m hitting minor bottlenecks on image loading – and image pre-loaders are not helping. Most but not all of this came to light when I moved thousands of miles away from home with the attendant delays! I’ll return to this one soon.

Node-Red Menus: Regular readers may recall from earlier blogs that I’ve been griping about the menu in Node-Red being there even if you have only one page. Some may have noticed that a blog reader pointed out a simple CSS solution – well, now there is better – Node-Red master as of now has an option to turn the menu off. I’d give it a day before updating to make sure the latest version had filtered through to updates.

Mint Linux: I wrote a while ago about this – so often these things fall by the wayside – well, I’m still using it – can’t find anything wrong with it on my little black laptop.  It isn’t Windows but for development work – it runs a lot faster on that old hardware than Windows 7 did and everything works right down to my Logitech Bluetooth headphones. Anyone else using this on an Intel-powered laptop?

Raspberry Pi Power backups: You’ll probably know I’ve covered this in the past – various solutions for backing up the little SBCs in the event of power failure. My best solution up to now has been RavPower battery charging units – but not all of them seem to work in the same way. I did find a little LIPO unit that works on one round 3v6 battery but it’s power output would not work for a RPI3 for example (which takes more power than the RPI2. Well, I’ve just discovered and sent off for one of these. It’ll take a few weeks but I’ll let you know how that goes. Anyone bought something similar? How did that go for you?

Facebooktwittergoogle_pluspinterestlinkedin

The Mint Experiment

Anyone who’s known me for years knows I’m a died in the wool Windows man.  Over many years from Windows 3.1 onwards, I’ve done down that road until ultimately all my machines are now Windows 10 – and I have to say that, while it could be argued before Windows 7 that it was not the most reliable operating system in the world, from that point on pretty much all of that changed. I regularly leave Windows 10 machines running for weeks on end and I’m sure they’d keep going for many months if it were not for the only remaining issue- that of pesky updates which Microsoft are determined we have whether we like it or not.

Now to be fair there was a time when Adobe – a company I cannot stand, used to issue updates for Acrobat almost on a daily basis and at least that no longer happens. I can usually tell when Windows wants me to update because Skype conversations become almost unusable and other strange things happen – at that point I reboot the machine and lo and behold – a Windows update is in progress – don’t turn off your machine. Thanks – I’m in a hurry for  train…

In my previous role as IT Director of the FSB, I would take it upon myself, being a hands-on type, from time to time, to try the latest Linux on one of our PCs, only to end up with utter disappointment as it would fail to connect to a WIFI access point or the video would hang over the end or some such issue – there was always SOMETHING – and so I would scrap that idea for a several months before trying again. At one point I used to get hate mail from  members who were clearly selling Linux machines -  for supporting Microsoft! Serious hate mail.  So over the years I kept trying again and always ending up with disappointment. (I’ve never used Linux on my personal machines because yes, I do like the latest state of the art, graphically intensive games and yes I do use lots of proprietary packages such as Magix and others which are simply not available on Linux.

In recent times as regular readers know, I’ve been forced into taking an interest in Linux because Debian (a Linux variation) runs on the Raspberry Pi. 2 years ago I bought a Raspberry Pi 2 (having played with the original Pi, loaded up the graphical operating system and immediately put it on Ebay in disgust at the speed). On the Pi2, I was pleasantly surprised to see that Raspbian ran at a reasonable speed and since then I’ve done many different board reviews and installed Raspbian and Debian on lots of boards, leaning on experts along the way as my knowledge started to build.

A while back I took the plunge and installed Ubuntu onto one of these boards and with help from others soon came to realise that there were not THAT many differences between Debian and Ubuntu and one of the things that has struck me in all this time is how reliable the operating system can be – I’ve a Pi that’s been sitting controlling stuff for well over a year now without as much as a sneeze despite me poking live updated and tweaks into it without rebooting.

Linux Mint on an old Dell laptop

And so with that in mind, last week I took an old DELL E4300 I had lying around which had simply refused to update to Windows 10 from Windows 7 (no matter how many ways I came at it) and which was so old it was really not worth opening up – and grabbed myself a USB stick with Ubuntu on it, ready after maybe 3 years of abstinence and armed with much better knowledge than previously, to try again.

Well, what a disappointment that was. Ubuntu loaded up no problem, with it’s rather dated looking purple interface – and asked me for my WIFI password – I promptly gave it this – and before long I had a working laptop. Or so I thought. The WIFI icon looked broken – yet I could pull up a browser and go on the web  - no problems. I was impressed by the ability to watch video on the BBC website, something that in the past on Linux was just not on.

tmp95E7That enthusiasm lasted maybe an hour. The App store decided not to work – coming up blank. But hey, that was just one program. I noted a nice graphical email client complete with calendar. I set it up and within minutes I had my Google calendar up and running. But as soon as I tried putting in email  - “Cannot get email as there is no Internet connection”. I opened a browser and sure enough the Internet was fine – but still that broken WIFI indicator. From there, things went downhill – it could not store draft emails due to a permissions issue and – nope – sorry life is TOO SHORT FOR THIS – I was reminded of the frustration of previous years… what HAVE these Linux guys being doing all this time, I thought.

I was in the process of giving up when I read something about Linux MINT. I liked the interface. In the instructions for installation I had to go get PendriveLinux so I could install the image on a USB stick. You should be seeing links here as appropriate. I went off to the official download page and picked the 64 bit version using the Xfce graphical interface as it had been suggested that while simple out of the box, this version had lots of options. I put the Mint Linux onto the USB stick and put it into the laptop. I must admit I found a certain satisfaction in wiping Ubuntu. The installation went well and WIFI came up but this time, no broken WIFI indicator. The taskbar seemed to be missing a battery indicator but It didn’t take me long to figure out how to add all sorts of widgets to the taskbar to make me feel at home (including a battery indicator).

I noted that Thunderbird email was installed and I set that up with my two email accounts – no problem whatsoever… but no calendar. Of course, that’s a plug in and it needs another plug-in to get Google calendar functionality – but all of that took mere moments to organise and now I have fully fledged email and calendar. Granted it is a little slow at pulling in the 35,000 emails in my main in-box – but it’ll get there I’m sure.

I hit a few obstacles on the way - my by now standard VNC server would not have it until Mr Shark suggested I try  x11VNC – that worked a treat.  Then I had it asking pesky password questions every time I tried to breath – that was easy to fix  - then I noted on power up that the KEYRING wanted another password – you’d think I was operating a bank. That went quickly – and from there everything went smoothly.  But this was Linux MINT – about which I know nothing at all. The funny thing was, doing an APT-GET UPDATE showed that in fact this is Ubuntu Xenial… now I’d already, with lots of help from MrShark, modified my all-singing install script for Ubuntu. I didn’t really expect it to work on this machine but having written down the steps to put everything together I thought “what the hell” and ran the script – it failed of course as it looks for UBUNU, DEBIAN, RASPBIAN or DIETPI – and this was LINUXMINT. I added a check for the latter THOROUGHLY expecting a host of horrific error and compatibility errors.

I was with some delight that I returned 15 minutes later to find that not only had the script worked – but without a single error – adding NodeJS, Node-Red, Apache, PHP 7, Mosquitto, SQLITE, MC and several other programs to my installation.  I rebooted to ensure I wasn’t dreaming – sure enough – everything worked.

The laptop has no Bluetooth interface so I plugged in one of those cheap Chinese Bluetooth USB units… and went off to the Bluetooth controls – without ANY hassle my Bluetooth mouse connected!!! I plugged in my Bluetooth headset – it got that – I went off to the BBC website and…news.bbc.co.uk – the Bluetooth headset didn’t connect automatically – so I went to the volume control – it was in the options – sure enough – perfectly synced Bluetooth.

Now if SKYPE video will just work….

Up to now, hours later, I have a nicely usable laptop with all my development toys (well maybe not NotePad++ but there are a couple of decent Linux editors,  my email and calendar, Chrome browser and a full office suite – making an otherwise pretty hopeless old laptop into a useable tool!

Issues: This morning I ran out of battery. A sign came up to say the battery is low – save your work – but that that point the mouse and keyboard stopped working – hence saving work was impossible. A moment later, the laptop shut down. I charged it and it came straight back up with the same message – I had no option but to shut it down (sluggish mouse response as an aside). After rebooting all was well.   Also Skype does not appear to survive power cycling and has to be loaded again.

Facebooktwittergoogle_pluspinterestlinkedin

RGraph with Node-Red

RGraph GaugeHaving gone from spending countless hours staring at HTML5 CANVAS, I’m now at the “meh” stage as it starts to dawn on my how it works.

And so it was that I stumbled on RGraph – or put another way, Christmas for widget-lovers.

If you’ve been following these blog entries you’ll know that Node-Red has TEMPLATES in the UI – and that you can put your own stuff into the templates and that recently the fog has lifted on getting variables in and out of the templates.

In recent blogs I’ve been constantly improving a thermostat control page and that took me off looking for a gauge with two pointers – one to show temperature, the other to show humidity.

And that’s when I stumbled upon RGraph. If you read this – and understand it – you will open the doors to a boatload of gauges, thermometers, charts and graphs so tuck in:

First things first, if you’ve already played with Node-Red in here you will likely have made a /myjs folder (home/pi/.node-red/public/myjs or similar – defined in your Node-Red settings.js file) to put various Javascript files in. Well, add this lot in a sub-folder called RGraph – you can call it freddy if you like but I thought it reasonable to use the name the way they use it. I grabbed the latest stable version from here. Inside there is a folder called RGraph – and inside that is a folder called libraries – I grabbed the contents of that folder and put it inside my /public/RGraph folder. It may be there is a use for other stuff in there – but for now that’s all I’ve taken.

So – then I dropped in a template – made it 6*6 and inside that template I put this lot – code shown below.

Now, if you don’t like my colours – change them. You can change just about anything including the size but you may need to adjust the font size if you do that. Experiment!

To change the two pointers – which I’ve chosen to call temperature and humidity – you might use them for petrol and oil – or whatever….I simply pass MSG as is common in Node-Red – but not msg.template – instead msg.temperature and msg.humidity – you can call them whatever you like.

The point of this is not to demonstrate my crap taste in colours – once you follow what I’ve done here – that entire, massive library of CANVAS-related gauges and charts is yours for the taking!  You can make the gauges interactive – but as I had two, not one pointers in this example, I skipped that. Details are in the extensive RGraph documentation.  Copy me and drop them an encouraging lines to say MORE IOT PLEASE!!

Oh and if you don’t like animation – where I say “grow” say “draw”.

(As an aside, I got this working today as well - https://www.codeproject.com/Articles/304874/HTML-Canvas-Aqua-Gauge)  very pretty but doesn’t scale well.

Prerequisites: Far too often in blogs like this we “assume” that everyone is keeping up – if not – may I suggest a quick look at this page I put up specifically to give a little background – which might help explain this article.

<script src="/myjs/RGraph/RGraph.common.core.js" ></script>
<script src="/myjs/RGraph/RGraph.gauge.js" ></script>

<script language="javascript" type="text/javascript">

           (function(scope){ 
                scope.$watch('msg', function(msg) {
                   gauge3.value=[msg.temperature,msg.humidity];
                   gauge3.grow();
                });
            })(scope);
            
            var gauge3 = new RGraph.Gauge({
                id: 'cvs',
                min: 0,
                max: 100,
                value: [23,60],
                options: {
                    titleTop: 'Temperature',
                    titleTopSize: '16',
                    titleTopFont: 'Impact',
                    titleTopColor: '#ff8888',
                    titleTopPos: 0.25,
                    titleBottom: 'Humidity',
                    titleBottomSize: '14',
                    titleBottomFont: 'Impact',
                    titleBottomColor: '#8888ff',
                    titleBottomPos: 0.3,
                    backgroundColor: 'black',
                    backgroundGradient: true,
                    centerpinColor: '#666',
                    needleSize: [null, 50],
                    needleColors: ['Gradient(transparent:yellow:orange:#ff8888:#ff8888)', 
                                    'Gradient(transparent:cyan:green:blue:blue)'],
                    textColor: 'white',
                    tickmarksBigColor: 'white',
                    tickmarksMediumColor: 'white',
                    tickmarksSmallColor: 'white',
                    borderWidth: 1,
                    borderOuter: '#666',
                    borderInner: '#3333',
                    colorsRanges: [
                                    [0,10,'rgba(0,0,255,0.6)'], 
                                    [10,20,'rgba(0,128,255,0.6)'], 
                                    [20,30,'rgba(0,255,255,0.6)'], 
                                    [30,40,'rgba(0,255,128,0.6)'], 
                                    [40,50,'rgba(0,255,0,0.6)'], 
                                    [50,60,'rgba(128,255,0,0.6)'], 
                                    [60,70,'rgba(255,255,0,0.6)'], 
                                    [70,80,'rgba(255,128,0,0.6)'],                                                                                                                                                 
                                    [80,90,'rgba(255,64,0,0.6)'],   
                                    [90,100,'rgba(255,0,0,1']
                                  ],
                    textAccessible: true
                }
            });
            gauge3.grow();

    </script>

    <canvas id="cvs" width="300" height="300">[No canvas support]</canvas>
 
Facebooktwittergoogle_pluspinterestlinkedin

The Pine 64

Pine 64Just a quicky this morning as I’m busy working on a LED for the thermostat control (thanks to some help from the author – I’m quite excited)  as well as bench-testing some NanoPi 64 and M3 units.

So what you see here is the Pine 64 – which, like the FriendlyArm NanoPi64 uses a quad-core 64-bit CPU. This particular board has 1GB RAM (max 2GB)and is missing the Bluetooth/WIFI module ( the pins on the right side).

I’m having trouble with this one – that is, seeing the point of it.  As the photo depicts it is BIG – chopped up you could easily fit three Orange Pi Zeros into the same space and at least 2 M3 boards (the ones behind).

So to be fair, it DOES have a beta (if you like using beta software) Android 7 available – I’ve installed it, it works but is not stunningly fast – no-where near as fast as a typical mobile phone for example) – and not too many board manufacturers can claim that (this release of Android won’t even start up on the NanoPi A64). So if a modern Android is your thing then, well, I guess you’ll find the board useful. There is also a WiringOP for it (GPIO) but I understand that is somewhat incomplete.

If Android is not your thing and you want to do some control stuff, I cannot think of any good reason to go for this rather than something like the much cheaper Orange Pi Zero or perhaps the M1 or M2.

Well, I said it would be a quicky. Oh and the chip gets hot – it needs a heatsink and there are no mounting holes around the processor to fit one.

So – the board with 1GB RAM is only $19 – that’s good right?  But then if you want the Bluetooth and WIFI that comes WITH several other boards, that’s another $10. Add shipping to the UK and you are now looking at $40. With the current atrocious conversion rate you could buy a Raspberry Pi 3 for that. Go for the 2GB version and you’ll looking at $50+

I’m thinking at the roughly $50 price range – perhaps the Odroid C2 wipes the floor with this? What do you think?

So – what did I miss? Why would one want one of these? Someone enlighten me… there have to be some plus points?

Right –back to fitting a LED to my thermometer gauge.

Facebooktwittergoogle_pluspinterestlinkedin

Some Background

Far too often in blogs like this we “assume” that everyone is following along, so for the sake of boring regular readers…. the background to much of what you will see in this blog, revolves around my home control project which started off using an Atmega1284 chip as a controller and Arduino and wireless as end-points, mutating over time into it’s current state where I use any Raspberry-Pi “compatible” board to run Node-Red and talk to ESP8266-based end-points by the MQTT protocol – most of the programming being in C and NodeJS as appropriate - and a need to understand how best to make use of available widgets for general home control, in the now widely-used Node-Red (thanks partly to it’s adoption by Raspberry Pi).

I’ve followed the fantastic Node-Red since the beginning as it seemed like a good contender for home control even before the original “ui” – a community addition, eventually absorbed into the main Node-Red project to become “desktop”.  To find out more about Node-Red and Node-Red Dashboard you can join the discussion group over at Google+

Within the desktop you have a “node” called “template” which can display simple web pages inside a window in the desktop and can accept inputs and send information from its output – a near-perfect “black box” if you like. The problem is understanding just exactly what you can and cannot do inside the template, how to display items inside the template and making sure such items scale appropriately.

This is part of the journey that some of us are on – and I’ve written several articles on this now in the blog here. I hope you find them useful.

Within Node-Red there is a file called settings.js (usually on a Pi or a machine you’ve set up with a Pi user, this would be located at /home/pi/.node-red/settings.js) and you can set directories for your own javascript and css. As Node-Red already has such directories I’ve chosen to standardize on mjs, mycss,myimages, myicons etc.. using this as the base:

httpStatic: '/home/pi/.node-red/public',

Javascript can then be accessed as /myjs/xxxx.js  etc

As one would normally use an 8GB or larger SD for such projects (smaller are often as expensive and sometimes hard to get) there is usually no shortage of space to store libraries of images, routines, css etc…  jQuery is already available inside the desktop without including it.

A good direction to go in (so it would seem) is to use widgets based on HTML5 Canvas. Keep an eye out for new widgets based on this and feel free to send us links to anything new and exciting.

Facebooktwittergoogle_pluspinterestlinkedin

RGB LED Animation

LED AnimationI was over enjoying a NYE drink at Aidan’s place at the weekend and we were chatting about gadgets, as you do and he’s made a little 3d printed enclosure that looks like a round home fire alarm box.. in the middle is a movement sensor (IR) and some slots all around. He was demonstrating it and said that he’d put a string of RGB LEDs on the board for status use and I said how nice it would be to give it some Echo-style animation.

That went off on a tangent and we ended up with some fancy animation using my ESP8266 code (Home control 2016). The software to do this has been around for a while – but not really used other than in my flashing Christmas candle referred to in an earlier blog.. in that code you can refer to a string of RGB lights up to 300 of them and do things like -  make the first 10 LEDs RED and pause for a second, then make the second 20 LEDs GREEN and wait for 5 seconds, clear the lot wait 1 second.  That will then continue to do that forever in a loop.

What has always been missing however is proper loops an loops within loops. Well, I fixed that tonight.

Using the normal topic/payload structure I’ve been testing on serial.

Here’s an example I have running in front of me in which I have a strip of 12 serial RGB LEDs.  4 come on in blue, then they go off, then the last 8 alternate between 4 greens and 4 reds, then 4 reds and 4 greens, several times before clearing and starting all over again.  As you can see there’s a loop in the middle of that.

{rgbstop}
{rgbstart:12,12}
{rgbadd:1,0,4,0,0,255,1000}
{rgbadd:1,0,4,0,0,0,10}
{rgbadd:2,8}
{rgbadd:1,4,4,0,255,0,10}
{rgbadd:1,8,4,255,0,0,90}
{rgbadd:1,4,4,255,0,0,10}
{rgbadd:1,8,4,0,255,0,90}
{rgbadd:3}
{rgbadd:1,0,12,0,0,0,1000}

This is now INCOMPATIBLE with earlier code so if you have something already running you’ll need to add a new first parameter (1) to keep compatibility.

The first command stops anything already running. The second sets up 12 LEDs on GPIO12 (count is the second parameter).

An example of a simple light up is the third instruction – code 1, from LED 0, light 4 LEDs in BLUE (0,0,255) for 1000ms.

Then go onto clear those LEDS and wait 10ms.

The new stuff comes in line 5 – command (2) – the loop. That says – here’s a loop (2) which will run 8 times.  More light changes after that then command (3) – end of loop.  Finally I clear all 12 lights and wait a second until starting all over again. That’s it – you can do loops within loops of course.

There is also a command 4 which means END – you’d only use that if you wanted to perform a series of loops and then stop permanently. That has no parameters.

Assuming you’ve used the latter and have a sequence which does whatever and then stops – it might be nice to store this in FLASH and recall it when needed. There are four non-volatile buffers available to store this information.

{rgbstore:X} where X is 0-3

You can play back any of these as below, again assuming in this case GPIO12 and 12 LEDs. Set X to be 0-3

{rgbrecall:X}
{rgbstart:12,12}

The above will play back a stored sequence immediately.

The code is in the usual place and available via the OTA – don’t forget the minor incompatibility. So this applies to version 1.7.5 of the software and onwards.

Facebooktwittergoogle_pluspinterestlinkedin

Happy New Year 6200+ members

And only days after I wrote that, we're well over 6,200 of you, registered in here and climbing! Thanks to everyone and especially those who've submitted great feedback over the last year.

A quiet New Year's Eve - out with friends after wasting a couple of hours having seen "Ubuntu in Windows 10" which then turned out to be a beta, which then turned out to be very old and breaks when you upgrade it to the latest stable Ubuntu - I should know by now not to use Microsoft Betas - thanks Microsoft.

Right so coming up - a couple of new boards from FriendlySoft, one being 64 bits! and I'm looking forward to a new DIY Amazon Alexa - using Google's APIs - more on that in the new year.I'm just about to get to test my 250w solar panel having bought a couple of 12v 7amp batteries and an MTTP 20 amp controller - just waiting for some power converters to turn that 24v back into more useful 12v/5v. Assuming all goes well I'll write that up soon.

Awaiting new software for the Orange Pi Zero which is working well with Xenial and the new script (which seems to be fine now - no gripes for a day - if anyone has ideas for useful APT-gets to add in there do let us know (but only things that work rock-solidly and are genuinely useful please).

Lots more planned for the new year - for now - hope you all have a great evening.

A couple of useful links from chat with Antonio this morning..

A neat-looking stand-alone ESP8266 Thermostat

Testing various temperature/humidity sensors

Oh and more updates to the  kitchen sink script - just tested on a Debian VM - went straight through - now has proper timings so you can see how long everything takes - typical Raspberry Pi might be an hour to run the lot...  OVH VM running the script - 8 minutes !!!

Pete

 

Facebooktwittergoogle_pluspinterestlinkedin

Merry Christmas

Some of you may be heading off home to see family so we might not hear from you for a little while. Others will be settling down at home for a Christmas of gadgets…

Christmas in Bellingham  - front of our house

Either way, by Christmas there’s a good chance there will be 6,000 of you signed up to this blog and 5,000 on Facebook – so I’ll take this opportunity in both cases (sorry if you’re on both) to wish you all a very Merry Christmas and a Happy New Year.  I’ll be around for most but not all of it.

Thanks for looking in – and if you’ve not logged in – now’s a good time.

Regards

 

Pete.

Facebooktwittergoogle_pluspinterestlinkedin

More Dashboard Goodness

tmp4ECCLast week, I got as far as some new buttons on Node-Red Dashboard along with fancy colour change and vibrate - you'll see some new buttons if you head off back to that entry.

So, what’s those  round things with numbers in them?  No,  not more gauges – but CONTROLS – a finger control for DIY Nest Displays! Well, several of them in fact.

Thanks to lots of work and some great feedback you'll see in here not to mention a little inspiration, we can now both input to the knob and output from it. This has SO much potential (not this example but the general idea - we can use most JQUERY controls in here ). We have had SO many issues along the way, interaction between knobs, not saving on refresh etc… lots of people have contributed – including ideas from the guys at IBM  -and today, reader Jorgen Antonsen provided the last piece of the puzzle.

So here is the library – demos in there – I picked the second demo – and I really think it is a winner. Here’s what we did:

In node-red settings.js I have a directory I can put stuff in like Javascript and css that won’t get wiped on an update of the dashboard.

httpStatic: '/home/pi/.node-red/public',

Now… you could create in there, say, folders for js and css like I did originally – but that would be a mistake – because they’ll conflict with the directories that Node-Red itself uses… so I called mine myjs and mycss.

Looking at the source of that page link I sent you, you’ll find a link to jquery.knob.min.js – grab that – and put it in the myjs folder. Now you have it available.

Here is what I put in my test page to bring up the nice (now simplified) controls you see above.  The second template is merely a duplicate of the first and so on – the ability to SCALE to the size of the template is new – and I’ve used 98% instead of 100% in the code because though 100% worked here in the demo – on my phone one of the knobs resized at 100%  - now it is perfect. I’d like to hear from anyone who gets a different result.

tmp7998

<script src="/myjs/jquery.knob.min.js"></script>

<script>
    (function(scope){
        scope.$watch('msg', function(data) {
            scope.msgSend = false;
            $("#jqueryknob" + scope.$id).val(data.payload);
            $("#jqueryknob" + scope.$id).change();
            scope.msgSend = true;
        });
        scope.msgSend = true;
        scope.value = 0;
        scope.sendData = function(data){scope.send({payload:data})};   
        scope.init= function(){
            $("#jqueryknob" + scope.$id).knob({
                change : function (value) {
                    //console.log("change: " + value);
                },
                release : function (value) { 
                    if(scope.msgSend)scope.sendData(value);
                },
                cancel : function () {
                },
                draw : function () { }
            }); 
        }
        //Wait for angular to assign id to DOM element
        setTimeout(function(){
            scope.init();
        },200)
    })(scope);
     
</script>

<input  id="jqueryknob{{$id}}"
        class="cDial1" 
        data-width="98%" 
        data-height="98%"  
        data-cursor=true 
        data-thickness=.4
        data-linecap=round
        value="{{msg.payload ?  msg.payload : 0}}"
>

 

So - if you SET either of these controls by using the mouse/finger,  they will set outputs... and survive a refresh. Spot on.

Manual injection will update the display without sending anything out of the template – while finger/mouse control of the knob will send output values out of the node. This is the expected behaviour.

Variations on these controls can be used to set temperature, time bands (see the other examples) and so much more and once we all understand how this is working – using other JQUERY controls should be easy.

Now – you see in the code above where it says data width and height 100% – that causes issues for the standard template – but as we’ve already cleared out all the padding from the template – why not go the whole hog and get rid of any scroll bars… Beware of altering data-thickness – that is what causes a problem if too thick (just make the item a little smaller).

This needs to go into a style – in a template BEFORE our knobs..

.nr-dashboard-template {
padding: 0;
margin: 0;
overflow-x: hidden;
overflow-y: hidden;
}

I’ve manually altered some colours – but I’m looking forward to someone coming up with a means to separately inject msg.fsColour so we can dynamically change this depending on value (thermostats!)

Been a good day, really.

more buttonsComing up next – controlling the colour!

Meanwhile,  if you want MORE buttons – check out this flow to put into Node-Red… on a page all on it’s own I suggest.

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

This should get you going! See image on the right

Facebooktwittergoogle_pluspinterestlinkedin

The Script

It occurs to me that I regularly refer to my “script” – without ever having detailed what it does!  I’ll fix that now.

The “script” is something Aidan and I originally put together for our own use, mainly to help when running home control systems – to simplify Debian Jessie installations on the Raspberry Pi to suit our purposes. Over time as I have reviewed various SBC boards I’ve modified the script with LOTS of feedback from readers in here until today where it will install software over a basic Debian Jessie installation on a range of boards including but not limited to:

  • Raspberry Pi2
  • Raspberry Pi3
  • NanoPi M1, Neo etc
  • Chip
  • Orange Pi PC (Armbian)
  • Roseapple Pi (Armbian)
  • BananaPi M2+ (which came up with 3 usable UARTS in Node-Red!)
  • Orange Pi Zero
  • Various FriendlyArm boards
  • Various VMs (Debian 8, XENIAL, DIETPI and PIXEL)

As the Raspberry Pi 1 is a little underpowered and old - it is not supported - if anyone wants to provide information to make it work - we can look at that.

The software installed using this script includes

  • Python, Samba, Telnet
  • Mosquitto with Websockets
  • Apache with PHP, SQLITE and PHPLiteAdmin
  • NodeJS
  • Node-Red including:
    • node-ned-nontrib-config
    • rode-red-contrib-grove
    • node-red-contrib-bigtimer
    • node-red-contrib-esplogin
    • node-red-contrib-timeout
    • node-red-contrib-pushbullet
    • node-red-contrib-openweathermap
    • node-red-contrib-google
    • node-red-contrib-sqlite
    • node-red-contrib-emoncms
    • node-red-contrib-geofence
    • node-red-contrib-ivona
    • node-red-contrib-moment
    • node-red-contrib-particle
    • node-red-contrib-web-worldmape
    • node-red-contrib-graphs
    • node-red-contrib-isonline
    • node-red-node-ping
    • node-red-node-random
    • node-red-node-smooth
    • node-red-contrib-npm
    • node-red-contrib-file-function
    • node-red-contrib-boolean-logic
    • node-red-node-arduino
    • node-red-contrib-blynk-websockets
    • node-red-dashboard
    • node-red-node-darksky
  • GPIO library as appropriate
  • Webmin
  • MPG123
  • Screen
  • PHPSysinfo
  • CU
  • MC (and editor)
  • HA-Bridge

Node-Red packages have been added recently and some removed (admin which is no longer needed as there is a package manager built into Node-Red).

Firstly let me state that this was built for our own purpose and is neither guaranteed to work nor supported. You should have a clean Debian installation with perhaps 8GB of SD – though this lot won’t actually add much and on a Raspberry Pi if you get rid of WolfRam (one of the menu options) you’ll save more than you lose! That and LibreOffice take up a massive amount of space and if you’re an experimenter I’m assuming you’re not likely to need either. 8GB of SD typically leaves LOADS of space for files and future additions.

If this script is to work you should create a user “pi” when setting up the board – clearly a Raspberry Pi will have this already.  Copy the script – call it, say, script.sh, into the pi directory and make sure it has execute rights. You should be logged in as user pi to do this. Then run the script – could take half an hour or twice that long – depends on the board. You will be asked simple questions about passwords etc.

And that is it – the script if it runs correctly (will likely show up some WARNINGS on the way – ignore – and NPM ERRORS which aren’t errors) will at the end suggest a reboot – do the reboot – and you should be up and running.  Don’t attempt this if you’re not familiar with running scripts and have absolutely no related experience. It is simple, it should run, but I don’t provide a support workshop other than people asking questions in here which I or another reader may respond to.

If it all works well, you should find Node-Red on port 1880, Webmin on port 10000 and at port 80 you should have Apache with default pages. With some boards, it may be necessary to change permissions on serial ports if you can’t open them and of course parallel port operation from Node-Red other than real Raspberry Pi is likely to require using the EXEC node – explaining that is beyond the scope of this article and may be trivial or non-trivial Generally, I’ve managed to get port access without requiring a degree in Linux.

Always happy to listen to TESTED changes to the script with a view to incorporating more useful features. Right now I’m about to install on a BananaPi M2+ and next week we’ll be trying out the Orange Pi Zero (alongside a review of that board).

Facebooktwittergoogle_pluspinterestlinkedin