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


Easy MQTT Graphing

I’m quite excited this morning, had an email from Kamil Baczkowicz – could I please try the latest beta of MQTT-SPY – I’ve been encouraging him to add graphing for the MQTT input as even Node-Red doesn’t do this out of the box.. sure enough he’s cracked it. Here’s a working example, I have my DS18b20 running so that it returns the temperature from my little ESP8266 board every 5 seconds. I got up this morning, loaded the new BETA of MQTT-SPY and…

graphing MQTT

Don’t ask me why my DS18B20 started varying by 2 degrees this morning (after being on all night) then settling at 20c – I have no idea what it’s playing at.

What more could you want (I know, lots). Simply right click the incoming stream and you have your graph with options to show everything up to the last 24 hours. I’m sure more is on the way. I just keep getting more impressed by the fast, simple package. It’s a .JAR file incidentally so whatever operating system you’re on you’ll need JAVA installed but that seems to be pretty universal except (and I’ve never figured out why) the mobile operating systems such as Android. If anyone figures out how to get this working on an Android tablet, you will be my best friend ever if you report back in here.


The BLANKER is there for why?

In the MQTT software for the ESP8266 (ESP-01 etc), specifically the MAKE file, there is this line..

$(PYTHON) $(ESPTOOL) -p $(ESPPORT) write_flash 0x00000 firmware/0x00000.bin 0x3C000 $(BLANKER) 0x40000 firmware/0x40000.bin

It's pretty obvious what it does, it blows the two BIN files you've just created. By what I don't understand is why it blows the blanker file at 0x3c000.

No really I'm not losing my marbles. In the MQTT package - in config.c and config.h you'll learn all about how defaults are stored in FLASH. Specifically 3c000, 3e000 and 3fooo are used to store non-volatile info and if a specific value is not found in the FLASH, then either sector 3c000 or 3e000 is firstly erased programmatically and then over-written - the purpose of using two is to ensure in the event of a failure you always have the previous version - so I cannot for the LIFE of me understand why there is a blanker file for 3c000 AND I can't understand why 3d000 is not used.

Thought anyone - if someone comes up with some good intel  on this I'm moving stuff around...

Peter Scargill