Quantcast
Channel: Scargill's Tech Blog
Viewing all 1391 articles
Browse latest View live

Weather 2 Board and ESP8266

$
0
0

tmpE044NOT the cheapest board on the planet, I was handed a couple of these little boards by a friend this weekend.. the weather-2 board.

The board uses 2 i2c chips – the BME280 which as you may know is a miraculous little chip offering temperature, humidity and pressure readings all in one chip. I already support that in my ESP8266 code. Nothing new there and the chip works as expected when plugged in using this module.

What this board brings to the party is a chip I was previously unaware of – the si1132 – which in one chip offers readings of visible light level, UV level and IR levels.

The original library for this used floats and I’ve reduced that down to integers – looking at the variations I doubt I’ve affected accuracy at all – and these now come in the form of I2c commands in my ESP8266 code..

{si1132_uv}

{si1132_ir}

{si1132_visible}

Assuming the board is attached (or a board containing that chip that works at the same I2c address) – you can grab readings from this chip no problem.

I could envisage one of these outside – in a cover that protects it from the direct light and direct heat of the sun, offering all 6 readings – handy for lots of things.  Or maybe you just want an alarm when you’ve had too much sunbathing – I’ll leave it to others to figure out best uses.

Makes a useful addition to the home control project. Source of the ESP8266 code available as are ROMS.

Facebooktwittergoogle_pluspinterestlinkedin

What is Klikr?

$
0
0

Today I became the proud owner of a Klikr – my friend Jonathan dropped one in for me – so, this afternoon I decided to investigate.

Here it is seen photographed next to my Samsung Gear Classic watch on my normal size hand to put it into perspective. I have the black one but there are other options.

Klikr

The unit contains a Bluetooth transceiver and infra-red transmitter and receiver. The idea is simple – you can have it learn key commands to control, say, your TV (by learning existing commands) and you can control that by Bluetooth on your phone.

You might, like me say – well that’s a bit pointless, I have IR remote control on your phone. You might also have a TV which you can already control remotely over the Internet.  However, if you happen to have a central control system, say, a Raspberry Pi controlling the house – you COULD stick Bluetooth onto that (unless it already has it) and control a TV that otherwise has nothing but Infra-red, from anywhere in the world. The device claims to have “voice control” but in reality that is something they’ve put onto the controlling App on your phone. Still, a nice touch.

Anyway, I’m sure you can read all about it if you’re interested, they seem to cost about £25. If you’ve no other way to remotely control a gadget that responds to infra-red this might be another tool to add to your home control toolbox.  I tested it, took no more than a minute to get it talking to my TV and having the Android (they do Apple) App turning things on and off. Doddle.

Oh yes, it was a Kickstarter project, it is made in China, it runs on a single CR2032 battery and will last a long time as it uses low power Bluetooth. Well, as long as you don’t sit turning stuff on and off all day with it.

While interested in this subject I did find this.. http://www.banggood.com/Broadlink-Black-Bean-Smart-Home-Wifi-Remote-IR-Controller-Universal-Appliances-Smart-Control-p-1049494.html?utm_design=18&utm_source=emarsys&utm_medium=Mail_mid90_email&utm_campaign=newsletter-emarsys&utm_content=Winna&sc_src=email_2129478&sc_eh=e375077fc58ebb7d1&sc_llid=376931&sc_lid=89002665&sc_uid=sBhI5Zx9FB

At first glance looks great as it runs on WIFI and can learn infra-red controls… (as does the Anymote hardware but I could not get that to work properly AT ALL). I was about to order one of these devices when I watched an American video – the guy was praising the Black Bean board but said that while it learned his TV remote controls – on playback, nothing happened.  Think I’ll wait a while on that one.

Facebooktwittergoogle_pluspinterestlinkedin

Weekend fun

$
0
0

One of the toys I’ve been playing with this weekend is the Amazon Dash – contributed by visiting read JAY when he popped over to see me last week.

Oh, before I start – anyone using the SOURCE of my ESP code – (not Arduino IDE) – if you fancy having a go at getting the NAME to show up on your router (as against ESP_xxxxx) and achieve success – PLEASE let me know – the library function that is supposed to do this simply won’t work for me).

SonoffAnd on the subject of ESP – if you’re using Sonoffs – take a look at this – https://github.com/arendst/Sonoff-MQTT-OTA-Arduino – This was good software for Sonoffs BEFORE I started putting in requests – but now – it has at my request DUAL ESSDs (so you can move from one place to another) – and at someone else’s and my requests –ECHO support – all in a good job and his code still fits into the standard FLASH – you’ll need the Arduino ESP8266 IDE setup – but that’s easy enough. Worth a look.

And on the subject of SONOFFS – I noted this on Banggood.. £4.80 inc delivery to the UK!

http://www.banggood.com/DIY-Wi-Fi-Wireless-Switch-For-Smart-Home-With-ABS-Shell-p-1019971.html?rmmds=category

Anyway…

Amazon DashThe Amazon Dash (full breakdown here for those interested) is a small device designed, like everything Amazon do – to get you to buy more Amazon products.  £4.99 for the privilege of having a button next to your washing machine to help you buy more washing powder (though to be fair apparently you get the money back on your first purchase). The unit is obviously meant for householders who like to waste money – as it is ultrasonically sealed so long after you lose interest in it, it packs in for good.

But of course we technical types are never stopped by such things – you can prise the thing open and replace the battery.  So now all that is needed is to think of a use for it.

Well, it just so happens that this is how it works – when you press the button, it turns on – transmits a signal (while flashing a light) then turns off. The signal is WIFI and a little Amazon SHOPPING APP on your phone lets you set it up to your WIFI.

So, you don’t after all have to order something with it – you could tie it into your home control system – there is a node for that in Node-Red but I didn’t find it that useful so wrote my own.

tmpB085

Easy really – once it it on your WIFI – tell your router to fix that IP address. Then ping it in, Say, Node-Red. So if you do that regularly, say every second or so – your PING will return true or false.  A simple function to detect change of state toward true – and you can do whatever you like with the result.

Odroid C2The unit is sealed and I would imagine would take a little light rain. I plan to use mine (with a new label) as a doorbell.  How about an emergency helper for someone with a temporary illness or other problem – with Node-Red you could have it send you an email, a text or other alert or just sound a bell somewhere. I’ve been testing this over and over and I can’t get it to fail. Of course-  if the broadband goes down you’re stuffed.

Oh and here’s the clincher.. Black Friday sale they were going for 99p each – so look out for other excuses for a sale – you might get a bargain.

In other interests, I finally got my hands on an Odroid C2 and my Debian script works a treat on it APART from Webmin – working on that and I’ll do a full write-up soon.

Facebooktwittergoogle_pluspinterestlinkedin

Grove LCD RGB Backlight

$
0
0

tmpD3E6Now, before anyone says anything – no I’m not advertising Seeed or their Grove stuff. It just so happens that over the weekend my pal brought some of their stuff over to have a play with and I was particularly taken by the LCD display. This is a typical Hitachi-style 16-character by 2 line LCD of the type that have been floating around since last century but which still are popular today I guess because of price. Anyway, this one marked “Grove-LCD RGB Backlight v1.0” is not particularly cheap but it has an RGB LED background and runs off I2c.

We tested it using the Seeed Studio WIO boards (more on that later). Lovely – want a pink background, or how about aqua, or mint –  well, you have full control over the RGB background with values 0-255 for each colour. It occurred to me that this really transforms the otherwise boring LCD display as you can use colour to indicate alerts etc.  For example on a thermostat display you could use orange for on, green for “reached set temperature” and blue for standby.

tmp52FBAnyway, as the WIO modules are little more than an ESP12 I thought it might be more useful to incorporate a driver for this display into my own ESP8266 code. Those of you familiar with the home control project will know that I keep updating the code for the Home Control 2016 project. So – I took a look at the Grove driver for this display – sadly it is in Arduino C++ format so I ended up doing quite a bit of changing to make it do what I wanted and in C – but ultimately it is in there and works a treat. Here are the new commands you can fire out in MQTT to the board with the new software on, using as usual GPIO4 and 5 for I2c.

{rgb_lcd_setup}

{rgb-lcd_clear}

{rgb_lcd_cursor:X,Y}

{rgb_lcd_background:RED,GREEN,BLUE}  // values 0-255 in each case

{rgb_lcd_write:”Your text”}

And that’s all there is to it. A nice addition to the code. I could add more if needed but I figured this minimal set of commands will do for most purposes.

I’m sure there will be other, compatible boards out there – if you know of them – do let us know.

So on the subject of the Seeed WIO boards, I’ve made a separate blog to follow on that – turns out that if you want to have a play, you can blow their code into an ESP-12 – but read the article coming soon.

Facebooktwittergoogle_pluspinterestlinkedin

Playing with WIO

$
0
0

We’ve had a very busy weekend – a friend of mine, Jonathan who’s another gadget guy stopped over and while the girls went shopping we spent the weekend been buried away in the man-cave experimenting. Firstly – a link for you – if you have an LG TV – here’s how to control it from the command line – and hence if you like, from Node-Red.  

Jonathan brought some kit over including a Seeed Studio WIO board and a couple of peripherals.

For beginners: Seeed do a series of products under the name of WIOLINK – one larger board and one tiny one with ESP8266 WiFi controllers, together with various peripherals. Together they make a nice playground with a very clever cloud-oriented setup whereby you can use a mobile phone to set up the board and peripherals are set up via the cloud. Once in place you can call an API to do your own control.

Grove LCDFor example – you need a controller for an RGB LCD Display? Dial up the display from their list of covered products (their own – usually small peripherals with a common 4-way connector) – press go – and the software on the board is updated to handle the new peripheral – which you can now access via an http POST. In the case of their larger board with several connectors, the APP even tells you which connector to plug the peripheral into!

Now this cloud-based approach is all very nice but originally this was based in China… my first thoughts were that I would not put it past the Chinese government to have a back door to such systems – imagine if millions of us were controlling our homes using their servers – what a powerful tool for disruption that could be – well, they now have a server in the USA and I believe you can do your own at home if you want but I’ll leave you to look up their info on that subject. For me this is just something new to play with and get ideas from.

NOT for beginners: Armed with an original WIOLINK board and a couple of peripherals, we set about this weekend to see how well this worked.  The phone APP all works well, their hardware seems to work well but when it comes to using the API once you’re all set up, the only Node-Red node we found has not been updated in a while and does not seem to work well.

So this is aimed at people who don’t want to get the soldering iron out and would prefer not to program either. And that’s fine.

But we wanted to see how this worked and see what we could do with it – and importantly what others who read this blog might want to do – so we took a bog-standard ESP-12 module, programmed it up with the Seeed code and… well, read on…

So you have a standard ESP-12 module, preferably with prototyping pins – and you want to make your own WIOLINK board – firstly if you don’t have it, you may wish to get the Espressif flasher. Then you need: Assorted binaries, and two bin files user1.bin and user2.bin.

Put them all in a directory somewhere, maybe called \wio.

Flash the software as such:

tmpE429

And that’s it  – you have all you need to get started.  Grab the WIO app for the phone and get a free account.

If using an ESP-12 module instead of a genuine WIO board, where Seeed refer to using UART, then RX on the ESP8266 is D1 on their boards which is the outer connection opposite ground and TX is the inner connector next to RX – of their standard 4-wire connector. Vcc is 3v3 except in the case of their RGB LCD which needs 5v (that will be to keep the LEDs happy). Make sure you don’t use 5v on other peripherals.

If using their I2c port – SCL is GPIO5 and SDA is GPIO4 (some boards may be reversed on some ESP-12 boards).

 

DIY WIO

We tried this out using the excellent Grove LCD RGB Backlight (which I’ve since managed to get running on my own ESP8266 code as it is very pretty), magnificent if only because you can make the backlight any colour you like!!  Everything just worked once we figured out the pins. YES you can get alternatives to this board for less money – but until I can get my hands on one – I can’t tell you if they are compatible. In particular, you can set the backlight on this board to any colour your heart desires, using RGB values. Want a light purple or an ice-green, or pink etc. – no problem. This actually transforms an otherwise utterly boring 16 character by 2 line display into something far more useful.

To set these up, Attach a LED+resistor to GPIO2 as an indicator with the other end grounded. The programming pin is GPIO0 – equivalent to the setup button on the real WIO device. Hold this to ground for a few seconds to go into setup mode – which is shown by a softly undulating light on GPIO2. Note that all my general purpose ESP8266 boards have 1k pull-ups on GPIO0 and GPIO2 to 3v3.  In this case you might want to consider adding similar pull-ups to GPIO4 and 5 as if you are using I2c then you do need pull-ups. Some peripherals have them, some don’t – a bit of a mess really as you really should just have the one set of pull-ups.

So basically you end up with an API call to their server with a unique code and some parameters – which control your board. There are a variety of ways to use this – and in the case of Node-Red there is even a set of nodes to do the job – but when we tested them we came up with various issues and the code looks like it has not been updated for a while – so you might be on your own there.

And so, taking the above into account it is quite easy then to try out the various Grove peripherals – at least those supported by WIO. The App itself makes it easy for you to fire out commands.

Up to now, the RGB_LCD display has proven to be the most fun which is why I’ve adapted the code for my own ESP code, along with the visible/uv/ir light sensor. Other devices less so – as they don’t use I2c. Seeed do a 4-channel 7-segment LED display – and a 10-channel level meter, both of which are 2-pin control but are NOT I2c – this means they have to use a separate set of leads – they chose the serial port (I personally prefer to leave that for debugging). If you need the latter – i.e. 10 variable intensity level lights – you’re better off (unless size is important) buying the display and the PWM controller I covered in an earlier blog with 16 outputs. http://tech.scargill.net/16-channels-of-pwm-for-esp8266/

Facebooktwittergoogle_pluspinterestlinkedin

NPM Update Status

$
0
0

If you are a Node-Red fan (and if not – why not) – you’ll know that the NODES – i.e. the modules that are provided with Node-Red or that people like myself create – get updated every now and then.  And it is a pain in the bum to keep checking to see if any of them need updating.

So – how about a weekly or monthly email detailing any updates!

It turns out that there is a handy command called “npm outdated” which returns a list of out of date devices!

So here’s the general sequence…

cd .node-red  // if you’re in the PI directory of your Pi or similar – this will take you to the Node Red directory

npm outdated // this will show you a list of out-dated nodes (or nothing).

You can then go off and do updates when you wish.

It occurred to me that this needed automating. One of the guys at the Node-Red groups (Mark Setrem) gave me this:

npm outdated –prefix ~/.node-red

That saves having to switch to the Node Red directory – and so from there – a simple flow…

tmpF1CD

The timestamp node can be set to output every week or month – the exec node contains what you see above – and the green email node contains email credentials.

The payload (email body) comes from the middle exec node, fill in the TOPIC in the timestamp and you have your SUBJECT line.

The output (which you can test by pressing the button on the timestamp – who’s payload is ignored)….

tmpE74B

The whole operation takes several seconds but because of the way Node-Red works – it’s not holding anything up. Ok, formatting could be better – but who cares – it does the job.

The original information that started me off is on the Node-Red site..

I’d updated NODE and NPN to the latest versions and that made some nodes fail (SQLITE)… also I realised when thinking about it – that some of those nodes have not been updated in a while – here’s how I gotaround the lot…

sudo npm cache clean

sudo npm update -g –unsafe-perm node-red

So that gets you the latest Node-Red after any updates of Node etc…

cd ~/.node-red
npm outdated

The above gives you a list of your nodes that may be out of date either through a node update – or simply – age!!

npm update              # to update all nodes, or
npm update foo          # to only update a node called foo

Enjoy.

Facebooktwittergoogle_pluspinterestlinkedin

Yule Be Impressed

$
0
0

Or not - as the case may be. This is my attempt to revive an old, bust Christmas decoration.

The original Christmas candle decoration was a white casing, simply filled with static, old-school filament lighting - and as happens one of them went by the by. We don't keep spares as most of our decorations today are LED. I was left with an empty shell -  what to do?

As it happens I had a roll of serial LED strip lying around looking for a job - so last night I set about giving it one.

In the early days of putting together my software for the ESP8266 (see Home Control 2016 project - binaries available), once I'd managed to get serial LEDs to run properly, I put together several RGB controls one of which includes animation, but never actually used it until now.

The programming below is easy once you know how.

{rgbstop}

{rgbstart:12,94}
{rgbadd:8,22,255,0,0,5}
{rgbadd:36,24,255,0,0,5}
{rgbadd:66,20,255,0,0,5}
{rgbadd:0,8,0,255,0,5}
{rgbadd:86,8,0,255,0,5}

{rgbadd:60,6,255,255,0,5}
{rgbadd:30,6,255,255,255,200}
{rgbadd:60,6,255,255,80,5}
{rgbadd:30,6,255,255,150,200}
{rgbadd:60,6,255,255,150,5}
{rgbadd:30,6,255,255,80,200}
{rgbadd:60,6,255,255,255,5}
{rgbadd:30,6,255,255,0,200}


{rgbadd:60,6,255,255,0,5}
{rgbadd:30,6,255,255,255,200}
{rgbadd:60,6,255,200,40,5}
{rgbadd:30,6,255,255,150,200}
{rgbadd:60,6,255,255,80,5}
{rgbadd:30,6,255,255,120,200}
{rgbadd:60,6,255,255,200,5}
{rgbadd:30,6,255,255,30,200}


{rgbadd:60,6,255,255,0,5}
{rgbadd:30,6,200,255,200,200}
{rgbadd:60,6,255,200,80,5}
{rgbadd:30,6,255,255,130,200}
{rgbadd:60,6,200,200,150,5}
{rgbadd:30,6,255,180,80,200}
{rgbadd:60,6,255,255,200,5}
{rgbadd:30,6,255,255,0,200}

The first line stops any animation and clears out any queue. The second line starts up the yet-to-be-defined animation and defines which GPIO pin to use on the ESP and how many LEDs are involved (to set up the buffer which is number_of_leds * 3 - not that you need to know that).

rgbstart:gpio_number, number_of_leds

The remaining lines start operating in the background as soon as they are called... here's the format:

rgbadd led_number, led_count, r, g, b, delay_in_ms

Hence any decoration such as the one in the video - which is nothing more than a strip of around 94 LEDs, starting where the wire comes in at the bottom and following the profile, pointing inwards (inside the hollow container) until coming back to the bottom. So, the first 8 and last 8 LEDs are set to green, the rest being red APART from half a dozen at positions 30 and 60 which get some animation between yellow and white.

You could do a LOT more and the software  has enough storage for 300 LEDs and a lot more instructions than this, 600 in total (version 1.70 onwards). I've used around 180 here. I could make it considerably longer but that seemed like a reasonable size at the time.

In the above example, you would simply fire out these commands from the serial port – in my case I wanted to do this at the push of a button on the mobile phone.

Using Node-Red, I simply made a sequencer to send the instructions out one group at a time – you need a slight delay as the board takes time to process each command – only a tiny delay in milliseconds – but some.

tmp4839

Below are the two VERY crude functions to let me start up the display from the phone – or from a Node-Red Dashboard button.

if (msg.payload=="reset") context.global.stepper=0;

var steps=[
"{rgbstop}",
"{rgbstart:12,94}",
"{rgbadd:8,22,255,0,0,5}",
"{rgbadd:36,24,255,0,0,5}",
"{rgbadd:66,20,255,0,0,5}",
"{rgbadd:0,8,0,255,0,5}",
"{rgbadd:86,8,0,255,0,5}",
"{rgbadd:60,6,255,255,0,5}",
"{rgbadd:30,6,255,255,255,200}",
"{rgbadd:60,6,255,255,80,5}",
"{rgbadd:30,6,255,255,150,200}",
"{rgbadd:60,6,255,255,150,5}",
"{rgbadd:30,6,255,255,80,200}",
"{rgbadd:60,6,255,255,255,5}",
"{rgbadd:30,6,255,255,0,200}",

"{rgbadd:60,6,255,255,0,5}",
"{rgbadd:30,6,255,255,255,200}",
"{rgbadd:60,6,255,200,40,5}",
"{rgbadd:30,6,255,255,150,200}",
"{rgbadd:60,6,255,255,80,5}",
"{rgbadd:30,6,255,255,120,200}",
"{rgbadd:60,6,255,255,200,5}",
"{rgbadd:30,6,255,255,30,200}",

"{rgbadd:60,6,255,255,0,5}",
"{rgbadd:30,6,255,255,00,200}",
"{rgbadd:60,6,255,200,80,5}",
"{rgbadd:30,6,255,255,130,200}",
"{rgbadd:60,6,200,200,150,5}",
"{rgbadd:30,6,255,180,80,200}",
"{rgbadd:60,6,255,255,200,5}",
"{rgbadd:30,6,255,255,0,200}"];

msg.topic="testi2c/toesp";
msg.payload=steps[context.global.stepper++];
return msg;

and...

if (msg.payload!==undefined) return msg;

Basically a payload of "reset" starts a crude global counter and iterates through the array, sending out messages at 100ms intervals until it falls off the end of the array  (well, I was in a hurry).  Works a treat. I have a test button there in Node-Red itself and a button on the phone, both of which do the same thing.

Facebooktwittergoogle_pluspinterestlinkedin

Node-Red Dashboard Thoughts

$
0
0

Or put another way – how to use Node-Red Dashboard without a mouse cursor or a menu – on a touch screen.

I’ve been playing with the touch-LCD screen on a Raspberry Pi – this was a Chinese one – quite cheap.. “5 inch HDMI LCD V2” – an 800*480 touch display with an XPT2046 Touch Controller.   It is lovely and works a treat for a resistive display - but it’s been sitting around for ages waiting for a use.

And now it has one running Node-Red-Dashboard – but I had a couple of issues..

Node-Red Dashboard with menu

So I had the Dashboard running wide-screen – full screen using Firefox.  One of my gripes was the mouse pointer in Firefox which I’m using on the Pi. I don’t want it on a touch-screen – well, I solved that by adding an empty template to the Dashboard with nothing more than a style in it.

* { cursor: none !important }

That gets rid of the mouse.  I needed to know how to get the Pi to open into Firefox automatically and full screen “kiosk” mode. I’m sure that’s easy and is referred to in the comments below. Right now I’m just selecting full screen – which is great – but not permanent.

The Dashboard now has the ability to let you change screens using a node – and you could trigger that from a button.

But by default you can’t get the touch-screen-unfriendly MENU out of the way – if you leave the menu title empty – you get an error – but here’s the daft thing – you get a menu even if you only have one page.

I asked if the guys at Node-Red if they would look at that – but thinking about it  -really that is NOT the answer – what is needed is to have the option to turn the menu OFF COMPLETELY while retailing the ability to switch paged via the NODE. No point in having nice large buttons and still having to fiddle with the menu – I’d rather do my own NEXT and HOME large graphic buttons. For a wall display with that change, Dashboard would be GREAT.

Well, it turns out that one of our readers supplied the answer in a little more CSS – one line in fact, easily added to your code.

Note that this demo highlights an issue with Node-Red Dashboard – occasionally, for no apparent reason, the dark theme reverts to light – I only just noticed this while updating the blog!! I hope Dave is watching this!

 

Node-Red Dashboard with no menu

Anyway – how did I manage this – no menu, no annoying top bar – simple when you know how (Thanks Antonio).

<style>
   * { cursor: none !important }
   md-toolbar.md-default-theme:not(.md-menu-toolbar), md-toolbar:not(.md-menu-toolbar) {display: none;}
</style>
<div ng-bind-html="msg.payload"></div>

I have my little function node which gets rid of the mouse – and now looks like this.. Well, when the theming is restored, more like this…

Node-Red Dashboard

Facebooktwittergoogle_pluspinterestlinkedin

Icons

$
0
0

I am always on the lookout for icons, be it for my Node-Red projects (Dashboard) or to replace icons on my Windows Desktop or for other projects – sometimes I need .PNG but in the case of Windows desktop – they should be .ICO files. So on a random hunt this afternoon I was very pleased to discover this lot.  https://sourceforge.net/projects/openiconlibrary/?source=typ_redirect

Magic – all sizes and types and importantly – free.

 

icons

If you’re aware of more diverse (but have to be great quality and free) icons – do write in the comments section below.

Facebooktwittergoogle_pluspinterestlinkedin

More Node-Red Dashboard Success

$
0
0

Dashboard buttonsWell, it looks like my revelations with hiding the mouse has upset WordPress – the previous blog on the subject makes some people’s mice disappear!  Good job I wasn’t testing a self-destruct button.

It’s been a good day today – I discovered SLACK and I’ve been happily chatting to folk about my Node-Red-Dashboard issues and at the end of it all, not only have the issues gone away but I’m making progress.

So – there are a couple of things to notice and some you won’t.

So firstly – my button experience until now on Node-Red-Dashboard has been blighted by a SWIPE command which meant if you pressed a button near the right of the screen and in any way slid your finger  to the right – the page would change – in the unreleased update to Node-Red-Dashboard (needs just a tad more work and docs apparently) that has gone.  Excellent. I’ve seen this “feature” in other packages and it really does not work if you’re supposed to interact with buttons.

In my last blog on the subject you’ll see I can hide that top menu if needed (the blue menu is great on a phone – not much use on a thermostat)… and today I discovered that desktop TEMPLATES have a spacing round them that DID make it impossible to make your own buttons that would be size compatible with the UI built-in buttons.

That is all now history. So – the built in buttons – no text wrap which make it hard to make small, a visual effect on press that really is hardly noticeable, inability to change colour or indeed anything other than text colour – all problems now history.

The garish red, green and blue buttons you see above – note the rounded edges you control, there is an attractive and obvious colour change pm press (and return to original colour after press without you having to program it ), audible feedback on press (on phones with vibrators), wrap on text – indeed you can put anything in there - icons etc.

This is due to a combination on my insistence on having flexibility – my own experience and lots of help from several guys on the web today – thanks everyone for filling in the missing bits! The end result of all of this – I really DO think that Dashboard is able to take on the big boys and I’m currently backing away from the alternatives.

So – the enabling technology here is the node-red-dashboard template – this has LOTS of potential and it is now easy to accept incoming information – and send out a value on press or whatever. You’ll note elsewhere that I’ve used this to make whole pages with colour-changing icons etc., well here I’m using one template per button – but that’s just for the purpose of demonstration.

Things that needed considering – CSS for button sizing, JS to get the button colour and change it while pressing then change it back – I was not going to get into setting each and every button press colour etc. More CSS for styling. All described below and trivial to implement.

SO it turns out that if you put a template on a page – make sure it is the first one – you can put nothing but JS and CSS in it – and it will not do anything VISIBLE – but will supply your functions and CSS for the whole page – isn’t that HANDY!!!

tmp3513Let’s take a look at what is driving the display up there (again ignoring the text at the top – start with the buttons). To the left you see a template all on it’s own – then 3 templates – then 3 buttons – not connected to anything as this is merely a demo.

So – the FIRST template has info we need – CSS and JS to make everything work – you just need this once for any page. The light blue buttons are there just to show you what buttons look like in Dashboard (i.e. not as good as they could be) – and the three templates are the three new coloured buttons you see above right – which react to being pressed both visually and with haptic feedback.

Let’s take a look at the FIRST template which makes it all possible. It looks easy now but trust me it has taken some head scratching to get this far.

<style>
  .filled { 
      height: 100% !important;

      padding: 0 !important;
      margin: 0 !important;
  }
  .nr-dashboard-template {
      padding: 0;
      margin: 0;
  }
  
  .rounded {
  border-radius: 15px 15px 15px 15px;
  font-size: 18px;
}
  
</style>

<script>
$('.vibrate').on('click', function() {
  navigator.vibrate(100);
});

function restore_bg(x) {
            $(this).css("background-color", x);
    };

$('.touched').on('mousedown', function() {
    
    var x= $(this).css("background-color");
    $(this).css("background-color", "yellow");
    
    setTimeout(restore_bg.bind(this,x),200);
    navigator.vibrate(100);
    });
    
</script>

The class FILLED is important - this is the one that gets rid of the padding that both buttons and template use by default - to make the button fill to the size of the template. nr-dashboard-template is also involved. None of this seems to affect other items on the screen.

ROUNDED is simply a means of forcing rounding on buttons - you can adjust that radius to suit or eliminate it if you like.

The scripts - well VIBRATE merely invokes the haptic feedback when you press a button - easy when you know how.

TOUCHED and it's associated restore function are variations on the ones I used with images. The class allows on press for a button to store it's colour - change it's colour - wait for a while - and change it back - all without having to have individual colour control on the actual button  - which simply has the default colour you select.

Now let's take a look at once of those templates. Oh and I got those subtle colours from here - https://flatuicolors.com/

<md-button class="vibrate filled touched rounded" style="background-color:#c0392b" ng-click="send({payload: 'Hello World'})"> 
    Red<br/>button
</md-button>

Simple? Yes because the previous code makes it so. A button in a template - auto stretched by the code above and all it has added is the background colour - which the above code can manipulate - and the classes. That's it. The ng_click is what happens when you press the button - the template outputs a payload of whatever you've set. No, really that is it.  so on that output, msg.payload will be whatever you set it to be.

With background colour control, RGB and related buttons become simple - a page full of colours for RGB controls becomes possible.  Note in the class ROUNDED I changed the font size - well you could separate that off to a separate class - and create classes (say) BIGTEXT and LITTLETEXT for example - suitable for different size buttons.

When you grasp this - if you're not there already, immediately all sorts of ideas should come to mind -it's a bit like opening a new door to see all the things behind it. Within days my demo screen will look utterly amateurish as I start adding icons etc but today was important as it was, for me a confirmation that there really is not a lot you can't do with node-red-dashboard – so many congratulations to the original developer and the guys at IBM and everyone contributing. 

If you go to the ANGULAR site and look at their examples - most of them work no problem - changing these rectangular buttons to round ones is a snap!

Oh, talking of improving things  - here’s a snapshot hours later as things progress…NICE!

new buttons

 

Oh – here… http://flows.nodered.org/flow/4bfad41290eda31588ff63a23815ac5c  - if you want a play…. and YES that template uses a little white space – but next Node-Red-Dashboard release it will NOT – css and scripts only will NOT use up screen real estate – all coming together VERY well right now.

Facebooktwittergoogle_pluspinterestlinkedin

More Dashboard Goodness

$
0
0

node-red dashboardLast week, we left Will Robinson..   sorry – wrong script..  Yesterday I got as far as some new buttons on Node-Red Dashboard along with fancy colour change and vibrate. Oh and here’s a thing – you can add SPEECH to the dashboard – I only just noticed that – a little speech output control you can fire text into so the buttons talk when you press them – wonderful.

Now, what’s up with the image on the left – same buttons and… what’s that round thing with a 69 in it?  No it isn’t another display – it’s a CONTROL – a finger control for DIY Nest Displays!

Sorry- don’t get excited – the reason for putting it up here is I can’t get it to work – my knowledge of the Node-Red Dashboard templates is not QUITE up to it so I was hoping one of our enterprising readers could fill in the blanks. This has SO much potential.

So here is the library – demos in there – I picked the second demo – and I really think it is a winner. Here’s what I 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 put 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 that nice control you see above.

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

 <script>
    $(".dial").knob({
        'change' : function (v) { }
    });
</script>

<script>
        $(function($) {

            $(".knob").knob({
                change : function (value) {

                    //console.log("change : " + value);
                },
                release : function (value) {
                    //console.log(this.$.attr('value'));
                    console.log("release : " + value); 
                },
                cancel : function () {
                    console.log("cancel : ", this);
                },
                /*format : function (value) {
                 return value + '%';
                 },*/
                draw : function () {

                    // "tron" case
                    if(this.$.data('skin') == 'tron') {

                        this.cursorExt = 0.3;

                        var a = this.arc(this.cv)  // Arc
                                , pa                   // Previous arc
                                , r = 1;

                        this.g.lineWidth = this.lineWidth;

                        if (this.o.displayPrevious) {
                            pa = this.arc(this.v);
                            this.g.beginPath();
                            this.g.strokeStyle = this.pColor;
                            this.g.arc(this.xy, this.xy, this.radius - this.lineWidth, pa.s, pa.e, pa.d);
                            this.g.stroke();
                        }

                        this.g.beginPath();
                        this.g.strokeStyle = r ? this.o.fgColor : this.fgColor ;
                        this.g.arc(this.xy, this.xy, this.radius - this.lineWidth, a.s, a.e, a.d);
                        this.g.stroke();

                        this.g.lineWidth = 2;
                        this.g.beginPath();
                        this.g.strokeStyle = this.o.fgColor;
                        this.g.arc( this.xy, this.xy, this.radius - this.lineWidth + 1 + this.lineWidth * 2 / 3, 0, 2 * Math.PI, false);
                        this.g.stroke();

                        return false;
                    }
                }
            });

            // Example of infinite knob, iPod click wheel
            var v, up=0,down=0,i=0
                    ,$idir = $("div.idir")
                    ,$ival = $("div.ival")
                    ,incr = function() { i++; $idir.show().html("+").fadeOut(); $ival.html(i); }
                    ,decr = function() { i--; $idir.show().html("-").fadeOut(); $ival.html(i); };
            $("input.infinite").knob(
                    {
                        min : 0
                        , max : 20
                        , stopper : false
                        , change : function () {
                        if(v > this.cv){
                            if(up){
                                decr();
                                up=0;
                            }else{up=1;down=0;}
                        } else {
                            if(v < this.cv){
                                if(down){
                                    incr();
                                    down=0;
                                }else{down=1;up=0;}
                            }
                        }
                        v = this.cv;
                    }
                    });
        });
    </script>

 <input class="knob" data-width="120" data-cursor=true data-fgColor="#222222" data-thickness=.3 value="20">

LOVELY - works a treat - but all attempts up to now to get inputs to the template to affect that dial - or to get on-release information OUT of the dial into the template output, have failed  -  I am hoping that by the end of the day some enterprising type is going to test this and we can turn this page into an instruction blog!  Also I note that there is some whitespace at the bottom and I don't know where it is coming from..

So - anyone up for this? We probably don't need most of that code but as I was failing at attempts to control input and output I thought I'd leave "optimising" until the thing actually WORKS. Variations on these controls can be used to set temperature, time bands (see the other examples) and so much more - just need to get to grips with the IO into and out of the Node-Red Desktop.

Facebooktwittergoogle_pluspinterestlinkedin

The Script

$
0
0

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!)

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

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 NPN 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

Node Red Weather

$
0
0

One of the many things that Node-Red makes easy to capture – is the weather – and all credit is due to the people who put the DARKSKY API together.

Animated weather

What you are seeing above is a 6 day forecast in ANIMATED, COLOUR images (I appreciate it does not look animated here). It is LOVELY. This is running on my Raspberry Pi and of course the display, being a web page can be displayed on a tablet, a PC screen, a phone or an integrated touch-screen. Don’t go using old browsers though – this makes use of HTML5 and vector graphics so you should be reasonably up to date.

To get a nice pretty weather forecast for your home control display or whatever you plan to use it for, you need:

a. information

b. A display mechanism

In this case the information comes from DarkSky via a simple API

DarkSky

If you wish to “call” the DarkSky API you may do this up to 1000 times a day for free. Reader Jay and I felt that grabbing the information every 5 minutes might be a good start. Once the novelty wears off you might consider every 15 minutes or so. A timestamp node is simply used as a trigger – to get the information when Node-Red powers up and every 5 minutes from there on.

An HTTP request gets you a massive object with just about everything you could ever want to know about the weather and finally a function attempts to read that object with minimal error checking. I say this because in the past I’ve had the very odd bad package from DarkSky using the NODE that is available (I suggest you avoid that at least for now) which does not harm but looks bad in the logs!

The “http request” node in the middle requires little information – just your unique code which you get when you sign up (for free) with DarkSky – and your longitude and latitude.

DarkSky details

Here is the full URL I used with a fictional key – and my own coordinates.

https://api.darksky.net/forecast/xxxxxxxxxxxx/55.130575,-2.2534091?units=uk2

Now you COULD read all the information from the new object and make a whole boatload of MQTT messages – some of which you might never use. If you were to do this – your flow might look like this.. and my thanks to reader Jay for saving me all that work.

massive flow

i think you’ll agree that is slightly over the top – but it does give you an idea of how much info you can get out of this and that is NOT a complete list.

On the other hand it was good fun for a bit, checking out all the info

info from DarkSky

So, instead, what we’re going to do is simply pull out of the object what we need… See below. When this is called, the function I’ve dropped in after that simply contains…

try {
var weathertest=msg.payload.currently;
global.set("DarkSky",msg.payload);
node.send (msg);
}
catch(e) {}

"weathertest" is used purely to provoke an error if there is something wrong with the data and can be ignored from now on. So now with luck we have an object called “DarkSky” out of which we can pull all manner of things as needed – and of course being global we can access this from any flow at any time.

So – here’s a EXAMPLE function to get the current weather summary

try {
msg.payload=global.get("DarkSky").currently.summary;
node.send(msg);
}
catch(e) {}

What’s with the “try—catch”? Well, this is new for me – that comment I made above about accessing anything at any time - I got sick of seeing harmless complains about undefined objects in my logs due to using something before it has been defined – or bad data coming through etc.,  so my new thing is to actually check that a variable exists before using it. If you call this function BEFORE you’ve grabbed the weather for the very first time – nothing will output – simple!

So – how far can we go with this? VERY far – it’s a BIG object but for what we need here – it is all very simple.

global.get(“DarkSky”).when.what

where “when” is one of the following:

  • minutely
  • hourly
  • currently
  • daily.data[x] where x starts at 1 for today and goes to 7 days,

msg.payload=global.get("DarkSky").daily.data[2].humidity;  // humidity for tomorrow !!

“what” can be one of the following:

  • summary
  • nearestStormDistance
  • precipIntensity
  • precipProbability
  • temperature
  • apparentTemperature
  • humidity
  • windSpeed
  • visibility
  • cloudCover
  • pressure
  • icon

I’m sure you’ll  agree that’s a pretty damned comprehensive selection, nicely hidden away in an object for you to pick out what you need. cloudCover and humidity you might want to multiply by 100 to make them useful – and temperature is in degrees C though you can no doubt change that to anything you want – read the API docs.

For now what we’re interested in is the icon – the name of an icon to represent the weather for seven days. The icon can be one of the following:

  • clear-day
  • clear-night
  • partly-cloudy-day
  • partly-cloudy-night
  • cloudy
  • rain
  • sleet
  • snow
  • wind
  • fog

It JUST so happens that there is a set of animated icons called SKYCONS which match up with this exactly – and they are in technicolour – you have control over the colour of various bits of them including:

  • main
  • moon
  • fog
  • fogbank
  • snow
  • leaf
  • rain
  • sun

So putting this all together – you can make a full colour set of icons which adjust for each of several days. As I am using Node-Red Dashboard, 6 icons fit nicely onto my phone so I simply picked the next 6 days.

You might want to satisfy yourself that you can grab this data before moving onto the next stage. Get yourself a DarkSky account, punch in the details and maybe go and grab today’s weather. Of course without these icons you still have lots of info you can use for wall displays or maybe calculating what to do with your heating system – for example in cold weather, if it is damp I like to ramp the heating up just a little more.

And now, onto the imagery.

You will need to be comfortable with creating a folder to put JavaScript libraries for use with Node-Red. In the Node-Red settings file you can define such a directory – just make sure you don’t call it “js” as Node-Red already has one of those and you’ll end up in trouble. I call mine “myjs”.  Go and grab the skycons.js file and put it on your system. You’ll find a lot of information in that link I’ve just given you.

For 6 days your flow will look like this..

weather flow

So – every 5 minutes or however often you choose, grab the relevant icon from the global object you are populating and inject it into one of these templates.

Here is the code for template 1.

<script src="/myjs/skycons.js"></script>

<canvas id="icon1"  width="50" height="50"></canvas>

<script>
var skycons = new Skycons({"monochrome": false, 
                "colors": { 
                      "main": "#779966", 
                      "moon":"#666666",
                      "fog": "#555522",
                      "fogbank": "#884488",
                      "cloud": "#999999",
                      "snow": "#aaaaaa",
                      "leaf":"#00ff00",
                      "rain": "#0000ff",
                      "sun": "#ff3300"
                    } });
skycons.add("icon1", Skycons.PARTLY_CLOUDY_DAY);
skycons.play();

    (function(scope) {
        scope.$watch('msg.payload', function(data) {
           if (data=="clear-day") skycons.set("icon1", Skycons.CLEAR_DAY);
           if (data=="clear-night") skycons.set("icon1", Skycons.CLEAR_NIGHT);
           if (data=="partly-cloudy-day") skycons.set("icon1", Skycons.PARTLY_CLOUDY_DAY);
           if (data=="partly-cloudy-night") skycons.set("icon1", Skycons.PARTLY_CLOUDY_NIGHT);
           if (data=="cloudy") skycons.set("icon1", Skycons.CLOUDY);
           if (data=="rain") skycons.set("icon1", Skycons.RAIN);
           if (data=="sleet") skycons.set("icon1", Skycons.SLEET);
           if (data=="snow") skycons.set("icon1", Skycons.SNOW);
           if (data=="wind") skycons.set("icon1", Skycons.WIND);
           if (data=="fog") skycons.set("icon1", Skycons.FOG);
        });
    })(scope);

</script>

The other templates are identical EXCEPT that: they don’t need the include – and they don’t need the definition of skycons. Also – wherever you see “icon1” – change that to “icon2” etc.. up to “icon6” assuming you want 6 days. “icon7” if you want to go all the way to 7 days.

If this does not work smoothly – check out that you ARE pointing to the javascript library and that you’ve made no mistakes – check that the data is actually going into the template node and make sure you have an up to date Node-Red and Node-Red Dashboard.  That will serve well later as I’m no-where NEAR finished making use of templates… just the thorny matter of getting data into and out of them to get to grips with.

If you have problems formatting these images - I noted when moving them mine came out stretched - this is some js and css  I use for other purposes but I think you need the padding css in a template (make this the first template - auto size - it will not show up) - to remove padding around the edges .

<style>
  .filled { 
      height: 100% !important;

      padding: 0 !important;
      margin: 0 !important;
  }
  .nr-dashboard-template {
      padding: 0;
      margin: 0;
  }
  
  .rounded {
  border-radius: 12px 12px 12px 12px;
}
 
   .bigfont {
  font-size: 18px;
}

   .smallfont {
  font-size: 12px;
}
  
</style>

<script>
$('.vibrate').on('click', function() {
  navigator.vibrate(100);
});

function restore_bg(x) {
            $(this).css("background-color", x);
    };

$('.touched').on('mousedown', function() {
    var x= $(this).css("background-color");
    $(this).css("background-color", "yellow");
    
    setTimeout(restore_bg.bind(this,x),200);
    navigator.vibrate(80);
    });
    
</script>
Facebooktwittergoogle_pluspinterestlinkedin

Virtual Pi

$
0
0

Every time I screw up badly, I end up having to go through to the house, swap SDs on the Raspberry Pi and start another backup. AND I’m told by our friend from Raspbian that I should not be doing this as live backups are asking for problems. Now, to be fair I’ve never HAD A problem with the Raspberry Pi SD copy program but that’s not to say I won’t – and of course none of the other Pi-like machines I own have such a simple backup facility (don’t go giving me a lecture on complex Linux backups please).

tmpD42CAnd so it was that one of our readers (Dr Fraggle) put me onto a VPS (virtual Private Server) facility this week – for less than £3 a month you can have your own virtual Debian. I took this up for a trial as I’d had immense difficulty in the past with Virtual PC etc. on my computer due to making the mistake of installing Docker.  So I’ve been playing over the weekend with this VPS service called OVH. Now, their service works really, really well - but the customer service is virtually non-existent as far as I can tell.  It was with that in mind that I grabbed some coffee today and sat down to clean up my Windows 10 PC and install VirtualBox.

I followed the instructions and downloaded a virgin Debian – expecting the same kind of experience that I got out of OVH or one of my little SBCs (I should say at this point that my script – which installs the kitchen sink – works absolutely perfectly on OVH).  Up came a fully-laden Debian complete with graphical desktop and all the trimmings… I went into a terminal and the first thing that came to mind was “sudo apt-get update”.  Well, that’s what you do, isn’t it.

Nope. No “sudo” – never heard of it, mate. This came as something of a shock. Anyway turns out it wasn’t installed, I sorted that and did an update. After a file edit to stop it looking for repositories on a DVD that the VM doesn’t have – I was away with a full update and upgrade. Dare I try my script.

tmpE86DWell, that failed at the first hurdle – virtually every one of the general pre-requisites and utilities I normally install failed miserably. So much for Linux not having the version issues Windows (supposedly) does! Debian isn’t even the same as Debian!

It was at that point of utter despair that my pal Jonathan called in on Skype as if sensing I was getting annoyed. No – you don’t want to do it like that, he said,  there’s a ready-built DIETPI image for VirtualBox.

And so there was.

I grabbed the image from the DIETPI website, loaded it in, created a PI user (I’ve a short script for that, too)  and loaded up my script. NOT A SINGLE ERROR – it’s not even this clean on a proper PI !!! Mosquito, Node-Red, my start-up page, MQTT, SQLITE – it’s all there!!

I’ve done a backup of the basic Debian and a backup of Debian plus all my tools and toys – and now I’m ready to take on the world. For those who don’t know, VirtualBox, DietPi and my script are all available on the web and all available for free. What a great way to test stuff out, now I can make changes to the script fearlessly (my ain is to make it a lot “cleaner” – without all the messages you can’t do anything about), safe in the knowledge that if the whole thing explodes, I’m a button-push away from starting again and it’s all a LOT faster than a PI on my Windows 10 machine (which was super fast about 4 years ago).

Can’t QUITE see how to get the USB emulation going so I can mess with SDs, but no doubt someone reading in here will have figured that out. If you do try out my script – make sure you tell it that this is NOT a real Pi – and don’t try adding GPIO….

DietPi on VirtualBox

Facebooktwittergoogle_pluspinterestlinkedin

ODroid C2

$
0
0

Odroid C2You’ll see in an earlier post a little picture of the Odroid C2 and following on from my last blog, I’ve had tremendous fun playing with the Virtual Debian – i.e. DietPi – and I just happened to be looking at the Dietpi site (which is very nice incidentally) and I noted a board I recently acquired – the Odroid C2.  I’m getting quite excited about this – read on…

As you click on the various boards you see comparisons of performance of the various boards including the Raspberry Pi, Orange Pi and others – most of which I have – AND the C2 – and the latter appears to out on top by some way and in some cases by a LONG way (and as you’ll see later it is not expensive)!

  • Amlogic ARM® Cortex®-A53(ARMv8) 1.5Ghz quad core CPUs
  • Mali™-450 GPU (3 Pixel-processors + 2 Vertex shader processors)
  • 2Gbyte DDR3 SDRAM
  • Gigabit Ethernet
  • HDMI 2.0 4K/60Hz display
  • H.265 4K/60FPS and H.264 4K/30FPS capable VPU
  • 40pin GPIOs + 7pin I2S
  • eMMC5.0 HS400 Flash Storage slot / UHS-1 SDR50 MicroSD Card slot
  • USB 2.0 Host x 4, USB OTG x 1 (power + data capable)
  • Infrared(IR) Receiver
  • Ubuntu 16.04 or Android 5.1 Lollipop based on Kernel 3.14LTS (and of course as you’ll see – DIETPI – Debian !!)

Well, I had to give that a shot! They mention it is very fast and part of that will be down to eMMC and fast Ethernet – not to mention the 2GB of RAM – well, I don’t have the eMMC module – but I DO have a new, fast Samsung Ovo+ SD. So – I grabbed the DietPi  image.

I ran my new PI script to get the Pi user in there and then the main script – I linked to it in the last post. I can only say the script ran FAST – way faster than a Pi and instead of up to an hour, sometimes more, it was all done in just under 20minutes. Not as fast as the VirtualBox version but faster than my other SBCs.

But I noted – the GPIO routines (WiringOP) didn’t load and I noticed there was no GIT installed – I would not have noticed that in the VirtualBox versions as I didn’t install GPIO.

After the Odroid rebooted – I checked to see if everything worked… and most of it did – VERY quickly.

However – once again – no Webmin, though I’d not noticed any issued – did not load!

I decided to tackle the GPIO first – and installed GIT and tried again.

MAKE not found….

Turns out there was a broken repository – the forum for DietPi had a solution which any time soon should end up on their website.

Then I could not get the time synced  - you could not make this off – the main pool servers were out of action…

All of that will be history by the time you read this I would think. I have another way to grab Webmin and that worked – I’ve altered my script accordingly.

So the upshot of this is that everything appears to work with the Odroid C2 and it is FAST even without eMMC. Now, some of the prices I’ve seen on Ebay are a bit OTT but the price seems reasonable if you go directly to HardKernel at $40 plus postage wherever you are.

In the process of doing the install I noted that there is a specific install of WiringPi for the Odroid C2

git clone https://github.com/hardkernel/wiringPi.git
cd wiringPi
./build
sudo chmod a+s /usr/local/bin/gpio

I’ve included that as an option in my script (I really do need a menu system) and if installed, it is indeed possible for the following to work… taking GPIO 1 as an example

gpio mode  1 out

gpio write 1 1

gpio write 1 0

There are two PWM pins (33 and 19) on the C2 according to this documentation however in the “gpio readall” I’m not actually seeing those numbers appear so at this point – without getting into specific addresses etc. and sticking with the simple GPIO utility you can call from, say, Node-Red, I’m not sure how to access them.  Attempts to do any PWM just return “Unsupport function on on ODROD-C2 model”. Looks as if there are a couple of analog inputs as well, yet to be tested. By the look of it, hardware SPI is not supported.

This could still end up as my main Node-Red controller!

GPIO pinout for Odroid C2

Facebooktwittergoogle_pluspinterestlinkedin

Merry Christmas

$
0
0

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 from Sonoff

$
0
0

Sonoff Mains PlugToday I got a couple of new(ish) toys from Sonoff – one being a UK version of their WIFI mains adaptor. So the point of this if you don’t know Sonoff is that their stuff is solid and inexpensive – not two words you normally find in the same sentence. The mains adaptor is absolutely solid – and when it powers on it has a nice coloured ring light to let you know it is working.  Sonoff have their own software for this but as it is ESP8266-based I usually put my own in or use Arendst’s Sonoff-MQTT-OTA-Arduino software – which up to now is proving reliable and has one advantage over my own – it is smaller and fits into the Sonoff devices without replacing the FLASH (well, it has two advantages – it supports the Amazon Echo – but as I use HA-Bridge to do that, the subject is moot).

So – I opened the unit up and Sonoff have even now kindly put labelling on the 4-hole connector inside for programming – very nice of them.

What can I say, Sonoff SCit worked first time, I can fire off MQTT commands to turn the thing on and off and can override that with the button on the front. Most other similar products I’ve seen are either proprietary, expensive or generally naff – this is GOOD and no secrets – you can get diagrams, change software and it works well.  Like the other Sonoff mains control boxes, good product – good price ($12.86 plus whatever post to get to your location – but even then – compare that to B&Q rip-offs). Lovely.

And with that, I’ll move onto the Sonoff SC – the unit you see on the right. No it is not a loudspeaker. To quote the company - Sonoff SC is an ESP8266 based WiFi environmental monitor device. It detects current temperature, humidity, light intensity, air quality, and even sound levels, and directly send realtime data to iOS/Android APP EWeLink

Sonoff SCAnd yes, I believe there is some source out there but this one is likely to be a little more difficult to DIY as it contains both an ESP8266 and an Atmel 328 – no doubt for two things that need A/D where the ESP8266 has only one analog input. So this gadget contains a SHARP Dust sensor, a DHT11 (I know, the crappy one) temperature and humidity sensor, a light sensor (a simple ORP-12) and a microphone – so it is a test-everything unit.  It runs off 5v.

So we ran it up this afternoon – there’s a nice phone app and it only takes 5 minutes to setup – I’m trying to think where you would use this – maybe in an old-folks home you were running just to keep an eye on everything? 

Sonoff SCFor me it fails in that there’s no MQTT connection so unless you use their App the use is limited but they DO claim it is “hacker friendly” so when someone goes to the bother of making a complete replacement software – with MQTT and the option to replace the hated DHT-11 with a marginally more expensive DHT-22 – I may just take more of an interest.

Sonoff SCThe thing is you have light sensing in the range of “dusky, normal and bright” – I’m not sure what use that is – had they made this more than $19 they could have used one of those little light sensors that gives exact LUX out for visible and also measures humidity and temperature accurately.

As it is they’ve used an ORP-12 device which is a bit basic.  Still – if I made a super-duper one and had a 3d printed case made, it would look like something out of Dr Who so hats off to them for making this at a price in a sensible case. It is almost worth getting one for the case to then gut it and do your own thing! Recently in the blog we’ve covered all of these sensor scenarios except for the dust sensing and there’s plenty of doc on that.  Worth a second glance.

Depending on the device you are using you can click on any of these images to get larger ones.

Facebooktwittergoogle_pluspinterestlinkedin

The Orange Pi Zero

$
0
0

Those of you who read my stuff will know that I’ve never been impressed by the Orange Pi boards – the utter lack of communication from the company really is stunning and initially the boards used to get very hot – but then came Raspbian and all that changed – third party support and lots of info.  With that in mind I’ve been looking forward to getting an Orange Pi Zero.

Orange Pi Zero

This is not a high end board but it REALLY is cheap so I had to see it working. Well, I’ve started and up to now I’m not stunningly impressed.  But whether it is the BOARD or the SOFTWARE I’m not yet sure. I installed DIET PI – which has worked so well elsewhere and in this case you really are counting on the operating system working from day one because there is no video output. I loaded up the DietPi software and there is a text file on the SD you can go in and setup WIFI etc. This board has both Ethernet and WIFI but I wanted to go in at the deep end. Well, I failed – no-where on the network could we find the board despite setting it up correctly. Ultimately I chickened out and plugged in an Ethernet lead (there’s a long story of broken leads here but we’ll put that to one side).

The board connected up no problem – I went into the setup and set up the WIFI – it found my access point and connected. I changed IP address – voila.  Rebooted – no sign of WIFI (sigh).  I had several attempts at this with a clean SD each time and for now I’ve given up.

As I write this, my normal script is loading – as yet without issue, on the Ethernet connection.  The thing is – I see these cheap boards as upmarket ESP8266s, i.e. peripherals for dotting around the house – and so the WIFI absolutely must work – I’ve put a message in the DietPi site to see if there are known issues or if it is just me.

If you’ve read some recent posts I’ve been playing with a VM version of Debian that loads my script up in 18 minutes – well, the Orange Pi Zero isn’t quite like that – it’s nearly done now and at 1 hr 20 minutes – not stunningly fast but no worse than a Raspberry Pi 2.

Now bear in mind when I did a review of the WIFI only FriendlyArm NanoPi Air I commented how much faster the eMMC was – well of course you don’t have that option here. This is a nice, cheap board, cheaper than the Air but I would not want to swap.

So the question is – how did the script go? Well, it all works, no problem – nice little board but until I see the WIFI working reliably – so that it can be used as a place-anywhere peripheral – I remain convinced the better bet is the FriendlyArm product UNLESS you’re planning to use hardwired.  I will adjust the blog should I be proven wrong.

The board is available in 256MB and 512MB Ram options – this one was the latter.

Facebooktwittergoogle_pluspinterestlinkedin

The Ongoing Knob

$
0
0

jQuery KnobI refer you to this article if you’re new in here - http://tech.scargill.net/more-dashboard-goodness/ – we’ve been having a lively discussion and lots of exciting new possibilities coming out of a chance discovery of the JQUERY KNOB and what is now our ability to integrate that with Node-Red. The purpose of this is to increase the usability of the web-based Node-Red Dashboard by introducing new and useful controls.

I won’t go through the history here – it’s all in that blog entry which you should read first before getting into discussion here.

So now we can create a touch/mouse-driven knob for Node-Red Dashboard, in a template – and we can replicate as many of these as we like in a tab. Many thanks to those who helped get this off the ground.

But once the novelty wears off, we find that we need more work on this for some scenarios. The knob can be coloured and it’s shape and size can be changed but what about that value in the middle. Early attempts at adding a “%” sign or similar failed miserably – until I actually started looking at the docs for the knob – at which point some things became clear.

I can think of two immediate modifications to the basic knob which come in as useful – the first is the addition of a percentage or degrees character – the second is slightly more complicated. I want to use the knob to show a time in hours and minutes and to let me alter that – worse I want the time to increment in 15 minute intervals – giving me back a value in minutes while SHOWING HH:MM -  so - how to do that:

It turns out to be surprisingly easy if you’ll bear with me.

So firstly the easy one – setting limits and steps can all be done in the input definition.

<input  id="jqueryknob{{$id}}"
        class="cDial1"
        data-width="98%"
        data-height="98%" 
        data-cursor=true
        data-thickness=.25
        data-linecap=round
        data-fgColor="#66CC66"
        data-bgColor="#CCAAAA"
        data-angleOffset=-125
        data-angleArc=250
        data-min="0"
        data-max="1440"
        data-step="15"

        value="{{msg.payload ?  msg.payload : 0}}"
>

If you refer back to the original article – the input definition is in there and I’ve simply lifted that and added 3 more lines – so now we can have any start and any end values and a step – in my case the number of minutes in the day. So how do we get from THAT to the display above right.

It turns out there is an extra bit we can shove into the code… a snippet from the original blog follows with something new – two examples here.

$("#jqueryknob" + scope.$id).knob({
    'format': function (value) {
        return value + ‘%’;
    },
               
    change : function (value) {
    },
    release : function (value) {
        if(scope.msgSend)scope.sendData(value);
    },

The above adds a percentage sign to the display WITHOUT affecting the actual output from our template – you could of course add any other symbol. The example below though looking more complex is just formatting to give me my HH:MM format – again without affecting the output of the template which in this case is in minutes.

 

$("#jqueryknob" + scope.$id).knob({
   'format': function (value) {
        return ("0" + (Math.floor( value / 60))).slice(-2) + ":" + ("0" + (value % 60)).slice(-2);
    },
               
    change : function (value) {
    },
    release : function (value) {
        if(scope.msgSend)scope.sendData(value);
    },

So that one addition above allows you to control what you see in the text of the knob without affecting the actual value.

I suspect there is far more to be gained from further examination of this widget. ANGULAR also has a knob - https://radmie.github.io/ng-knob/ and that has some nice features including subtitles. Perhaps we can look at this one sometime!

For now here is the latest update of the actual code used in my test knob – set the template to 6*6. I’ve removed a line that wasn’t doing anything and changed msg.payload to msg so in future we might add more stuff in there (thanks Dave).

Don’t forget to create a template with the CSS in it – and make sure your template tickbox settings are like this.

 

Template tick-box settings 

Enjoy.

Facebooktwittergoogle_pluspinterestlinkedin

More Dashboard Buttons

$
0
0

Old buttonsThis is about creating buttons for Node-Red Dashboard. If you’re looking in for the first time – this is what Node-Red Dashboard buttons currently look like. The light blue background colour can be changed as can the text colour but that’s about it. And when you press on them, there is some marginal change but not very distinctive.

New buttonsIf you read the previous article on buttons you will know that things are much better now thanks to the use of templates – and that using a template for a button, you can achieve the same functionality but with better colouring and shaping options – rounded corners for example. Of course, having played with this for a few days, the novelty of coloured buttons on my Node-Red Dashboard soon faded and I yearned for something a little more modern.

Ignore the knobs – they belong to another blog entry – the three buttons on the top – the rightmost one (blue) is as we have up to now – it is blue and when pressed flashes yellow. It also vibrates on a mobile phone – all of that was discussed in a previous entry. The two on the left however are new and use background images. They still flash when pressed, they still vibrate – but the image is up to you – the images you see on these were not made to any particular size – maybe 50mm square – in PowerPoint (without the text) and saved as PNG images. The pattern is a bog-standard PowerPoint gradient so lots of nice colours already done for you – just right-click save the rectangle from PowerPoint or wherever.

The trick to maintaining compatibility then when pressing a button is to store away whatever the background colour AND image is, do the button press stuff then restore both the background image and colour. This works a treat.

I would have LIKED to do the background image definition as a CLASS but for some reason that would not work – so it is a style – if anyone can correct this I’d much rather add class “greenish” to the button than a style.

Here is my styling that goes into a template all on it’s own – and an example button which again goes into a template.

<style>
  .filled { 
      height: 100% !important;
      padding: 0 !important;
      margin: 0 !important;
  }
  .nr-dashboard-template {
      padding: 0;
      margin: 0;
      overflow-x: hidden;
      overflow-y: hidden;
  }
  .rounded {
  border-radius: 20% 20% 20% 20%;
}
  .round {
  border-radius: 100% 100% 100% 100%;
}
   .bigfont {
  font-size: 18px;
}
   .smallfont {
  font-size: 12px;
}

</style>

<script>
    $('.vibrate').on('click', function() {
      navigator.vibrate(100);
    });
    
    function restore_bg(x,y) {
                $(this).css("background-color", x);
                $(this).css("background-image", y);
                
        };

    $('.touched').on('mousedown', function() {

        var x= $(this).css("background-color");
        var y= $(this).css("background-image");  
        $(this).css("background-image", "");  
        $(this).css("background-color", "yellow");
        
        setTimeout(restore_bg.bind(this,x,y),200);
        navigator.vibrate(80);
    });
</script>

and a button - if you want roundish use class "rounded" - if you want round use class "round".

<md-button 
    class="alerted filled touched bigfont rounded vibrate" 
    style="background-image: url('/myimages/orangeish.png'); background-size: 100% 100%; background-repeat: no-repeat;"
    ng-click="send({payload: 'Red Button'})"> 
    bg-image<br/>button
</md-button> 

Facebooktwittergoogle_pluspinterestlinkedin
Viewing all 1391 articles
Browse latest View live