Mosquitto on Raspberry Pi 2

mqttWell, that took some doing.  I now have Mosquitto running on the Raspberry Pi 2. 

This is the link I followed for the install..

I simply installed the respository then Mosquitto itself, nothing more.

This installation put a non-personalised config file at /etc/mosquitto – so in there was pointed to the directory /etc/mosquitto/conf.d  - so I put my mosquitto.conf in there which was basically 2 lines…

allow_anonymous false
password_file /etc/mosquitto/conf.d/passwords.txt

I’ve not yet put SSL in there but I certainly wasn’t going to start up the broker with NO security.  I added a simple text file passwords.txt as above with a one-liner admin (colon) password where the password is encrypted using the Mosquitto password program for the PC (thankfully I already had a passwords file).

And that’s it really, stop the broker and restart it to make sure it takes notice of the config file..

sudo /etc/init.d/mosquitto stop

sudo /etc/init.d/mosquitto start

And talk to it via something like MQTT SPY – subscribe to any old topic (“testing”, in my case) and try publishing to that topic. I’ve tested powering down and back up and all is well.

Easiest thing I’ve done all day.. oh, NO it wasn’t – I could not write to the etc/mosquitto/conf.d directory  - the usual Linux security issues….  I did this.. most likely giving FAR too much access (if anyone wants to tell me what it SHOULD be, please do but don’t let’s get complicated)…

sudo chmod 777 ./conf.d


and from there on I could use my FTP described earlier and Notepad++ to create and edit the necessary files.


Raspberry Pi 2 VNC Error Message Solved

UltraVNCToday is getting better by the minute. I’ve been plagued with my new Raspberry Pi 2with a harmless but annoying message when remotely accessing it from my PC with UltraVNC.

A box would pop up with

GDIBUS freedesktop.PolicyKit1 Error.Failed:; An Authentication agent already exists for the given subject.


Well, to cut a long story short, even the Raspberry Pi group had no answer for this as many of the proposed solutions needed menus that do not exist on the Pi. until I stumbled upon this link – solved the problem completely.

While I’m on – I’ve been reading about editors for the Pi… the one that comes with the 2 (nano) is like a step back into the last century. I downloaded something called Joe and that looks quite fine – but then when playing with a toy that someone else put me onto on my PC – that is WinSCP – which I’m now using in preference to my normal FTP client – I happened to notice an EDIT function for files on the other side of the wire – i.e. on the Pi itself. Well, it works, appears a little like Notepad, transparently downloads the file and opens for edit and when you save – sends it back. I tried some simple Python files and they worked a treat. THEN I realised I could customise the editor in winSCP – so I told it about my favourite PC editor, NotePad++ which i have heavily customised and themed. Well, it just works. So now I can editor Pi Python and other files in my normal comfortable environment.

Where there’s a will, there’s a way as loads of people probably say.


Raspberry Pi Permissions

As you’ll note elsewhere in the blog, I’ve been playing with WordPress (PHP/MYSQL etc) on the new Pi 2 – an hitting problems with permissions. Typical of a Windows users (I’m quite happy in CPANEL) the Linux commands mean very little to me and there’s enough to learn without taking on extra, so when my FILEZILLA connection to the Pi 2 failed to let me change or understand permissions, reader Simon pointed me here.

Not only did this program inherit my FILEZILLA settings but the properties of a directory or file let me use familar tick-box settings to update the permissions – with the result, another issue with WordPress, uploading images to the Pi, is now history. Well worth investigating that simple and quick program.

Now I just need to find out why comments in the WordPress installation are disabled. Must be a reason…

Next job, find out what’s involved in making copies of the SD card on the PC so I can experiment with wild abandon safe in the knowledge that it is impossible to break anything.

Meanwhile my friend is knocking up a little test board for the ESPs using a Tiny85 to handle the reset line for programming just like an Arduino – more on that later.


More Pi Mysteries

Well, I thought I had the CRON thing cracked.  I made my cron file….. with this inside it..

And sure enough – CRON runs the PHP page which publishes a couple of topics every minute as it should do, to my MOSQUITTO broker sited elsewhere, exactly as it should do and as does the same PHP page has been doing for weeks on another system.

GREAT… except that every minute it also generates an empty file in /home/pi directory


I am happy to admit… I do not have the foggiest idea why the Raspberry Pi 2 would do this – in fact I have no idea how that PHP page and the home/pi directory are even aware of each other. Any ideas guys?


Raspberry Pi 2 startup

I’m using the Raspberry Pi 2 (note the 2 – i.e. the new one) – which up to now I’m quite happy with – still got a little way to go but I have this annoying message in the Raspbian desktop when it comes up (on powerup).


Can anyone tell me how to get rid of it. It’s not doing any harm, it’s not stopping anything working but it’s driving me nuts.

Please keep it simple, I’m a Windows man.


Bringing the Pi into the PC world

So you have your sparkly new Raspberry Pi and the first thing you need to do is remotely access it from the PC… and so you install TIGHTVNC… and put that on the PC and they talk to each other and…. no clipboard…

This link got me out of a jam. Now I can use either TightVNC or UltraVNC on my Windows PC, talk to the Pi and copy and paste.. Indeed thanks to ”Input Director” on the PC, I can copy and paste between a number of PCs and the Pi. Now that’s civilised.

If only I could get Filezilla on the PC to let me change FTP permissions on the Pi that would be even more civilised.



Boy am I in it over my head (for now). my new Raspberry Pi turned up – very nice – formatted a 32Gig microSD, loaded Raspbian and after a couple of false starts I soon had a working (graphical worktop) operating system.  I added FTP, VNC (so I don’t have to tie up a monitor, keyboard and mouse) and PHP,  I managed to get my PHP MQTT page to run and send messages to the MQTT Broker.

So this works.

No problem.

I THOUGHT I was having trouble getting a CRON job to work (timed running of the page) – but it turns out it’s worse than that..   I’ve been trying “PHP” then the location of the page… and I’ve realise that won’t work – so in a terminal..

php  /var/www/mqtt/examples/publish.php  - the page runs but relative paths in the page are wrong… surely there is a way to run a page like that as if it was running in a browser (clearly without any client side stuff).

So in the CRON page I had

* * * * * php /var/www/mqtt/examples/publish.php

and NOTHING was happening…  and of course now I know at least one reason. I’m assuming the other reason will be something to do with permissions…

So can anyone familiar with the PI point me in the right direction.. how do I get a CRON job to run the page with internal relative links working as if it was being run from a browser.

And if we get that far, am I going to hit permissions issues. I used sudo crontab –e to edit a simple text file with the above line in it and saved it in /etc/cron.d

All of which is probably wrong.

Incidentally don’t try installing THINGBOX on the Pi2 – it won’t work and they don’t have a way around it yet. In my case it would not even start up.

Solution: Although no-one had a single solution I got enough out of all you helpful people to resolve this and more.

So firstly, it's not /usr/local/bin that PHP resides it's /usr/bin and you can use any old editor to edit any old file name in /etc/cron.d to do the job.

Given my hatred of command lines I found the command line editor to be ATTROCIOUS but.. LeafEdit in the desktop is great (well ok, it's not NOTEPAD++ is it) - it's only failing is it's not running as root. Now there might be an easier way but I went into the terminal and ran "sudo leafedit" and up popped the graphical editor with all the permissions I needed - I updated my file calld cron to include the path for php, saved it and then ran "crontab cron" - no idea what that does - but next thing I knew, my PHP messages were appearing in Mosquitto (being monitored by mqtt-spy on the PC) no problem.

I rebooted the PI - no problem - it all came up roses and no modifications to the original PHP file at all. That's what I call A RESULT.



DS18b20 and MQTT Graphs

As a background job, some of you will know I’ve been looking at averaging temperature readings as there can be a little variation when reading the DS18b20 for a variety of reasons, though nothing like the horrors I saw when using ESP201. On the ESP-10 with a 12” lead I’m getting quite steady readings as you’ll see in this graph. The massive dip to –17c is down to me using the freezer spray on the chip head (well, you have to test these things).


So there we have it… a constant 19c in my office until I hit the chip with the freezer spray (readings every 5 seconds) and an instant drop to –17c followed by the slow climb up back to 19c.

I’m also taking an average reading…

os_sprintf(tBuf, "%d", (int)(temperature_average+0.5));


and that produces this output


It doesn’t actually look any better but of course it’s only dropping down to 8c. Clearly however I need to do a much better job of smoothing than this – averaging 8 readings is clearly not enough – perhaps a better way that can ignore really rapid changes altogether…  let’s face it – opening the door isn’t going to cause a drop in temperature even remotely like that! However, the smoothing process does work and thanks to others for the suggestion.

And how am I producing these graphs? With MQTT-SPY of course. This excellent program has been evolving a lot recently and I like to think the graphing feature was at least partly largely down to my gentle encouragement. What’s missing is the ability to zoom into the image to check out a particular area so a couple of days ago I wrote off to the author and pushed my luck by asking him for such a feature.

In this morning’s mailbox I received a reply and…so NOW we can zoom in and out using he mouse centre wheel and right button.

For those new to this program it’s a free JAVA program (just runs on my PC) which is excellent, you can publish MQTT messages, subscribe to others and now graph the results of incoming data all without any great new learning curve. You can even run automated scripts if you want to send messages out… Rather handy for generating time messages (there’s an example in the WIFI I believe) and you can control what happens if the connection fails etc. MQTT-SPY is also fast and responsive, not at all what I expected from a Java program.

no points graph

This just keeps getting better and better. Head on over here to get the .JAR file. I put mine in /users/peter/mqtt-spy to hold it all together as it generates log files and more.  All you need is the one file – no big installation. Excellent. If you find it really useful the author suggests a donation to UNICEF.

Important – read the OVERVIEW wiki before griping about zooming control – it’s all in there.


ESP201 Performance

Maybe it’s just me..  I’ve been messing with the DS18B20 and the ESP-01 and on advice from a respondent in here wrote a quick averaging function and have been monitoring that all morning – lovely. No connection issues, nothing.

So this afternoon I took my little ESP-01 development board (which has pullups, 3v3 regulator and more) and extended leads (maybe 4” to an ESP201 board – I did this because I wanted access to the ADC which of course is not available on the ESP-01.

I pulled GPIO15 low and the other pins of the ESP01 match to the relevant pins on the ESP201 (GPIO0, GPIO2, RESET, PD, GND, 3v3.

I grounded GPIO0 and programmed the chip – no problem. So in short all the pins that would have attached to the 01 are attached to the 201 and GPIOis grounded. Does this sound right?

What had been a perfectly functioning ESP01 program is now working on the ESP201 – and the ADC is working fine (around 1.1v for value 1024 – ie 10-bit ADC) – granted a degree of variation!

BUT I’m getting more variation on the temperature than I’d expect – but FAR more importantly the WIFI range is ATTROCIOUS. Looking at 3v3 line with scope, no more noise than on the 01.

Any thoughts?


Temperature variations

How useful is this MQTT-SPY turning out to be – I had no idea I had such temperature variations from my DS18B20 – ok it looks worse than it is due to the limited range of the graph but I really do need to do some averaging!! This is just 1,147 readings at 5 second intervals. No way I would have spotted this without this easy to use (and free) software… now I sound like an advert.


graphing MQTT SPY


Onion Omega

You (probably) saw it here first…  I thought I’d seen it all in the ESP8266 but this is looking impressive already. Yes, that IS a complete WIFI controller with Linux  and plenty of RAM in a matchbox. Early days, I should have one to test in a matter of weeks so be sure to look in here… I’ll likely do a short video on the subject. And yes as best I can tell that is also 0.1” pin centres. With an extension it also handles wired Internet though by the time you start putting extra bits on my guess is it would be competing with the new Raspberry Pi. On it’s own however I think this one might just have wings! More when I get my hands on some hardware.

Onion Omega