Archive for the MQTT Category


Posted in Arduino, IOT, MQTT, Networking, Wifi on July 20, 2017 by asteriondaedalus

So, following up after a previous promise I got myself a cheap arduino touch screen that was on sale, to act as a Programmable Entry Panel or PEP.

I will use the Wemos D1 and the Arduino core fore same to try to port the associated library onto Wemos D1. That way I can have a control panel via MQTT.

Yes, there wiĺl be a Android version as my wife got herself a Samsung – though so hates it.

Saves me the hassle of working in iOS.

And now for emqttd …

Posted in Linux, MQTT, Orange Pi on July 8, 2017 by asteriondaedalus

… again.

So, we buzzed out how to install emqttd on a OPiZ that was fragged by insertion of an expansion board so it, for some crazy reason, would not boot from debian server distro but would, but with clapped out device behaviour, using debian server distro.

Now we are back, with a new OPiZ board, no I said NO expansion board, and we have gone back to debian server distro.

So, some subtleties between the two distros. distro must have had build tools installed as git and make were already on board.  The other quirk is wget on orangepi will report unknown certificates when using wget.   That aside, we are up againt and the distro seems happy as long as expansion board has never been inserted into the main board.

So for emqttd you will need git and build-essentials so please install with:

  1. apt-get git build-essentials

Now we need erlang:

  1. wget
  2. dpkg -i erlang-solutions_1.0_all.deb
  3. rm erlang-solutions_1.0_all.deb
  4. apt-get update
  5. apt-get install erlang erlang-dev

Now previously we have had elixir on the end of line 6 but the emqttd build (to follow) is a bad citizen and builds elixir again over the top so no point cluttering the system.

Now we go downhill again.

So, I downloaded emqttd with:

git clone
cd emq-relx && make

But, when I ran make I started getting those rotten messages that hinted that the ethernet was down – couldn’t resolve inet addresses.

I ran route and I seemed to have a connection.  I did, however, loose connection from the browser to the red-node despite pm2 show telling me node-red was running??

When I took a peek at my wifi extender settings the OPiZ IP was no longer reported.

I rebooted, node-red was there again, route seemed to show things were fine BUT my wifi extender settings were still not showing the OPiZ IP.

git was flaky too.  I started getting certificate errors??  The error was:

server certificate verification failed. 
CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none

So, there are ways to fix this but not any explanations of what caused it.  This is a fresh distro, with a fresh install of git, so I haven’t played around with config.

There was some chatter about certificates being time sensitive so problems with NTP??

So I am wondering if this is what I have seen with git before, not southern hemisphere friendly – after all here I am after midnight.

I did do something naughty.

I found you could turn certificates off for git.

So I did, emqttd then did start but clapped out not long after.

Each time “can’t resolve host github”

I pinged successfully so I know that I am on the net.  I can’t, as usual, connect to github.

So, I was at a loss.

Given my background in embedded systems and testing I had to do what I normally did.

That is, nothing was too silly.

Go figure, I had been bugged by a difference between the previous fiddling and now that was really subliminal.

I had come across a syntactic sugar for netmask, for example a netmask of would crop up at the end of your host IP as /24 but for some reason the netmask set by nmtui when using distro was /32.

Now I am not saying that that was what the problem was but changing the /32 to /24 in the static IP seems to have sorted the “missing” IP address of the OPiZ on my extender config window.


Nope, the following morning I am not seeing the OPiZ on the networking but it is happily connected to the internet???  Although, I am still having problems with host resolution of github and having to run make multiple times.


It hasn’t helped with the github “missing” but re-running make, as it did last time, seems to muddle through – which again suggests a problem with the load on the github servers dropping connections.

It doesn’t seem to happen here in the day time.


Posted in Armbian, MQTT, node-red, Orange Pi on June 28, 2017 by asteriondaedalus

Given my journey here, to have node-red and emqttd running as services on Orange Pi Zero, I have to say the finale was not unexpected.

Re-burnt SD with Etcher as people were convinced I had caused problems with FS corruption using WIN32DiskImager.

Built node-red and emqttd as services (again).

I then started the Orange Pi Zero and left it running for two days.

I went to open on node-red in my browser this morning.

No connection.

Same for emqttd.

They were running last night.

The COM port to the OPiZ is still up as it shows up on the TerraTerm drop down.

I start up a console but not a sausage.

It should drop straight through to the root prompt for password.

For the halibut I tried sshing in via its static IP.


What The Frack Over?

And, pulling power then reapplying sees the board not come up without IP address – but with node-red and emqttd running.

no connection

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*.


I just notice the windoze drive letter on Etcher.  You have to swipe your mouse over a tiny group of pixels accidently for a hovering text to show up.

Once I saw that I did go back to the drive selection to find a very light gray “j” over a dirty white background in contravention I suspect of accessibility laws – if not plain old simply human factors and HCI design rules.  I am 50+ and have glasses (often smudged) so what can I say … I easily miss things.


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!



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


Woof woof woof

Posted in Arduino, MQTT, Sensing on June 18, 2017 by asteriondaedalus

A neighbor complained that the dogs were barking all day.

Likely cause all the renovation work going on (late into the night as well).

I looked around for software so I could detect the barking and potentially turn sprinklers on for a minute – to distract them.

Options are also a buzzer, so they associate the buzzer with the sprinkler coming on.  Then later the sprinkler needn’t come on.

HE is funny.  Not liking to wet he has an aversion to the solar powered, IR triggered, sprinkler I use to at least keep them away from the side of the house.

The psychology is funny though, they stop short of going down the side of the house and bark anyway.

Much of the software is really noddy.  Level sensing.  So I looked for microphones and downloaded python scripts etc.  The software would also send you an email if the dogs barked.

Still, the problem running on the PC was obvious.  The problems setting up a microphone on a C.H.I.P. or Orange Pi were not insurmountable BUT still was that over kill.

My time in signal processing get get me excited about using correlations to discern dogs barking from loud noises but there are other tricks there.  The load noise would be of a fixed duration that repeated.  So, a window with say four loud noises could count as barking in a backyard otherwise quiet.

The thought of the signal processing didn’t daunt me, but the turn around time to get something running did.  So, the plan is a super duper system later, at the moment I just want to monitor their behaviour and sort something out that might curb it.

So I thought I would go with a arduino compatible microphone/sound sensor instead.  An ESP-01 would do it as the sensor has a tuneable level sensor and raises as signal if the level is at or over that set.

However, it also puts out an analogue signal, from the mic, so a WeMOS mini would be better since it has the ADC input.


The sound sensor takes 5v, as does one of the pins on the D1 mini.    This way I can pump out noise events by the level sensor early using mqtt.   And later, I can pump analogue samples out by wifi.

I am already using node-red to send emails from the OPiZ so I can pump out hourly “woof” stats.   This setup is also cheap enough to set a couple up so that different parts of the yard (and thereby irrigation sectors) can play their part.

I have a suspicion neighbors are not helping and banging the fence.  So I am looking for a vibration sensor to get stats on that as well.

Close but no bananna

Posted in MQTT, Orange Pi, Rant, The downside of Opensource on June 14, 2017 by asteriondaedalus

So here is where I got to getting emqttd to start as a service on Armbian Debian server running on OPiZ:

Jun 14 08:29:42 house systemd[1]: Starting SYSV: emqttd is mqtt broker....
-- Subject: Unit emqttd.service has begun with start-up
-- Defined-By: systemd
-- Support:
-- Unit emqttd.service has begun starting up.
Jun 14 08:29:42 house emqttd[1282]: /etc/init.d/emqttd: 1: /etc/rc.d/init.d/func
Jun 14 08:29:42 house emqttd[1282]: starting emqttd...
Jun 14 08:29:43 house run_erl[1321]: Erlang closed the connection.
Jun 14 08:29:58 house systemd[1]: emqttd.service: control process exited, code=e
Jun 14 08:29:58 house systemd[1]: Failed to start SYSV: emqttd is mqtt broker..
-- Subject: Unit emqttd.service has failed
-- Defined-By: systemd
-- Support:
-- Unit emqttd.service has failed.
-- The result is failed.
Jun 14 08:29:58 house systemd[1]: Unit emqttd.service entered failed state.

So, to get here first you need the instruction for setting emqttd as a service at emqttd site.

The script line “. /etc/rc.d/init.d/functions” (within /etc/init.d/emqttd) will try to source a file you don’t have in your Armbian debian server distro for OPiZ.  It appears a standard file so I used mkdir to create the /etc/rc.d/init.d directory and downloaded a copy of functions.  This may or may not be the source of any knock on problems I am currently having.

In any event.

What the emqttd build does not do is move the binary to /opt directory for you, and there are no words to direct you to do this in the emqttd help, so the help file either expects you “know” (how we hate priori knowledge yes) that was their install solution OR the build clapped out and didn’t move the files or install properly – and did not report same.

So, you will need to copy the files (built into _rel directory) into /opt with (from your emq-rex directory):

mkdir /opt/emqttd
cp -r _rel/emqttd/* to /opt/emqttd

To get the error above just type in:

service emqttd start

Note, I also tried the service installation for node-red to no avail.  It appears to hook into services via a slightly different route (who would have thought).  But, alas, the following line ends quietly with no error report.

systemctl start nodered.service

But, browser does not connect to anything.  Rebooting has no effect.  The following provides the obituary:

systemctl status nodered.service