File Share Quickies

Following on from an initial comment by Keith Howell in the blog about NGROK, Antonio and I were chatting today about TKaiser’s little testing script and I wanted to share something with him. Skype of course is useless at this unless it’s a very small file - but we’ve used a tool called HFS in the past which opens up a simple file-sharing web-based system on your PC, meant for short term use of course.

Well, you can then of course give someone else access but that’s a pain as you have to go doing port redirects on your router – a little OTT for a simple one-off file sharing.

HFS

Combining two little utilities makes short work of this.

HFS lets you collaborate on files… while NGROK opens up the server port to the outside world without going anywhere near your router. Above you see the local version of HFS – and you can drag and drop files into that file area on the left… below you see the web version in this case on port 83 but any port will do as long as it isn’t in use.

HFS

If you look at the first image – top left where the house and the backslash is – you can add username and password for access by a simple right-click.

So – now you can go mess with your router and do a port redirect so someone can access this to grab files… OR open a command box in Windows and…

ngrok http 83

At which point the command line will show you the URL for someone to type in order to get the web page above! That’s it.  If you want to do stuff like secure access (HTTPS) and more you have to pay for NGROK but for this simple version – it’s all free.  Whenever you use NGROK you are given a unique access address so this is really meant for just short term use. Note again – use of port 83 here is arbitrary.

Both of these packages are installation-free – just stick them somewhere convenient like the desktop.

https://ngrok.com/download  (mac, Windows, Linux)

http://www.rejetto.com/hfs/?f=dl

Facebooktwittergoogle_pluspinterestlinkedin

A Question of Lifespan

I’d like to start off a conversation about SD Lifespan. How can we make our SBC projects run for longer? In comments I've seen elsewhere, people seem to think it is ok that a Pi may well fail within a year due to SD - I don't think that is even REMOTELY acceptable unless you're making a novelty games machine.  People make a big deal about the reliability of Linux - not a great deal of use if the entire file system will come to a halt in a year...

I've never suffered this problem - my first heating system issue has appeared after more than a year's continuous use (and that includes doing lots of experiments on the same system).  You may have seen comments in earlier blog entries about this – for the first time ever I recently suffered a dead SD on one of my Raspberry Pi projects – stone, cold dead – read only and NOTHING on the Pi or my PC could encourage the SD to write again.

It has been said that some cheap SDs are not as large as they seem and as soon as you exceed use beyond their ACTUAL size – the chips become read-only.  I’ve yet to test this out but TKaiser has suggested testing all new SDs and in a previous comment has recommended SanDisk Extreme Plus.

The test program H2TESTW is widely available for free. I’m testing my first 16GB disk now – looks like it will take 20 minutes but as no user interaction is needed… time well spent.

In here you will find questions and opinions. In the comments hopefully you will find some resolution – lots of bright people read this blog and I’m hoping they have solutions rather than opinions.

If you read on the web about the subject of eMMC and SD and USB memory – it is hard to tell what is hard science and what is opinion.

For example there are blogs suggesting that instead of relying on SD, use a USB memory stick. I have trouble with this as the technology is similar. Why should a USB stick last any longer than an SD.

You’ll see reference to eMMC – there can be no doubt that eMMC (usually an internal module or chip) is usually faster than SD – but does it LAST any longer – some say yes, some say no. To be sure it is less convenient to back up compared to an SD you can simply pull out and replicate!

Then there is the hard disk. I have a natural tendency to think that a spinning disk has to be less reliable than solid state memory but every experience I have says the opposite. I could not tell you the last time a hard disk went bad on me. Of course – they tend to be more expensive – and they are very much larger than SD.

The general idea is that you can READ SD as often as you want but there is a limit sometimes described as 10,000 write cycles, sometimes describes as 10 times that amount. I suspect the latter and that there is just a lot of old information out there.

Then there is WEAR LEVELLING wherein some SDs have a chip inside that helps prevent a single location being written to, too many times – knowledge on this seems to be akin to witchcraft. WHICH manufacturers use this in WHICH SDs and HOW effective is it? I’ve not found a single source of information on the subject that is up to date and verified.

Today I read about putting some directories into RAM.

In the /etc/fstab file you can add for example

tmpfs /var/log tmpfs defaults,noatime,nosuid,mode=0755,size=100m 0 0

Works a treat but for one tiny item – Apache would not start up!

Several people have mentioned RAMLOG – but from what I can see –that no longer works with Jessie (the problem of old material hanging around on the web. This looks modern – and is reasonably straightforward to install – takes just a couple of minutes. https://github.com/azlux/log2ram – I installed it – and it works at treat. The default action is to update the disk every hour  - but moving the file “log2ram” from /etc/cron.hourly to /etc/cron.daily to me makes more sense.

So many questions – so many potentially wrong answers. See comments about actual number of writes to SD – would you believe any given location (not the one you see but the REAL location) could be as low as 1000s rather than 10s of thousands  – I had no IDEA it was that low).

On the subject of power supplies, in the comments you’ll find code for testing the likes of the Raspberry Pi – as there are registers in the Pi which pick up voltage issues… I was horrified how easy a long USB lead would allow the the Pi to work – but continually to register issues.

In testing – I found comments from TKaiser useful – then when wondering about the CPU frequency I found THIS article – and the associated script useful..

http://megakemp.com/2013/02/26/adventures-in-overclocking-a-raspberry-pi/

So already we see a need to reduce writes, only use good, tested SDs, use good good supplies with short leads. Not new, not rocket science but I am seeing some good science behind the need for this and look forward to reading more of your educated comments.

Keep the comments coming!

A Little Test

In the process of this discussion, TKaiser supplied us with a little script to return some information about power from the likes of the Pi2 or Pi3. This was intended to be used as a command line tool – repeating until told otherwise. Well, I like REPORTS…

I took out the loop section so as to return a single line of information – and that can conveniently be run in an EXEC node in Node-Red

Node Red showing Pi variables

 

I changed the script to simplify output – if someone can tell me how to produce output without “’C” and “V” so we have just numbers coming out – would be nice… I called this tk2.sh (changing permissions – don’t forget) and ran that inside an EXEC node in Node-Red…

     Maxfreq=$(( $(awk '{printf ("%0.0f",$1/1000); }'  </sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq) -15 ))
    Health=$(perl -e "printf \"%19b\n\", $(vcgencmd get_throttled | cut -f2 -d=)")
    Temp=$(vcgencmd measure_temp | cut -f2 -d= | tr -d C | tr -d \')
    RealClockspeed=$(vcgencmd measure_clock arm | awk -F"=" '{printf ("%0.0f",$2/1000000); }' )
    SysFSClockspeed=$(awk '{printf ("%0.0f",$1/1000); }' </sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq)
    CoreVoltage=$(vcgencmd measure_volts | cut -f2 -d= | sed 's/000//' | tr -d V)
    if [ ${RealClockspeed} -ge ${Maxfreq} ]; then
        echo -e "${Temp}$(printf "%5s" ${SysFSClockspeed}) $(printf "%019d" ${Health}) ${CoreVoltage}"
    else
        echo -e "${Temp}$(printf "%5s" ${RealClockspeed}) $(printf "%019d" ${Health}) ${CoreVoltage}"
    fi

(If you see a question mark above - the word is sampling)

As you can see we have some space-delimited values! If you look at the bitfield, semi-permanent recordings of issues are on the left (most significant bits) while on-going issues are on the right. Extracting from TKaiser’s notes..

The bits on the right are:

0: under-voltage

1: arm frequency capped

2: currently throttled

And corresponding on the left:

16: under-voltage has occurred

17: arm frequency capped has occurred

18: throttling has occurred

It is easy enough to break this down..

Here is another version where I have split up the values

tmpA7A1

The first is the input – the second is the split version – the same except they are now in 4 different places

var reading=msg.payload.split(" ");
msg.payload=reading[0] + " " + reading[1] + " " + reading[2] + " " + reading[3];
return msg;

And from there you can do what you like with the data of course – one idea might be to read every minute and turn that string bitfield into an integer,  totalling up errors in the lower bits (you could just read bits of the string to achieve the same thing) … after a period send off a report email…

No need to report over-heating as the governor should take care of that – however – min-max summary in the email might be nice while testing.

Facebooktwittergoogle_pluspinterestlinkedin

Raspberry Pi 3 Serial

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

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

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

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

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

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

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

dtoverlay=pi3-miniuart-bt”"

to the /boot/config.txt file.

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

Facebooktwittergoogle_pluspinterestlinkedin

Microwave for the Weekend

tmp2DA0If you read the blog about the Maker Faire, I just came back with a bag of goodies and one of them is a microwave movement sensor.

Not the two-board solution I discussed a while ago that never really worked – this is a small, neat single board called an RCWL-0516 and here’s a Chinese link though if you get in touch with the fellow I mentioned at the Faire where I got mine – ABX-LABS (Ebay shop) he might have them. About £1 anyway.

So this board has 5 wires and not a lot of information out there, some of which is in Russian. I did found out enough to know that this unit is oscillating at around 3 Gig and you only need to use 3 of the 5 wires!

The unit will pick up movement up to 7m away and in the right circumstances can see right through wood! No silly comments about being irradiated please.

So I set it up on my bench, the 3 wires of interest are ground (obviously) VIN and VOUT. Stick 5v on VIN (will not work on 3v3) and a LED on VOUT – and you’re done – it works.

Well, that was easy and of course it WAS too easy. I took the board and applied it to one of our ESP8266 boards which have 5v – and took the output to Pin 14 which in the case of my software, is a de-bounced input which can send an automatic MQTT message on change.  Job done – except – it would not work. It seemed over-sensitive but after more careful checking – it really wasn’t taking too much notice of movement – instead triggering fairly regularly ALL ON IT’s OWN!  I tried putting a cap across the power, I tried putting a cap across the output – all to no avail.

In the process of having a gripe with Aidan that we’d been ripped, I put the board on my standalone test to show him it working – and decided to route ground and signal back to the ESP – it worked perfectly – then it twigged -  ESP8266 boards are prone to putting spikes on the power lines when transmitting!  I put a 10r resistor in series with the power and a tiny 330u 6v cap to ground at the Microwave board end – problem solved.

If you want to do something clever, the 16 pin logic chip – I stuck a scope on it and pin 12 gives off some interesting analog stuff!

In terms of sensitivity it pretty much works 360 degrees though supposedly it is most sensitive on the component side of the board direct on.

I spend half of my time waving my arms about at the normal room IR sensor to keep lights running – this I think will be MUCH better.

Have fun.

Facebooktwittergoogle_pluspinterestlinkedin

Newcastle Maker Faire

Maker Faire Newcastle 2017What a great day. Newcastle has an annual Maker Faire and it is on this weekend – and what a faire it is.

I headed off first thing to get some parking and was pleased to find that Newcastle College had some cheap parking - £4 for the day. I arrived 45 minutes to early, thankfully the security guard was a chatty type who wanted to know what all the fuss was about so we filled in time while waiting for my friend Aidan to turn up.

We got talking about cars as that was his thing and so by the time Aidan turned up in his Tesla, the guy was itching to see it and up to his armpits in questions.

Self-balancing one wheel vehicleThe faire started at 10am and we arrived shortly thereafter – it was CHOCKER full of people.

I’m so pleased this has turned out to be a success over the years – there was a time when “makers” – were treated a little dismissively by the public but today everyone wants to come and see what they are up to.

The first thing we came across was a self-balancing one-wheel vehicle and we had a great time talking to the designer – this is not a production job or commercial in any way, he built it because he wanted to – and it works extremely well. Yes, the pad on the front is for “emergencies”.

Rather than design in a modern way, the panelling was very retro – something my friend Melanie-Jane would love to have seen.

As we walked around we were amazed by the variety of stuff people do – from machines that do knitting, to robot hands,to retro gaming machines. A friend of ours Tony was responsible for a mini-version of the PAC-MAN arcade machine, though it had a flat top and I did remind him that the miserable pub people had this changed to round quickly as people were putting their pints on top of the machine. Well, if you’re going to spend all night playing you need somewhere to put your beer!!

Aidan Ruff making a flying thingNext off we came across an interesting idea – a bunch of clear tubes maybe 12” diameter and 6ft or more high – with air blowing up them. The public was provided with cups. paper plates, glue and sticky tape and invited to design the gadget likely to Flying thingreach the top of the tube without falling to bits or coming back down. Aidan could not resist the challenge and so while I manned the phone he proceeded to build a very high-tech device – which actually went in – out the top and continued on for some time – no doubt setting a world record – but then – that’s what I’d expect.

If have to say, if you saw the contraption he built, there was no way this was going to fly – but it did! Flimsy as it was the device went into the tube and headed straight up at tremendous speed and cleared the top of the tube by a long way. I’ll bet the kids who were competing flying thing in actionwere hopping mad. Afraid you can’t beat a gadget man who is also an experienced, qualified pilot…

Big round of applause and we were off to get some coffee before the next challenge..

Next stop, tPDP 8here were LOTS of tables with things that people had made – LOTS of them – some trivial – a few flashing lights – but not this – a genuine mini-version of the old classic, the PDP-8 computer – all done with wood, loving care and a Raspberry Pi.   I’ve been planning to build an IMSAI for some time but this was just wonderful.

There can be no doubt that modern computers are fantastic – and the computers from mid-last century were toys in comparison – but the Open Source Robot Handsdifference is – you could SEE and understand what they were doing (well, a relatively small number could – most people don’t know how their TV remote works but they’re probably not reading this blog) – it’s almost worth having one of these just as a piece of furniture – in some ways it reminds me of the bank of flashing lights on “Voyage to the tmpD569bottom of the Sea” or “The Time Tunnel” and similar. But this is a real, working machine. If you can click the image and scale it up – you’ll see it was made with love.

Open source robot hands, open source 3D printers – what a combination. We met up with an old pal of ours Dave Alan – a fellow who I met at the start of the microcomputer revolution – he has speech running on a 6800 processor WAY before the big boys thought of doing it (funny enough I had the same on a PIC and have an award on the wall to prove it – then along came PC speed and that was the end of that).

We saw and had explained a new 3D Printer – no more than £350 inc. VAT which used a new recycled plastic which does not bend and warp Dinosaurlike older materials – and I have to say, some of the parts they built with this were almost production quality – a non-technical person would not know the difference between that and a milled plastic part – VERY impressive – and not even a special heated cover over the thing!!!

Want one (but then I want a router and a laser cutter and….)

tmp73BAmong other delights there was a genuine dinosaur wandering around with his (her?) handler. Very impressive. Oh and you see those drawers on the right – wow – I SO miss the old radio rallies and computer shows where people brought their old junk 0 but better, suppliers brought tons of surplus stuff and sold dead cheap.  And so it was that the bearded fellow on the right – SO missed this – he decided to resurrect the idea – he had many dozens of £1 trays (3 for £2) and the prices were REAL bargains – anyway I think he’s called ABX  http://stores.ebay.co.uk/abx-labs

Robot

And that was about it – we talked to loads of people including friend Tony at the Newcastle Maker group – I hope to get to go see them in the autumn when we come back to the UK.  A GREAT day out for all the family, good prices on food – which makes a change as sometimes these things are a rip…

If you you are in the area next year, same time I strongly recommend a visit but of course such events are on all the time, all over the western world really. If nothing else you can guarantee that if you put a bunch of techies together – they’ll be dying to tell you how they made their stuff – and that is what makes these events so special. Well done to everyone involved in organising this.

Facebooktwittergoogle_pluspinterestlinkedin

Help

Looking for help on a couple of items where Google has failed me..

1. Friedland door/window contact twin-pack DC-55.   I have them running – I have RFLINK talking to them – I understand the codes for door opening  and door closing and another for the internal spring being released (anti-theft) – but there is another signal which occurs occasionally – I’m assuming it is something like “battery ok” – but that suggests another “battery not ok” – but I have NO info on this – anyone?

Status: Still no feedback on this - and Friedland's site has no useful info that I can find.

2. On the RFLINK board I have a little whip aerial – it is 70mm high and has the miniature screw fitting for the board at the other end.  What inexpensive, simple antenna would be SIGNIFINANTLY more sensitive without being directional.  From my outside office I can reach just into the house but only just.

Status - some GREAT feedback here but nothing definitive other than it is looking like a DIPOLE might've been a better bet.

3. Grafana and INFLUXDB.  I have upgraded Influx to 1.2 (see the blog entry if interested) but a problem persists – I have a graph showing several temperature lines – inside and outside stuff – nothing extreme.  I have two of them with duff readings in them – one is minus 400 and the other is +6000.  I cannot figure out how to delete readings outside of a range in InfluxDB (on the Pi) and I cannot seem to get WHERE clauses to work in Grafana.   WHERE value < 100 for example just makes the line disappear.   Anyone know the answers?

Status: Solved!

InfluxDB (I'm on v 1.2) you can only delete readings by time - but you CAN do normal queries which return the time.

The CLI (command line interface) is called "influx" - enter that and you end up in an interface you can get out of with "quit".

While in that interface you will see a prompt >

use x  (where x is the name of the database)

select * from y where value>z

where y is the name of your measurement and z if the value - well, this is what I needed it might be equal to, less than etc etc.

You get a bunch of results with the timestamps.

To delete a value - well, here's an example.

delete from uk_office_temperature where time=1490109437728705735

and that is it - it is that simple - when you know how - NOW I can clean up my database and in fact I'll now add filters on the incoming data to stop this happening again.

Thanks are given in the comments - thanks to all for feedback on these subjects - now those of us who didn't know - do.

 

Facebooktwittergoogle_pluspinterestlinkedin

A Fine Sunny Weekend

Scargill's Man-CabinEvening all, it has been a busy weekend here at the Scargill’s man-cabin. No Friday, frequent blog-visitor JAY popped over for a visit and we spend some time discussing new stuff:

First on the list was a new toy Jay just picked up on offer at Maplin – a “SmartSensor Energy Egg” solo pack which comprises a PIR Egg and a mains socket. The two operate on 433Mhz and allow for turning a light on for a predetermined time when someone moves in the room. Simple enough – but At under £8 on offer I guess Jay could not refuse. I have one sitting in front of me now looking for a home in my office. There is a website – energy-egg.com but I advise against it – half of the links go no-where. Anyway – special offer – Maplin.

The gadgets are meant to run stand-alone but of course we had to try it out with the RFLINK 433Mhz setup and sure enough – the RFLINK registers activity in the PIR.

Turning the PIR on and off with the handy button on the top produced this output.

"20;31;Eurodomest;ID=0eec5a;SWITCH=05;CMD=ALLON;"

"20;30;Eurodomest;ID=0eec5a;SWITCH=01;CMD=OFF;"

ChatbotEnergy EggStrangely the effect was the opposite of what you might expect – the ALLON command turned the light off!! Anyway the upshot being we can easily monitor this device along with others using the RFLINK.  Sadly when we tried to turn this into a COMMAND to turn the light on and off from the RFLINK unit, while we could turn the device ON, the OFF command stubbornly refused to work – but we started sending emails off to Frank Zirrone of RFLink software fame – and he was very helpful – we’ve now send some diagnostics off (this all comes in the software folder for RFLink) and he’s taking a look.

Meanwhile we discovered a potential issue with the playground covered earlier in this blog – the mobile phone as server. I’ve been using TASKER on the phone to pick up MQTT messages from the Debian installation (to in turn play a really nice doorbell sound) – using the MQTTCLIENT Tasker Plug-in App which you might recall replaced it’s somewhat ill-fated predecessor. Well, it seems it is still not out of the woods.

ChatbotWhile it works GREAT, if you reboot the phone, while everything else comes up perfectly including Debian itself, Tasker and, well, yes, everything – the MQTT plugin – would you believe does NOT re-connect with the MQTT broker until you open the app.  Now this may be because it is starting before Debian is ready – but you would think that such a program designed to run in the background, would try, try, try again until it got through. We even tried using Tasker to initialise it – no joy.  So until the author comes back, we’re on the hunt for alternatives – and it is possible that TELEGRAM may be it  - Chatbotexcept having installed it on my phone (easy) and on my PC (easy) and installed node-red-contrib-chatbot on Node-Red - with a wopping 37 nodes  - I'm now utterly confused. Jay helped me set up a bot and send a message to it - but getting it to arbitrarily send a message... I'm not quite there yet - and what you're supposed to do with all those OTHER nodes....

ChatbotThere is a TELEGRAM app for Android, a plug in for Node-Red and in fact it comes on just about all platforms – this is similar to other messaging apps in that you can send text message back and forth – so the hope is that we can send messages between Node-Red on Debian – and the Android Tasker reliably – more on that later.

Anyone have any experience of using TELEGRAM? I swear this could be the death of me.  A video showing the various nodes in action would be nice!

 

I’ve fitted some door sensors 433Mhz model DC55 from Friedland – comprising a magnet and a reed-switch-triggered 4533Mhz transmitter – all very nice and small – they work a treat with RFLink but right now I’m looking for the meaning of the codes – clearly I figured out the ones for open and close – and there’s another when an internal spring is released – this is for security – but there is a 4th code which comes out very occasionally – and I have no idea what it is for. Maybe “battery ok” – maybe “battery shot” – no way to tell and their manuals don’t seem to help.  Any ideas anyone?

Finally – the script – just updated it to handle that Node-Red initialisation we discussed in a previous blog entry.

Hope you had a nice weekend.

Facebooktwittergoogle_pluspinterestlinkedin

Node Red Initialisation

There have been various conversations about Node-Red initialisation of variables recently. Here’s a solution.

So firstly – what’s the problem? Well, because of the asynchronous nature of Node-Red, it seems to be that sometimes you find yourself using a global variable before it has been defined. No lectures on using global variables please. I can see in my own systems, in the log, incidences of uninitialized variables.

My own solution to the issue of non-volatile storage has been to save global variables as a single object, into a file – and restore said on power up (thermostat settings etc.) – you could store them in MQTT, in a database, anywhere – doesn’t matter. The issue is restoring them.

On power up one assumes the left most tab in Node-Red will run first and that is generally true – but where anything asynchronous is happening – like getting a file for example (hint) there could be delays and other code could run using one of your variables before you’ve actually set it up. This usually does NOT result in Node-Red crashing but you can get rubbish results. Of course you can check every time you use a variable if it exists but that can get messy REAL quick.

A conversation started in the Node-Red discussion groups recently – one of many - and I just latched onto an idea and ran with it.  Of course my first few attempts resulted in suicidal feelings as they failed time after time – but just mid- morning it all started to come together.

So, first things first – the Node-Red settings.js (created when Node-Red is installed and could be for example at /home/pi/.node-red/settings.js)  file runs BEFORE Node-Red comes online – so you know that if you initialise stuff in there, it will be set up in time for you to use – but messing with that file from within Node-Red could be dangerous and you could kill the whole installation. It also  defeats the object of having everything in one nice visual interface.

Here’s another way

Within settings.js there is “functionGlobalContext” which sets up any globals you might need for example – fs object for using files. Here is that section (typically) with one line added into settings.js

functionGlobalContext: {

os:require('os'),

moment:require('moment'),

fs:require('fs'),

mySettings:require("/home/pi/.node-red/redvars.js")

    },

See that last line with “mySettings” -  you can call that what you like.

In (for example) your /home/pi directory, create a simple file called redvars.js (or anything you like really). In there you could put this..

and thanks to Nick O’Leary for the specifics…

module.exports = {

    "fred": 1,

    "brian": 2

}

However, what happens if the redvars.js file is corrupt for any reason – answer? Node-Red crashes..

Here then is a better way:  

At the VERY START of setting.js add this..

var mySettings;

try {

mySettings = require("/home/pi/.node-red/redvars.js");

    } catch(err) {

mySettings = {};

    }

So mySettings is either populated or made empty. No crashing. Now you only need to add ONE line to the functionGlobalContext – here it is in my case… yours might be different…

functionGlobalContext: {

os:require('os'),

moment:require('moment'),

fs:require('fs'),

mySettings:mySettings

    },

As you can see, with an additional comma then one line, a foolproof version of mySettings has been added.

Run Node-Red and you will now find that (for example)  global.get(“mySettings.fred”)  returns 1.  SO – now all you have to do is to put what you need in that file redvars.js – and if you need to update them you can do that within Node-Red. 

In my case I have a variable called counter in there.   Every time I update something, I update that counter to 10;   I have a little timer job running that checks that var and if not zero, decrements it – if it is now zero, it updates the file… see how I did that below.

If you look at my original article on this subject – all seemed well, simply stringify the object and save it to disk – and that’s really how I’d like it to be - but my mechanism for RETRIEVING the object on power-up failed miserably because of the async nature of the file read – often resulting in use of the variables before they existed. This way, that won’t happen and all it needs is to stringify the object and add “module exports-“ at the start.

In the unlikely event that the redvars.file is corrupt, on power-up, mySettings will be undefined – easy to check and if necessary overwrite.

So one simple change on initial setup of Node-Red – and from there on you can create or amend non-volatile global variables from within Node-Red.  You could expand on this of course – that is up to you.

Update 26/03/2017 - This modification is now in the script!

Facebooktwittergoogle_pluspinterestlinkedin

Enter the NanoPi M1+

NanoPi M1+Today must be my day for easy installs. The FriendlyArm NanoPi M1+ turned up this morning along with spare heatsink and antenna.

So first of all what is it? – this is a small SBC, a development from the Nanopi M1 which I’ve reviewed here before.  So is this worth reading? I would say YES. The M1+ comes complete with 8GB of EMMC which as we’ve seen with other boards makes a significant difference to speed. It can of course handle SD.

The most important features are:

  • H3-based (which means there is code out there for the GPIO)
  • Mali GPU
  • 1GB DDR3 RAM
  • 8GB eMMC
  • WIFI, Bluetooth (4.0 dual mode)
  • Gigabit Ethernet
  • 3.5mm Audio jack
  • Microphone on board
  • IR sensor
  • 2 USB-2
  • 2 USB Type A
  • OTG
  • DVP Camera
  • Serial Debug port….

As usual 4 serial ports, though one is debug and one will be tied up with Bluetooth – but that still leaves the Pi wanting.

tmp8DB7I opened up the box, downloaded the EMMC loader image from the FriendlyArm site onto a 16GB SD and ran it on the hardwired Ethernet connector. A box popped up offering to install one of two operating systems, I picked Debian. Minutes later I turned it off – took out the SD, turned it on and… working complete with LDXE. Size – around 70mm * 65mm.

I don’t remember an easier setup – everything worked including SCP access to both users FA and ROOT. I logged in as root from WinSCP, copied my script across – ran it – it created the Pi user, I logged in as Pi, ran the script and went off for coffee. Exactly 58 minutes later the whole thing was done and dusted with all my favourite software in place.

This time I’d put in a new addition to the script…AVAHI.  Once the script finished I popped into the HOSTS file and the HOSTNAME file and changed the name from “friendlyarm” to “m1plus” and rebooted the board.  Antonio who gave me this mod had assured me that this would now mean local access to the boards by name – which should work but hasn’t in the past.   I went to my browser on the main pc and typed http://m1plus.lan and sure enough – up popped the board. I tested all my main programs – all work. Actually, just http://m1plus works too.

I’ve not done any speed tests other than the script install which at 58 minutes is not bad…. but the whole thing has a good feeling of speed about it.  This could be my new favourite board. Up to now it has been the M3 boards but the fan noise is getting on my nerves a bit – need to sort that – the M1+ definitely does not need a fan.  I have hardwired Ethernet on one IP, WIFI on another – the WIFI is reporting a good signal WITHOUT an external aerial. I checked the Bluetooth and it immediately found my Bluetooth speakers.

So up to now, all looks good and as we’ve seen the H3 before there should be no horrible surprises anywhere.

I’ll let you know more about speed and reliability as I get into using this little board. Just a shame they’d not put the connector on for their LCDs… but hey – you can’t have everything.

Facebooktwittergoogle_pluspinterestlinkedin

FriendlyArm S430

S430 DisplayThis could be one of the shortest reviews I’ve ever done!  The S430 is a low-cost  4.3” capacitive touch-display designed to work with FriendlyArm boards such as the NanoPi S2, M2, M3, the NanoPC T2 and T3 and finally the Smart4418.

When I think of the HASSLE I’ve had getting a cheap(ish) Chinese display to work with my Raspberry Pi 3 (read elsewhere – still not resolved – you have to make changes to the Raspbian system but more importantly alignment no longer seems to work so the touch part is useless and no-one has a solution).. I spend days on this and finally settled for a display with no touch!

But I digress. The S430 offers 480*800 resolution, is bright, clear and has 4 nice recessed mounting holes and a ribbon cable out the back  - none of this HDMI-awkward-connector nonsense as per the above.

And that’s it. I unpackaged the unit, I took a NanoPi M3 which was sitting minding it’s own business serving up Node-Red – I turned it off – plugged in the ribbon cable, turned it on – and immediately, lightning fast text – no drivers, no setup, nothing.  When the board eventually popped up with Debian – everything worked – accurate positioning, sensitive capacitive touch etc.

tmpC1FFIt really is hard to say much more more – it is good and it does what it “says on the tin”. It is accurate, thin and most importantly, it is cheap.

As you can see, I just happen to have everything set up in portrait mode and it all just works. Being capacitive I’ll have to go find a proper capacitive pen as you can’t just use any old bit of plastic as you would with the resistive displays – on the other hand – no pressure is needed either.

I could see this working a TREAT with Node-Red Dashboard.  Images in here will expand if you click on them.

I’m quite excited as you can tell.

There is a BIG caveat to all of this which may or may not be important to you – I asked FriendlyArm about landscape mode and they said they had “not implemented landscape mode” – something I find extremely strange… that’s going to limit things a bit….

Facebooktwittergoogle_pluspinterestlinkedin