NOT Rip-Off Britain for Raspberry Pi

Here’s a bit of a reversal.. normally I steer clear of the UK for pricing as we tend to pay over the top… I can’t help thinking I’m reading this incorrectly….

Raspberry Pi 3

However – here above is RS Components latest pricing for the Raspberry Pi 3 – the latest model – at just over £27

And that’s fine – compares to what, say the USA would pay. I think I bought a model 2 last year in the USA for slightly less.

But check this out…

Raspberry Pi 2AliExpress who you can normally count on a decent price…

Claiming 65% off and charging £38 for the old model 2 !!!

Am I missing something here?

The funny thing is – after seeing this – I found more – I found a Raspberry Pi 3 all on AliExpress – for £29.29 with free shipping – which is a GOOD price – then the older Pi2 for an amazingly high £53.98 (they are kidding, right~?)  – the two prices sitting right next to each other!!

Oh, here’s the link for the 3 in case anyone’s interested…



I’m sure Linux life would be a LOT easier for beginners if it were not for the pesky permissions..

You’ll see in previous blogs that with help from readers, I discovered that the WIRINGOP library will work with H3 chips – and allow access to the pins on for example the FriendlyArm NanoPi M1 boards.

A compiled C program such as this…

#include <stdio.h> // Used for printf() statements
#include <wiringPi.h> // Include WiringPi library!   const int pwmPin = 7;
int DELAY_MS = 30;
const int pwmValue = 75;   int main(void)
    // Setup stuff:
    softPwmCreate(pwmPin, 0, 100);
    printf("PWD is running! Press CTRL+C to quit.\n");
    int up;
    int down;
    {     {
      for(up = 11; up <= 21; up++)
            //pwmWrite(pwmPin, up);
            softPwmWrite (pwmPin, up);
      for(down = up; down >= 11; down--)
            //pwmWrite(pwmPin, down);
            softPwmWrite (pwmPin, down);
            delay(DELAY_MS * 2);
    }   }
    return 0;

can be compiled as such…

gcc -o pwm pwm.c -l wiringPi

and lo and behold you can control pins on the M1…. but only as ROOT user – which is utterly useless for many situations.

I then discovered elsewhere that THIS

sudo chown root:root pwm
sudo chmod 4755 pwm

makes the program work for normal users – in my case on new boards I always create a user PI with similar permission to the PI user on the Raspberry Pi.


And so it was that I got all excited when I realised, after discovering that WiringPi has some hardwired limits – (hardwarePWM for example does not work unless you use a REAL Raspberry Pi) that THIS exists for the M1 –

So this is a whole lot of code and demos… one of them is called MATRIX-GPIO_OUT

#include <stdio.h>

#include <stdlib.h>

#include <unistd.h>

#include “libfahw.h”


int main(int argc, char ** argv)


int pin = GPIO_PIN(7);

int i, value, board;

int ret = -1;

if ((board = boardInit()) < 0) {

printf(“Fail to init board\n”);

return -1;


if (board == BOARD_NANOPI_T2)

pin = GPIO_PIN(15);

if (argc == 2)

pin = GPIO_PIN(atoi(argv[1]));

if ((ret = exportGPIOPin(pin)) == -1) {

printf(“exportGPIOPin(%d) failed\n”, pin);


if ((ret = setGPIODirection(pin, GPIO_OUT)) == -1) {

printf(“setGPIODirection(%d) failed\n”, pin);


for (i = 0; i < STATUS_CHANGE_TIMES; i++) {

if (i % 2) {

value = GPIO_HIGH;

} else {

value = GPIO_LOW;


if ((ret = setGPIOValue(pin, value)) > 0) {

printf(“%d: GPIO_PIN(%d) value is %d\n”, i+1, pin, value);

} else {

printf(“setGPIOValue(%d) failed\n”, pin);





return 0;


and so here is a C program that lets you control the actual pins of the M1 – it was the first example I came across – REALLY simple – compile it and sure enough like that previous program – it works – but only as ROOT user.

Thinking I was being clever I tried…

sudo chown root:root matrix-gpio_out
sudo chmod 4755 matrix-gpio_out

SADLY – it would not work as a non-root user even with this – no access.  Is anyone clever enough to know WHY and how to get around it – there are lots of example programs in this MATRIX library but Node-Red does not run as ROOT – cannot access root programs using SUDO and therefore the whole lot are useless to me (and others using similar software) as it stands. The Matrix manual is only available in Chinese so it is looking like WiringPI (or WiringOP) is the only way forward for non-root users of these boards – and that’s a shame. I hope I’m wrong.

Why does the WiringPi C code example work after user is changed to root – but THIS example does not?

Ideas anyone?


Roseapple Pi and Wiring Nirvana

Yes, you’ve heard it all now, we have Raspberry Pi, Orange Pi and now Lemon Pi. But this article is not all that is seems – so read on.

The Early Lemon Pi

Lemon PiThe Lemon Pi was originally touted as being a $35 single-board computer supporting Android 5.0 and Linux.

Embed Studio put this one up in a successful crowd funding campaign.. but why would you be interested in yet another board.

So firstly, price – if the $35 doesn’t get crushed by postal charges (mine turned up in the UK with no duty or anything) it’s a good price. Secondly – and this stands out a mile – it has three USB ports just like the Raspberry Pi – BUT – one of them is USB3  – which could be a game-changer when it comes to using external memory or hard drives!!!

The board ticks boxes for me  – it has both CPU and GPU,  3.5mm audio out for one (and that also supports TV out for very old people) , microSD  DC5v in on a micro-usb, Ethernet, 3 USBs and a standard HDMI video output – so no accessories needed here. It also has the 40 pin RPI compatible pinout.

The quad-core Cortex A9 Arm processor is supported by 1GB  (the website says 2GB RAM, the spec says 1GB RAM – I’ll come back to you on that when I test the board –  and according to the spec there’s the possibility of up to 7 UARTS!!!

For video they claim they can handle up to 4K*2K video (H.264). There is supposedly an IR Receiver but I could not find it and finally the board is 85mm by 56mm.

So the board turned up this morning in a white box with no instructions or info. I scoured the web for info – nothing – why bring out a board with no software.

Would-be Raspberry called Lemon becomes Roseapple

And then while visiting the CNX blog – I twigged – this wasn’t a Lemon Pi after all – It was and is a RoseApple Pi!  And the difference? Well, in the latter, the second 1Gig IS fitted – and it’s called RoseApple Pi – that’s about it.

This board also has Android 5.1.1 available but to be honest I’m sitting back on Android and waiting for it to be properly supported i.e. Android 6 and higher – on the Raspberry Pi 3 – then ALL of the alternatives will have to start playing catch-up.

Anyway I downloaded Debian 8.1 originally – but in August 2016 I decided after my success with other boards to go with Armbian – So I put – it on an SD, plugged it in, plugged in the HDMI and…  it all worked – I could see with a port scanner that it was  called “RoseapplePi” and the display came up – winSCP was just fine (unlike with the original Debian).

I installed my own script with very little modification which gives me Node-Red, Apache, SQLite and Webmin  along with Mosquitto – all worked well and significantly the speech synth software IVONA which gave me so much trouble  elsewhere – installed without issue.

Using the same criteria for testing as I did with the Orange Pi and Raspberry Pi, here are the times taken to complete the system tests.

  • Orange Pi 488 seconds
  • RoseApple Pi 544 seconds
  • Raspberry Pi 2 1,171 seconds

So armed with Node-Red – I checked the /DEV directory and could only find one serial port – ttlS2.  I tried to access that with the serial node –and the usual permissions issue came up – so learning from my experiments with the Orange file – I simply gave /dev/ttlS2 full read/write/execute permission.  I did a test with the output connected to the input (this is the 4 way connector near the twin USB sockets – pins 1 and 2)  and did a little test- VOILA – serial IO.

That out of the way I tackled GPIO. For the Orange Pi I’d managed to get a command line utility working called GPIO – no such utility here until I installed this –  Wiring Pi for the Roseapple Pi.

That was easy and includes the GPIO utility – it was easy enough to find the pin definitions for the Roseapple Pi. Could I go further I wondered? I installed Wiring Pi in Node-Red and rebooted.

I installed Wiring Pi for Node-Red –

The compilation went very well and hinted at all sorts of powerful stuff which I’ll likely never understand.

I changed the Node-Red (/home/linaro/.node-red/settings.js) settings file..

  functionGlobalContext: {
         wpi: require(‘wiring-pi’)
        // octalbonescript:require(‘octalbonescript’),
        // jfive:require(“johnny-five”),
        // j5board:require(“johnny-five”).Board({repl:false})

and restarted Node-Red…

Following instructions here – 

(near the bottom – Wiring Pi) I figured I should now be able to get a blink example going..

But no – the simple blink example produced…

Error: setup: arguments[‘mode’] => (“undefined” in (“wpi”, “gpio”, “sys”, “phys”)) === false

Not only THAT but my serial port had stopped working – was this down to a reboot or had Wiring Pi reset it’s permission? I gave it write permissions and restarted Node-Red.

I tried the command line GPIO and…

linaro@localhost:/dev$ gpio mode 14 output
Unable to determine hardware version. I see: Hardware   : gs705a
– expecting BCM2708 or BCM2709. Please report this to
linaro@localhost:/dev$ gpio mode 14 out
Unable to determine hardware version. I see: Hardware   : gs705a
– expecting BCM2708 or BCM2709. Please report this to

So – I uninstalled the wiring Pi mods (npm remove wiring-pi) and rebooted – NOW the GPIO command line utility worked – and I even tested it – picking a number at random..

gpio mode 14 output

gpio write 14 1

gpio write 14 0

Sure enough – a LED on a pin half way up the connector – GPIOD14 – toggled on and off.

Referring back to my instructions in the Orange Pi blog item – using the EXEC function and”gpio”


The above works a treat – but clearly that is just SLOW input and output…. would be better by far if wiring-pi would work natively.

Anyway I figured it all out the hard way – for simple output…… numbers to pins..

  • Pin 40 GPIO21 gpio nothing default off
  • Pin 38 GPIO20  gpio nothing default off
  • Pin 36 GPIO16  gpio write 27 on
  • Pin 32 GPIO12  gpio write 26 on
  • Pin 26 GPIO7  gpio write 10 on
  • Pin 24 GPIO8  gpio write 11 on
  • Pin 22 GPIO25  gpio write 6 on
  • Pin 18 GPIO24  gpio write 5 on
  • Pin 16 GPIO23 gpio write 4 on
  • Pin 12 GPIO18  nothing default off
  • Pin 10 GPIO15  gpio write 16 on
  • Pin 8 GPIO14 gpio write 15 on
  • Pin 3 GPIO2  gpio write 8 on
  • Pin 5 GPIO3  gpio write 9 on
  • Pin 7 GPIO4  nothing default off
  • Pin 11 GPIO17  nothing default off
  • Pin 13 GPIO27  gpio write 2 on
  • Pin 15 GPIO22  nothing default off
  • Pin 19 GPIO10  gpio write 12 on
  • Pin 21 GPIO9  gpio write 13 on
  • Pin 23 GPIO11  gpio write 14 on
  • Pin 29 GPIO5  gpio write 21 on
  • Pin 31 GPIO6  gpio write 22 on
  • Pin 33 GPIO33  gpio write 23 on
  • Pin 35 GPIO19 nothing default off
  • Pin 37 GPIO26  gpio write 25 on

So all of those pins work using the command line “gpio” – and hence via Node-Red where I tested them – but there has to be a better way.

And how did I check this? Node-Red of course


And the function?

global.set(“parp”,global.get(“parp”) ||0);
if (msg.payload==”on”)
if (global.get(“parp”)<40) global.set(“parp”,global.get(“parp”)+1); else global.set(“parp”,0);
msg.payload=global.get(“parp”) + ” on”;

if (msg.payload==”off”)
msg.payload=global.get(“parp”) + ” off”;
if (global.get(“parp”)>0) global.set(“parp”,global.get(“parp”)-1); else global.set(“parp”,40);

node.status({text: msg.payload});
return msg;

But the REAL magic is here

Here’s where we come to the real point of this update – apart from the pin definitions above – take a look at my similarly updated FriendlyArm M1 article which not only has the pins for THAT board but also now has a solution for general pin control – for non-root users.. – this is what I’ve been waiting for.

Therein you will see a simple C program, easily compiled on the board – honestly – no knowledge needed  (one command-line instruction) and more importantly – the 2 lines necessary to AT LAST make this stuff work for an ordinary user – which means integration into Node-Red. This now makes at the least, the Roseapple, LeMaker, M1 and NEO usable with Node-Red right down to port level. It has taken me a long time to get this far.


Banana Pi M2

banana pi m2 Updated August 19, 2016:  Technically referred to as the BP1-M2+  I received this Banana Pi board in the post this morning. It is SMALL – that is, the same width but just a tad wider than the FriendlyArm M1 and M2.

But there the similarity ends. Firstly this little thing has EMMC, microSD, Bluetooth, WIFI, Wired Ethernet, 2 USB sockets (a tad limiting), 1GHZ Arm quad-core processor, 1GB Ram, 8GB EMMC (which to me is too small but I’m sure people will find it useful – and as for backup… I’d rather use microSD), and it claims to run Android 4.4 smoothly – hence my comment about the EMMC – what use is 8GB for Android??!?!?

The Android version is a little old for me so I thought I’d try the recently updated Raspbian. The blurb SAYS the GPIO is compatible with Raspberry Pi (really? Does it run the Raspberry Pi modules for Node-Red? If so I’ll be impressed).

The downloads and docs are all here which is a big improvement on some others – Orange Pi with hopelessly out-dated images – others with non-working Google Drive images etc.. I got the image no problem for Debian and as I received no documentation with the board, I was grateful for the online version.

I DID notice no audio output other than that on HDMI – which is a bit of a bummer – I like to see a 3.5mm jack for audio. Sadly the manual refers to plugging in a 3.5mm jack for audio – but there is definitely no 3.5mm jack socket on the board.

There is also an IR receiver. I’ve yet to see one of these boards run it out of the box but there IS a reference to this in the manual! – would be awfully handy if this worked in Android for remote controlling stuff.

At this point I just about had the image downloaded and things were going downhill a little.

At the end of the instructions, sure it was obvious you could be now running your operating system – but from WHERE was unclear. I didn’t want to load it into EMMC.

I was encouraged to see WIRINGPI available – but it was not clear if this was a special – if it WAS a special I found myself wondering why they claimed above that the board was PI-image compatible??

THIS page – on copying images – got my interest – up to now in all the boards I’ve tested, the Raspberry Pi is the ONLY board that has a simple to use copy/backup facility that will make duplicate images even on different size SDs!! This would prove to be no good.

SO – first things first… claims about being Raspberry Pi compatible – MYTH (like all the rest) if it were compatible it would run the RPI ROMS and it does NOT – I just tested it – result – nothing.

But on the other hand for the FIRST TIME their package they describe as “Raspbian booted first time – and had an “expand file system” which after a reboot opened up the operating system to the full size of the SD (others – ARE YOU READING THIS!!!). Marvellous.

Not only that but their “Raspbian” which features the Raspberry Pi logo and looks really like a Pi – apart from the monitor overhang which made closing programs difficult – has the latest file backup system that ONLY (as far as I know) the Pi has had up to now – would it work? I took the Raspberry Pi image disk that was supposed to work with the Banana Pi – now defunct as it does not – and used that as the backup.

I booted up “Raspbian” as supplied on the Banana Pi site – and ensured the WIFI worked – it DID (however it only found one access point which compares badly to other systems which find even my neighbour’s access point). It said I had a connection – but a poor one – no more than 12ft away from the access point!!! 2ft away my PC streams movies on that connection!

I plugged in the USB with my microSD in the BP1-M2+ and ran the graphical backup program. All looked well as it found the USB3 drive and started partitioning. “preparing partitions” it said. After what seemed like a similar time to the Raspberry Pi, maybe a pit longer, the software went off to start copying the two partitions, just like the Pi. If I were honest it SEEMED a little slower than the Pi2 but there are so many factors to take in here. It copied partition one and then…

“Could not mount partition” – I have NEVER seen that in a Pi2 or 3 before (and I make live backups all the time)  so I took the chip out and formatted it on a PC – and re-inserted…Once again – “preparing partitions”… I’m sure it took longer than normal… (and remember when I do this normally it is on a system doing all SORTS of jobs with all SORTS of software. This is a simple empty system).

Partition one started to copy – 60%… 70%… 90%… slow.   Not in the same league as Pi3… it stuck at 100% for AGES – I was convinced it was going to fall over… and…

“Could not mount partition”. I tried this three times in total with different SD holders – same result.  Having failed to get anywhere I took the same chip in the same container, put it back into a Raspberry Pi 2 and initiated a backup. This worked PERFECTLY.

I’m sorry guys – this is NOT Raspberry Pi compatible – STOP CLAIMING COMPATIBILITY. the RPI backup program WORKS. This does NOT.

At this point I noted, having received a heatsink with no glue and having written back to ask if it was necessary, that the main ARM chip was running hot enough to cook an egg. Fortunately I found a little heatsink I had lying around and that improved matters.

I wondered if it was worthwhile doing the usual apt-get update/upgrade – and checked to ensure I had a WIFI signal. Sure enough my WIFI was connected – but I could not browse the web or do anything Internet-related. I got that IP address which means – no.   I even tried putting the address in manually – no.

As I was looking at the WIFI – I noted the volume control top right was on mute. I clicked on the slider to adjust it – nothing – would not come out of mute.

With no audio and no WIFI I thought I’d go off on a tangent and try the recommended ARMBIAN. Aside from (again) overscan on my monitor (which works perfectly with a Pi and various other boards) Armbian came up – with a very nice screen and packed full of utilities (but no SD backup). Once again the WIFI would not have it. I plugged in Ethernet and decided to give the video a try – I opened up Firefox – and went to the BBC iPlayer.  Sorry – HTML5 content will not work – you need the FLASH player – and we all know what getting that running is like.

At this point I was ready to give up… but there was one thing left to try.

Android – a particularly old Android 4.x but I figured it might be worth a try. I followed the instructions which unlike any other board I’ve tried did not include blowing an image with Win32DiskManager but instead a piece of converted Chinese software. I tried several times and failed but eventually got a complete, verified image. Put it into the M2, the Banana Pi info came up and then… blank. The instructions said wait a while the first time – I waited 15 minutes – still blank.

Such a promising start, it looked like an RPI, acted like an RPI but… I have to say, disappointed.

I left this for a while – and having given up totally on using this board for any graphical interface due to the fact  thaty there were SO many issues, I thought I’d have a go with Armbian Debian server, the text-only version which has worked well on the FriendlyArm Neon. After a couple of false starts probably due to using a slow SD, I convinced the M2+ to boot from an 8GB SD with Armbian. Aside from some overscan which made it very difficult to do the initial change of password as the text was somewhat off-screen, I managed to get past that stage and onto WinSCP to do the usual apt-get update and apt-get upgrade which worked a treat. I installed the server version of Jessie – so no graphical desktop but it would be easy to add in. I’m inclined to use larger SD cards if I’m installing a graphical interface but 8GB is more than enough for a command-line only setup even with all the extras I typically add including Node-Red, Mosquitto, SQLITE, PHPLiteAdmin, Webmin etc. by my script.

I ran my install script – see the home control project and although it seemed to run somewhat slower than usual, it did run (ignoring unused variable warnings which are irrelevant but keep popping up in part of the script – I do wish people would keep information to a minimum).

Ok, early days – but it does appear that everything works at least in this simple use of the board – I have yet to look at the hardware in depth – clearly the Raspberrry Pi GPIO stuff DOES NOT work – I installed WIRINGOP as this is after all an H3 board and sure enough – pin 40 – that’s GPIO21 – could be made to turn on and off by turning on and off GPIO number 25.

And so after much trial and error…

  • Pin 3 GPIO2 =   gpio write 8 on
  • Pin 5 GPIO3 =   gpio write 9 on
  • Pin 7 GPIO4 =  gpio write 7 on
  • Pin 11 GPIO17 = could not figure out – default off
  • Pin 13 GPIO27 = gpio write 2 on
  • Pin 15 GPIO22 = gpio write 3 on
  • Pin 19 GPIO10 = gpio write 12 on
  • Pin 21 GPIO9 = gpio write 13  on
  • pin 23 GPIO11 = gpio write 14 on
  • pin 29 GPIO5 = gpio write 21 on
  • pin 31 GPIO6 = gpio write 22 on
  • pin 33 GPIO13 = gpio write 23 on
  • pin 35 GPIO19 = gpio write 24 on
  • pin 37 GPIO26 = could not figure out – default off
  • pin 8 GPIO14 =  gpio write 15 on
  • pin 10 GPIO15 =  gpio write 16 on
  • pin 12 GPIO18 =  could not figure out – default off
  • pin 16 GPIO23 =  could not figure out – default on
  • pin 18 GPIO24 =  gpio write 4 on
  • pin 22 GPIO25 =  gpio write 6 on
  • pin 24 GPIO8 =  gpio write 10 on
  • pin 26 GPIO7 =  gpio write 5 on
  • pin 32 GPIO12 =  could not figure out – default off
  • pin 36 GPIO16 =  could not figure out – default off
  • pin 38 GPIO20 =  could not figure out – default on
  • pin 40 GPIO21 = gpio write 25 on

When I say I could not figure out p particular pin – I mean it would don’t respond to simple gpio commands – I assume those pins have other functions like serial that is not clear on the banana pi diagram. STILL not a bad haul!! A quick Node-Red lookup table will sort these and the NEO out…

NOW – take a look at my updated M1 article which not only has the pins for THAT chip but also now has a solution for general pin control – for non-root users..

Overall though I can’t see much reason to go for this board unless you happen to have one handy.


The NanoPi Neo

By now if you read this blog regularly you’ll have heard me rant on about the FriendlyArm boards – mainly because they are inexpensive and actually do work well as Pi alternatives – you’ll also note that I don’t blindly praise them – I’ve still not managed to get the T3 to run a 32gig SD of Android – and it’s an old Android to boot… but generally – I like their stuff.


SO it will come as no surprise then that I’m interested in the new NEO. And why would that be? Because it is SMALL and CHEAP. It has no WIFI or Bluetooth but it has hardwired Ethernet – just the job then for a NODE-RED central controller perhaps?  This is clearly aimed at a market not wanting a graphical interface as no hdmi out – but at the price – I’m happy with that.

So there’s a reason it is cheap – there are two versions, 256Mb RAM and 512MB RAM – I would not personally give time to the former – but the latter would, you would think, run Node-Red, SQLITE and Mosquito without issue… So the extra RAM puts the board at $9.99 plus whatever postage you get stuck with in your country…  cheap by any standard…

But – looking at the docs – it seems that right now the main official option is for Ubuntu – I don’t know about you but when something says “An open source tiny PI” on the front of the box, you might expect it to be somewhat compatible with THE PI.. and that means Debian for me – and no doubt for most people familiar with the Pi.

The internal processor is an Allwinner H3 quad core like the Orange Pi so it is reasonable to assume that there will be alternative  software. It looks like there are 3 UARTS so one would hope for  two to be accessible.

There is one USB, a microSD slot, a micro USB OTG port and 2 USBs via headers.  The expansion port claims the usual, I2c, SPI etc but of course that will only happen if the software will support it.   Size is 40mm by 40mm – which makes it kind of smaller than a Pi Zero.

It occurred to me that setup could be a problem with this board as it has no SCREEN but read on – as it turns out it wasn’t an issue.

FriendlyArm sent a copy of Ubuntu which I’ve no interest in but thought I’d better try to ensure the board was ok. Sure enough it worked but the instructions on the box were the wrong way around. The blue LED flashes constantly – the green LED stays on – according to their info – it should be the other way around. Also to resize the SD they offer a Linux solution – assuming everyone has a Linux computer spare – or a simple SUDO fs_resize. The latter at first didn’t work until I realised that firstly the sudo command was not there and secondly I didn’t need it as I was root !!!

So all of that worked well – but I know for a fact my script won’t work on Ubuntu so I needed to get a working Debian

So – off I went to get ARMBIAN – and sure enough there is one version there for this particular board!

I flashed a 16GB SD with the Armbian code using Win32DiskManager, plugged in the Ethernet and power. A dim green light came on. After a few seconds it brightened up.  And then maybe 30 seconds after that a blue light started flashing regularly along with the green – a sure sign SOMETHING was happening. On the Armbian website it warns that the first time boot could take minutes – so I left it.

Next stop Advanced IP scanner. Sure enough there was a board in my address range – sitting at – with my favourite tool, WinSCP, I used the login credentials root and 1234 and – no file list – it HAD logged in but nothing.  I wrote off to the Armbian guys and apparently logging in with Putty (SSH) was needed to make an initial password change – and sure enough – it worked. I went back to WinSCP – and bingo.

The software asked me if I wanted to change screen resolution which was a bit odd as I was running in a terminal and the board has no screen!!!  Not really sure what to do with that – why would they enable the graphical environment when there’s no screen. So – off I went (as root) to get tightvncserver – and sure enough it installed but would not run – complaining about lack of fonts. No big deal – I un-installed it. i had no intention of running a graphical environment on a board with no screen connection anyway !!

I REALLY think this board needs a heatsink which was not supplied.  I wonder why it is that Raspberry Pi manage to run without one and these H3 boards end up running hot enough to cook eggs – there ARE H3 boards which are faster than the Pi but I don’t think this is one of them.  However the fact that it is so SMALL and inexpensive it is worth a little effort.

Next stop, with the board running Armbian I left it  running my installation script designed for a Raspberry Pi to install a host of utilities and Node-Red, Mosquitto and SQLITE. At VERY first glance it appeared that everything was  working….  of course it occurred to me there is no 3.5mm jack.  And then it appeared that SQLITE has not started up or installed… Mind you I HAD had a power cut in the middle of all of this, closing the terminal session (though not the NEO which was on a battery power-pack). Sure enough, a little manual intervention and that was SQLITE up and running. In the process I updated my script to include the new node-red-dashboard which is the worthy successor to node-red-contrib-ui


Overall? Well, I’m really happy though I’ve not done things like in-depth UART testing – I’ll need to load up some GPIO tools etc. but the bulk of my stuff just seems to work.

All down to postage… this looks like a good deal. With no 3.5mm jack I’ll have to get my hands dirty and solder that 0.1” edge connector on to get audio out. I’ll report on that later and it appears there’s a microphone input too on that connector along with an option for an IR input! Nice.

For connections – see here –

Now as it turns out they bear no resemblance to other boards (unless I’m missing something) – so I started to experiment with the help of links from people in here.

THIS FELLOW – got the M1 working with the Wiring Pi and so I installed that (H3 – same chip) – but could not get pin mappings to work.

I discovered that GPIO WRITE 24 ON turned on the little blue light on the board… and then purely by trial and error…

  • GPIO WRITE 10 ON  –  GPIOC3 – pin 24
  • GPIO WRITE 14 ON  –  GPIOC2 – pin 23
  • GPIO WRITE 12 ON  –  GPIOC0– pin 19
  • GPIO WRITE 13 ON  –  GPIOC1 – pin 21
  • GPIO WRITE  3 ON  –  GPIOA3 – pin 15
  • GPIO WRITE 6 ON  –  GPIOA2 – pin 13
  • GPIO WRITE 2 ON  –  GPIOA0 – pin 11
  • GPIO WRITE 28 ON  –  GPIOG6 – pin 8
  • GPIO WRITE 29 ON  –  GPIOG7 – pin 10
  • GPIO WRITE 24 ON  –  GPIOA6 – pin 12
  • GPIO WRITE 26 ON  –  GPIOG9 – pin 18
  • GPIOG8  (pin 16) could not turn on
  • GPIOG 11 (pin 7) – could not turn off
  • GPIOA1 (pin22) could not turn on

So – that’s a START!!! Just need I2c now!! The only issue for me here is that FriendlyArm ONLY provide and support UbuntuCore for the NEO which is of no interest to me.  I don’t know if this is down to a language problem or what but…ok, the ad does say Ubuntucore ready – but the name says “NanoPi” – and surely to qualify as a Pi you should be supporting the main operating system of the Pi – that being… Debian.

Interestingly their M1 product DOES support Debian – which is strange.  But here’s the problem – though WiringOp just happens to work for GPIO on both the M1 and the NEO, and compiled WiringOp programs can be made to work as user Pi,  as the company’s Matrix software which DOES give you access to I2c etc. seems to have some issues with any other than ROOT access – and FriendlyArm do not currently know how to get around that.

So the ONLY  the way forward here to make full use of these boards, is for someone brighter than me to work on WiringOP to make it completely compatible with the NEO and hopefully the M1 – at that point – we’re onto a real winner but it would be so much better – when someone brings out hardware products like this – which rely SO heavily on documentation and software – if they would get it right themselves!!!  The manual for the Matrix software is even now in Chinese only!


Midweek Ramblings

Following my addition of the BME280 code to Home Control 2016, a couple of guys have suggested they might like to see more accuracy than the integer I use for temperature so I’ve added a new polled value {hightemperature} which is simply the temperature value *10 – but with that extra accuracy – so for example hightemperature mod 10 would give you the decimal point. Not sure I see a need for even higher precision so we’ll leave it at that – personally I just use temperature to the nearest degree.


I’m also playing as you know with port expanders and having already ran out of ports I’ve added an experimental additional 8 port outputs via one of those cheap port expanders I referred to in a previous blog entry.  So assuming this is set to address 38 (typically that’s switch 3 set to off, the others set to on) you can do simply control of out17 to 24, bearing in mind these things start off as inputs floating high.

Port expander

I’ve not attempted at this point to store values in FLASH or preset them on power up – let’s see how much use this gets.

See the Home Control 2016 manual for updates.

On a different tack, this might seem obvious to the hardware guys here and it should have been obvious to me as I’ve been working with electronic hardware since I was old enough to think –  but I made the mistake of getting lazy recently – on my new pergola. I set up on of our boards with a cheap Chinese relay board on GPIO12 – to control a water mister (it gets hot here).  So I would use the timed outputs for example {out12:6,2] which sets output 12 on for 2 minutes before timing out back to OFF state.

I had the water fittings all set to go, got my Imperihome App out, pressed the button and sure enough – excellent misting. I pressed the button to turn the mist off and…. nothing.

I figured a jammed relay – but no. Out of desperation I checked the actual state of the port as set in memory – and it said the output was on – but I’d turned it off – this was impossible. I sat and went through the code over and over – no issues.

I made the classic mistake of assuming the hardware was perfect and it had to be a software issue. In FACT, even though the misting system was kind of isolated from the board by the little external relay board, said relay was powering a 12v washing machine coil – and as it turns out the backlash from the coil was having the weirdest effect on the board – stopping that port turning off – to this day I still can’t explain it as it was actually affecting storage of info in the chip.  I can only assume a voltage spike getting back to the board itself.


I know, sounds daft, so I put a diode across the washing machine solenoid – something I should have done in the first place. Immediately – 100% perfect operation tested over and over. Worth knowing about. See purple diode below.

diode to stop interference

Also added {reset_config} command so that from serial you can reset the board to defaults  – for security this will not work from MQTT.


BME280 Box of Tricks

bme280I’ve just wasted more time than I care to think, trying to get a BME280 driver to work – finally done it by adapting some work from this fellow (Cosmin Plasoianu) who’s code is good but was out of date for the current SDK and also referred to another chip as so many bits of code do – the BMP280.

So what’s the difference? Well, the BMP280 is a modern temperature and pressure chip – but it does NOT do what the BME280 does – and that is humidity. In other words it can form a replacement for the DHT22 as long as you don’t mind using another wire (i2c). It responds quickly and is relatively accurate. The BME280 is also on a different I2c address to the BMP280.  Anyway – all SORTED.

It is not cheap at nearly £4 but adding in pressure lets you do all sorts of weather-predicting stuff!  As usual I limit accuracy to the nearest degrees C or percentage humidity because while seeing decimal points looks good  – the ultimate accuracy does not warrant it.

I’ve updated the manual {temp_type:3}  – and this uses i2c. The new command assuming GPIO4 and 5 are used for I2c and assuming there are pull-ups in use  – this  fills in the variables temperature, pressure and humidity which can be accessed as {temperature?} {pressure} and {humidity} as normal and are also generated automatically – see manual.

One more success for Home Control 2016.



Arduino Libraries and ESP8266

DallasSo I’m working on a side project – which may or may not go anywhere – to make a working version of my home control 2016 ESP8266 software in the Arduino environment. 

One popular device is the Dallas DS18b20 temperature sensor, a simple 3 wire device that looks like a transistor, has a single communications line and returns accurate temperature digitally.

Well, I’ve had this running for AGES on my code and can handle both the normal and P-suffix variety – so I was a bit dismayed after wasting an hour and throwing a chip away to find that the Arduino version does not.  Also it seems people are still writing libraries out there which wait for the chip – wasting valuable time – so I thought I’d do a short write-up on my own code.

Another annoyance I discovered was the need to predefine which GPIO pin you’re using for the temperature sensor – making dynamic change impossible. There really is no need for this.

So – how do I get around the delay – simple – I swap things around – instead of priming the unit, waiting and taking a reading, I take a reading and prime the unit – making the first ever reading after power-up a waste of time – and I use a flag to return zero the first time. This means no waiting and hence VERY fast reading. I also check the result and if the DS18b20 fails I try for a DS18b20P.

In my own code I use EASYGPIO which isn’t available on the Arduino version – which means (as I understand it) putting the GPIO pin from output to input means two operations, one to reverse the state of the pin and another to set the output value – but hey, it works.

No libraries needed of any kind though if you were cleverer than I you could dump my routines into a library. Of course nothing is new and some of my code is simply refactored from elsewhere as you’ll see.

Firstly – I’m not going for accuracy here, I’m only interested in temperature to the nearest degree – if you want more you’ll have to make minor changes. I’m also not interested in multiple devices per pin. I am however interested in changing pins without static declarations. Funny enough this all started for the Arduino, got adapted for ESP8266 and ended up back in an ESP8266/Arduino setup.

   Adaptation of Paul Stoffregen’s One wire library to the ESP8266 and
   Necromant’s Frankenstein firmware by Erland Lewin <>

   Paul’s original library site:

   See also

   Stripped down to bare minimum by Peter Scargill for single DS18B20 or DS18B20P integer read

// Perform the onewire reset function.  We will wait up to 250uS for
// the bus to come high, if it doesn’t then it is broken or shorted
// and we return;

void ds_reset(void)
  uint8_t retries = 125;

  pinMode(temperaturePort, INPUT_PULLUP);
  // wait until the wire is high… just in case
  do {
    if (–retries == 0) return;
  } while (!digitalRead(temperaturePort));
  pinMode(temperaturePort, OUTPUT);
  pinMode(temperaturePort, INPUT_PULLUP);

// Write a bit. Port and bit is used to cut lookup time and provide
// more certain timing.
static inline void write_bit(int v)
  pinMode(temperaturePort, OUTPUT);
  if (v) {
  else {

// Read a bit. Port and bit is used to cut lookup time and provide
// more certain timing.
static inline int read_bit(void)
  int r;
  pinMode(temperaturePort, OUTPUT);
  pinMode(temperaturePort, INPUT_PULLUP);
  r = digitalRead(temperaturePort);
  return r;

// Write a byte. The writing code uses the active drivers to raise the
// pin high, if you need power after the write (e.g. DS18S20 in
// parasite power mode) then set ‘power’ to 1, otherwise the pin will
// go tri-state at the end of the write to avoid heating in a short or
// other mishap.
void ds_write(uint8_t v, int power)
  uint8_t bitMask;

  for (bitMask = 0x01; bitMask; bitMask <<= 1) {
    write_bit((bitMask & v) ? 1 : 0);
  if (!power) {
    pinMode(temperaturePort, INPUT_PULLUP);
    pinMode(temperaturePort, OUTPUT);

// Read a byte
uint8_t ds_read()
  uint8_t bitMask;
  uint8_t r = 0;

  for (bitMask = 0x01; bitMask; bitMask <<= 1) {
    if (read_bit()) r |= bitMask;
  return r;

So what you see above are the basic routines for talking to the two  chip variations. Here’s the actual code I call once a minute (you could use any interval) to store the temperature. I don’t stop interrupts as I might be running an RGB fader and I don’t want any flashing.

Doesn’t seem to present issues, never has, but if you wanted you could average temperature over time.


I run my heating without any of that and I don’t get glitches on my Home Control software – this is the same code but with changes for the Arduino-style port handling.  I wonder if I’m missing a single instruction to set an input to an output and make it zero at the same time?

   ds_write(0xcc, 1);
   ds_write(0xbe, 1);
   temperature = (int) ds_read();
   temperature = temperature + (int) ds_read() * 256;
   temperature /= 16;
   if (temperature > 100) temperature -= 4096;
   ds_write(0xcc, 1);
   ds_write(0x44, 1);
   if (gotDsReading == 0) { gotDsReading=1; temperature = 0; }    // ignore first reading
    Serial.printf(“Here’s your temperature %dc”,temperature);

It would be nice to see this in a stand-alone library somehow. temperaturePort is the number of the GPIO pin. I generally use 2 or 14 on the ESP and I don’t want them dedicated in case I want to use them for something else. Define gotDSReading and make it zero on power-up or change of pin. If the dummy value of zero is no good – change it.

Oh and in the process of putting this together I realised a slight silly in my main Home Control software – and that is now fixed….

Works for me!!


Adafruit GFX

I’m hoping someone can save me a learning curve here.  I’m messing with the Adafruit GFX library here with a view to making a subset of my normal MQTT-based code supporting the little 160*128 LCD displays. All of this is working – I can put text up directly from an MQTT message – no problem.

But I’m having trouble getting my head around the GFX fonts.

Firstly – there seems to be a source code command line tool for generating fonts – and I need an LCD-type font… but I cannot find a precompiled version of the tool or similar for Windows and reference to Windows is so vague in the GFX info I’m not sure I want to go experimenting. Has anyone successfully made fonts in Windows for this library?

Secondly font height. The cursor positioning is based on pixels – and it seems that if you want to go to line X of text you have to guess how many pixels you need to use as a multiplier – that can’t be right surely?  There is a function for figuring out the XY bounds of a string so you can use a block erase before writing but that too is in pixels and assumes you know the height of the font. Surely there must be a function somewhere that simply returns the height of the current font?



More Home Control 2016 Updates

As of version 1.5.61 of the Home Control 2016 code,  I’ve now expanded the {debug} command considerably, added new Hitachi display commands and introduced a new MQTT topic called “otacomplete”. Here incidentally is the Bitbucket repository for all of this.

The Hitachi commands are documented in the manual.  As for the new MQTT topic, this is so that, should you choose to OTA update a unit remotely, you have some means to know asap that it is working.  In the event of an OTA update, the unit will send out the following MQTT message:

topic : otacomplete
payload: [the ID of the unit]

Typical serial on-demand debug output at the time of writing – for a test unit with ID “freddy” – with passwords changed to protect the innocent:

Time: 09:07:05 11/08/2016
Time Code: 1470906425
Dusk: 21:08 Dawn: 07:22
On1: 08:00 Off1: 12:00 On2: 15:00 Off2: 23:00 Peak: 23c Off-peak: 19c Frost: 14c
IP: 192:168:1:25
Internal ID: ARPS_00A68508
ID: freddy
DESC: empty
SSID: wififorus (Active)  Pass: xxxxxxxx
SSID2: wififorus  Pass2: xxxxxxxxx
MQTT Host: Port: 1883 User: admin
OTA Host:  Port: 80
Code Version: 1.5.61
SDK Version: 2.0.0(656edbf)
RSSI: -48
Out0: 0
Out4: 0
Out5: 1
Out12: 0
Out15: 0
Out16: 0
Sensor Type: DHT22
Temperature Port: GPIO2
GPIO13 available for general use: No
GPIO2 is an input
Sonoff setting=0
WiFi button=2
Invert settings=HEX( 1)
Serial2 settings=0
RGB Indicator=1
No LED clock
CPU frequency: 80Mhz
Free Heap: 16680 bytes
Up Time: 0:05:04