Setup for home automation server

Posted in Linux, MQTT, node-red, Orange Pi on June 25, 2017 by asteriondaedalus

So, setup for house server on Orange Pi Zero 512kB using:


Ignore my previous posts where I use WIN32DiskImager.  Seems it has fallen out of favour (and might be the root of all the other problems I was seeing??!!).

Use Etcher as directed on the site, as well as a good quality Class 10 SD card.

On Windows you will get a fright because dopey Etcher does not nominate your SD card as a drive number (J: for example on my PC) – heaven forbid.   So it takes a while to work out it is happily point ONLY at your SD card.

Given all the warnings about using WIN32DiskImager (and trashing your computer) it was a bit arrgh! of the authors of Etcher.   I think they are trying to be hip *yawn*.

Login into distro for first time and set up root and user accounts.

Setup static IP for your Orange Pi Zero using nmtui or nmcli (for power users).

Reboot and  then run:

apt-get update

Grab binaries for nodejs and install them:

tar -xf node-v6.10.3-linux-armv7l.tar.xz --directory /usr/local \
      --strip-components 1

Check install with:

node -v
npm -v

Use npm to install node-red with:

npm cache clean
npm install -g --unsafe-perm node-red

Test node-red out with:


Then go to your OPiZ static IP with your browser on another computer in your network.

1880 node-red Port

Next we are going to setup PM2 so as to start node-red as a service on boot:

npm install -g pm2
whereis node-red
node-red: /usr/local/bin/node-red
pm2 start /usr/local/bin/node-red \
      --node-args="--max-old-space-size=128" -- -v
pm2 save
pm2 startup
export PM2_HOME="/root/.pm2" # because I installed in root 
reboot #takes a while after rebooting but it should come up

Then go to your OPiZ static IP with your browser on another computer in your network – you should see node-red running.  Be brave, close the browser tab and re-open it, or refresh it.

Now let’s add erlang with:

wget &&
dpkg -i erlang-solutions_1.0_all.deb &&
rm erlang-solutions_1.0_all.deb


apt-get update && sudo apt-get install erlang erlang-dev elixir

Note you can leave elixir at the end of the previous command but emqttd following will rebuild elixir blindly over the top – bad citizen!

Now fetch and build emqttd:

git clone
cd emq-relx && make

Try out emqttd with:

cd _rel/emqttd && ./bin/emqttd console


18083 MQTT dashboard port

Go to your OPiZ static IP with your browser on another computer in your network – you should see node-red AND emqttd running.

Now let’s set up emqttd to start on boot:

cp -R emq-relx/_rel /opt/emqtt/
mkdir /usr/lib/systemd/system
nano /usr/lib/systemd/system/emqttd.service

---- inside of nano ----

Description=emqtt daemon

ExecStart=/bin/sh /opt/emqttd/bin/emqttd start
ExecStop=/bin/sh /opt/emqttd/bin/emqttd stop


---- exit and save from nano ----

chmod +x /usr/lib/systemd/system/emqttd.service
systemctl enable emqttd.service

I copy the whole _rel directory over to /opt because I tried moving only the bin directory BUT when I tried running it came up with an error.

Go to your OPiZ static IP with your browser on another computer in your network – you should see node-red AND emqttd running without having to login!



Ah, the thick plottens!

Posted in Linux, Networking on June 24, 2017 by asteriondaedalus

So, even with the static IP set on the parallella the TerraTerm console keeps disconnecting after a time.

Then it dawned on me, the connection was being broken because the PC IP would expire and pick up another from the DHCP in the router.

So, the unwritten story is that you need to set the IP address of your working PC to static as well – so that IP addresses at both ends of the connection persist.

Now that I have set my PC to static IP, TerraTerm does not close down.

It’s all a matter of timing

Posted in Chapel, Elixir, Erlang, FORTH is it dead or isn't it?, Parallella on June 24, 2017 by asteriondaedalus

So, phew!

I re-bombed parabuntu onto the SD card.

What the problem was earlier was the security key had changed but I was forgetting to say YES to option for saving the new key (I had quite a lot of red wine last night so don’t be so hard on me 😉 )

When I powered up the Parallella again, I wasted no time and jumped in with:

sudo nano /etc/network/interfaces.d/eth0

---- inside of nano ---

auto eth0
iface eth0 inet static
address // your parallella IP here
netmask // your netmask here
gateway // your gateway address here
dns-nameservers x.x.x.x //your dns server list here

--- exit and save ---

sudo reboot

Happily now running on the static IP set … phew!

Now to work.

Target environments will be erlang/elixir and chapel.  Yet, ePython for poking around.

I am reading back into my threaded interpretive days to look at a minimal FORTH runtime to run on the Epiphany.  There has been chatter on the parallella groups about J1, but that is a HDL (read FPGA) FORTH.  I think many people chattering haven’t worked in FORTH so much of the chatter is unproductive.  I am thinking a GForth running on the ARM side that assembles, rather than cross compiles, to a hand built threaded interpreter on the matrix.  I am not sure how feasible that all is but it will be  a good instrument for learning the nuts’n’bolts of Epiphany.

Many lessons can come from the struggle, yes?

This, idea is no more or less I worked on during a project, in Canada, where I noted the DSP software the team was using was already using a threaded processing chain.  The idea then of control loops and conditional inside of that was a soft sell.

So, in FORTHeze no outer interpreter running on the Epiphany.


Why …

Posted in Parabuntu, Parallella on June 24, 2017 by asteriondaedalus

… am I torturing myself?

So, yes here we go again.

I found that the interfaces file for parabuntu sources connections from interfaces.d so the files to edit sit in that directory.

Go figure though, have way through editing eth0 file the TerraTerm console closes – that is, blinks out of existence on my PC screen and out of my task bar.

I checked the wifi extender and the IP address I had already established was the one the DHCP had provided to the Parallella.  It was still there.  For some reason though, despite having already logged in, re-logging via TerraTerm prompted with an unknown security key to be added to the list, and when it logged in I was presented with a black screen, no prompt, and no reaction to control keys!  I assumed that I might have come back up in middle of nano at least.

So, I am now re-bombing SD card.

Try, try …

Posted in Orange Pi, Parabuntu, Parallella on June 22, 2017 by asteriondaedalus

So, I am scratching the OPiZ SD and starting again to see if that recovers the issue around the system no longer booting up with ethernet.

Straightforward enough.  I used SDFormatter to reformat the SD card.  I am just rebombing with the arbian distro.

Logging in via USB.

I will jump straight in with nmcli as the problem manifests as no IP, Gateway or DNS and nmcli failing to save the configuration.


Tried logging into the fresh distro – got a “Authentication token manipulation error” when responding to prompt for new root password?!

I pulled power to try again.  Same problem, so I will rebomb SD card.


Still the same problem!  Is the card fragged?  I will bomb a new SD card (with trepidation).  But, maybe the card was fragged by the expansion board and not the motherboard?  Might explain the problems with software: nmtui hanging, nmcli eventually not saving, loss of ethernet configuration.


Same problem with new SD card?  Is my distro corrupt?

I re-downloaded the distro and burnt that new copy of the distro to the new SD card.

Getting a flashing red led next to the green one.

Of course, there is a hint on the net that OPi are generally super sensitive to SD quality, you need at least a Class 10!  I have a SanDisk Ultra microSDHC UHS-1 Class 10 … check.

Since it is getting through the initial prompts, and doing so on two different SD cards, it is pretty telling that the board is fragged somehow.

Proof of pudding I took one of the SD that now won’t get past setting root password (on first boot of SD card) and happily bombed parabuntu onto it.

I did suspect the SD card for a moment.  I connected the Parallella to my gateway in the lounge room as I have a horrible nest of power cables in the back of my desk, up against the wall, which makes it soooooo undignified, when getting on all fours to plug something into the rarely available positions in the power boards.

The parallella powered up BUT I could not see an extra device on my gateway???  I tested the power adapter I bought (the ones with the various optional connectors) so I knew I had +5V on centre pin as required.

That’s right.

In the end I was on all fours.

Bumping my head.

Kelpie cross Staffy cross Ridgeback cum Chupacabra (aka Mexican Devil Zombi Dog), tail wagging at the speed of sound, jammed under the desk with me as my presence on the floor WAS obviously an invitation for her to play.

I digress.

The parallella turns up fine, with a DHCP IP address , when connected by ethernet cable  to the wireless extender sitting on my desk.

The fun fact?

Yep, I follow instructions to set up static IP on the parallella AND I then have to re-bomb the card to get dopey ethernet back again.   This one will be a pain since you cannot serial in easily.



Is this the last straw?

Posted in Linux, Orange Pi on June 21, 2017 by asteriondaedalus

So, now after a couple of weeks of dicking around trying to sort the booting of the OPiZ – so it starts up with node-red and emqttd, it works!

Or at least I can say the both services start up.

But, of course, this last couple of days I had trouble browsing into the node-red and now, in hindsight, it seems my OPiZ was occasionally not starting up connected to the ethernet.

After all the work to get around the fragging of the board, and working out the trick to using nmcli, the OPiZ would occasionally boot with no IP (static or otherwise), no gateway setup, no DNS?

It is now worse having put the board into the case.

The simple act of screwing it in and now system boots with no network at all.

So, fingers crossed – I will type in all the nmcli commands again.

Arrrrr … no.

If type all the data again and then use the “route -n” command I get naught – meaning:

root@house:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface


Finally, a new mqtt based node-red server

Posted in Linux, MQTT, Networking, node-red, Orange Pi on June 21, 2017 by asteriondaedalus

So, much pain but lotsa learning!

Final story.


If you are using:

  • OS: debian server: ARMBIAN 5.31 stable Debian GNU/Linux 8 (jessie) 3.4.113-sun8i
  • Erlang/OTP: V9.2/19
  • EMQ: 2.2
  • Orange Pi Zero 512kb (and fragged by expansion board 😉

Ignore the service definition at the emqttd site

DO NOT CREATE /etc/init.d/emqtt – because systemd is installed in ARMBIAN 5.31 and systemd uses UNIT files (as emqttd.service below).  The /etc/init.d/xxx file should be ignored if the UNIT file is there but why clutter and have junk around.

Then do the following (from root):

mkdir /opt/emqttd
mkdir /opt/emqttd/bin
cp -R emq-relx/_rel /opt/emqtt/
mkdir /usr/lib/systemd/system
nano /usr/lib/systemd/system/emqttd.service

---- inside of nano ----

Description=emqtt daemon

ExecStart=/bin/sh /opt/emqttd/bin/emqttd start
ExecStop=/bin/sh /opt/emqttd/bin/emqttd stop


---- exit and save from nano ----

chmod +x /usr/lib/systemd/system/emqttd.service
systemctl enable emqttd.service


Thanks awfully to @turtleDeng.

There is, of course, a new problem.  Both node-red and emqttd services start every time the OPiZ boots.  However, for some reason (tonight for the first time) connection to LAN is not coming up every time.  It comes up with no IP, no gateway, no DNS addresses???

Reboot a second time and it comes up.

This new problem means I will need check after brownout, or cycle power on ISP gateway (where the OPiZ will get its power … assuming there is 5volts on the USB port on the gateway).