Monthly Archives: February 2015

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?

Facebooktwittergoogle_pluspinterestlinkedin

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

Facebooktwittergoogle_pluspinterestlinkedin

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

Facebooktwittergoogle_pluspinterestlinkedin

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.

Facebooktwittergoogle_pluspinterestlinkedin

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

Facebooktwittergoogle_pluspinterestlinkedin

Domoticz

Ideas anyone? Installed Domoticz just to see how well it might work… needs an add-on for MQTT here https://github.com/sschimmel/DomoticzMQTT  - grabbed that, put the files in nodejs\node_modules\domo and ran node server.js as per the recommendation.. and.. it threw an error “Cannot find module “mqtt”

Update September 2015: MQTT is now part of the Raspberry Pi image for Domitz - just note that you need to add MQTT as hardware by going to setup/hardware. Tested with MQTT spy.  You can grab a complete Raspberry Pi image – or do what I did which was to add it to the existing image. The instructions are here.

https://www.domoticz.com/wiki/Installing_and_running_Domoticz_on_a_Raspberry_PI

6 lines of setup including clean-up can’t be bad!

However when we tried to install Domoticz from the instructions on an existing system, everything worked but I put in the wrong port for MQTT. I then went to bed and the next morning the installation had crashed – hardly a good start for getting my confidence up.

To cut a long story short, a complete re-install seemed the best idea and this time everything worked. 

Things I control – lights – lots of them – and RGB lights –lots of those too.  Once you have everything setup you can simply add new lights and when you turn them on or off, an MQTT message is generated…. with a light ID and it’s status. And so it is with RGB… but for one issue  -there is no RGB status  - which begs the question – how on earth do you use Domoticz to control an RGB virtual light – via Node-Red. It would APPEAR that you cannot. I’ve looked at their forums – people are asking the same question and coming to the same conclusion.

And with that I’ll put this to one side until someone tells me I’ve missed the point – but I can assure you that the MQTT package coming out of Domoticz when you change the colour of a virtual RGB light – does NOT include the colour!

Facebooktwittergoogle_pluspinterestlinkedin

Landing on two Feet

feetSometimes I really do land on 2 feet.  So the ESP/MQTT rig now appears bulletproof and in a timely fashion the Raspberry Pi appears just in the nick of time. All I need is an easy to use Mosquitto/Node-Red setup and …. what should appear but a link to this … http://thethingbox.io/

I can see it’s going to be a busy weekend of discovery.

I was wondering how to make the thing programmable without having to blow the flash – and it hit me tonight… give the unit a default unit number to prefix any subscribes… and… use MQTT messages to rewrite the default unit number and any other info – and reboot!! Easy (well, of course, it won’t be).

That’s enough for one day.

Facebooktwittergoogle_pluspinterestlinkedin

ESP12 and More Pins

ESP-12I’m just about to have a go at one of the larger boards – the ESP12 (or 201)…   so can someone save me (and others) re-inventing the wheel.

Here’s what I do to initialise an ESP-01 port bit GPIO0 as an output.

Firstly the setup..

// For GPIO2 just change the 0 to 2 - there is one init line.
#define LED_GPIO 0
#define LED_GPIO_MUX PERIPHS_IO_MUX_GPIO0_U
#define LED_GPIO_FUNC FUNC_GPIO0

then initialisation

PIN_FUNC_SELECT(LED_GPIO_MUX, LED_GPIO_FUNC);

 

and here it is set to 1.

GPIO_OUTPUT_SET(LED_GPIO, OUT_ON);

 

As you can see, I’ve already figured out how to do the same with GPIO2 (though I’ve not used GPIO2 as an output yet)

So – what other pins can we use in exactly the same way and are the numbers as you would expect or different?? This general principle also seems to work for GPO4 and 5 but not for the higher numbers.

Facebooktwittergoogle_pluspinterestlinkedin

Rubbish plug-ins

Another rubbish spam plug-in - apologies to anyone who's been trying to comment this morning - I really do not understand some of the people that give stars to WordPress plug-ins. I used an anti-spam system that got high ratings - and it would not let people comment - when I went on the web, loads of people with blogs had the same issue. It's history now, I'll deal with spam by hand until I find something that actually works...

 

Facebooktwittergoogle_pluspinterestlinkedin

ESP8266 and MQTT Exciting Times

I don’t want to jump in prematurely here but those of you who have been reading the blog will know that I’ve had no end of problems with the MQTT stand-alone software on the ESP8266, but as each problem has emerged, the author (Minh Tuan) has been keeping in touch and working with me.  

MQTTLast week having apparently gotten everything working (that’s a real project continuously firing out temperature, responding to incoming time correction signals and accepting commands to turn GPIO0 on and off,  connected to a solid state relay controlling a lamp) when I realised that one of the real-life tests I’d missed out was … what happens if the broadband went off.

To my horror, it resulted in absolute failure.  The software would not reliably reconnect. I had some great suggestions from people – including one to think outside of the box, could it possibly be the MQTT broker not reconnecting properly. I worked on everyone’s suggestions to no avail.  I even updated my development environment (Windows 8 with Eclipse) to the latest SDK + patch (0.9.5) – no difference.  I can’t tell you now many evening hours I spent on this.

ESP-01Then this morning I had a contact from Minh to say he’d sorted the problem. I downloaded the code – and tested it – turned the WIFI off for a few seconds – turned it back on – HURRAY, reconnect no problem, re-subscribe no problem, queued outputs sent no problem. I was just about  to report success when I thought I’d see what happened if I left the WIFI off long enough to fill/overflow the queue (there is a RAM queue for messages and it includes incoming subscribes and outgoing messages, I had a hunch that a full queue might stop re-subscribes). Sure enough… the grim news on leaving the WIFI off for several minutes and reconnecting was that the software started up again – but all subscribes were lost – no room for them.

Thankfully Minh was around and immediately spotted this – we agreed that if the queue filled up completely and the WIFI restarted, the queue would be SCRAPPED.  Ok there are better ways and I’ve asked him to look at this – but for a quick fix he sent me a replacement mqtt.c file and… I put it to the test.

MQTT[6]3 hours later I cannot crash the software. No matter how long the WIFI is off it always reconnects properly. Some earlier strange issues on power up have disappeared (I feared they might be my own non-volatile variable storage additions.. but no).

The library has been updated accordingly just minutes ago and is here https://github.com/tuanpmt/esp_mqtt.

You really should take a look at this. For the first time we potentially have the means to make an ultra-reliable control system with the ESP8266 boards. Recent mods to the code free up RAM (an issue for example with the Lua software) and so I have no doubt there is lots of room in there to add your own bits.

To recap for those who’re looking in for the first time, anything I refer to here will be covered in other blog pages – but I’m using MOSQUITTO – in my case running on a Diskstation NAS Drive for reliability but it will also run on various platforms and there are servers out there for people to use as well. I’m testing this with the excellent MQTT-SPY and all of this without having learn a word of Linux Smile  thanks to the excellent feedback I’ve had on this blog and the work of others around the world who like me are so keen to get this working.  If all goes well I can now concentrate on mastering the likes of Openhab so that once I have boards in place controlling stuff, I can easily monitor and control the boards themselves from a mobile phone – and for the first time with a little security in place – the point of investigating MQTT in the first place!

phpIncidentally, the PHP page I use under CRON to push the time out to my MQTT broker – I had some fun with that as I realised it was pushing out rubbish (wrong time) and further to a PHP upgrade at my provider – was throwing in warning messages to boot. Here is the latest working version (been up there running 24/7 for a week now) with security information altered to protect the innocent. To keep things simply, the dawn and dusk information is only accurate to the nearest minute. That lowers the number of times it will be updated and as I keep this in FLASH, the number of times the FLASH is updated.

<?php
error_reporting(E_ALL ^ E_NOTICE);
require("../phpMQTT.php");

function varcheck($var, $default)
{
return isset($var) ? stripslashes($var) : $default;
}

$locn = varcheck($_GET[‘loc’], "Europe/London");
$lon = varcheck($_GET[‘lon’], 55);
$lat = varcheck($_GET[‘lat’], -2);

date_default_timezone_set($locn);   
$dateTimeZoneLocal = new DateTimeZone($locn);
$dateTimeLocal = new DateTime("now", $dateTimeZoneLocal);
$localDateTime = date("H:i:s d-m-Y", time());
$localDisplayDateTime = date("H:i l d-m-Y", time());
$localTime=strtotime($localDateTime);

$mqtt = new phpMQTT("your.mqtt.server", 1884, "whateverYouLike");
if ($mqtt->connect(TRUE,NULL,"yourwifilogin","yourwifipass")) {   
            $mqtt->publish("time",$localTime,0);
            $mqtt->publish("timestring",$localDisplayDateTime,0);
            $sun_info = date_sun_info($localTime, $lon, $lat);
            foreach ($sun_info as $key => $val) {
                if ($key=='civil_twilight_end') $mqtt->publish("dusk",(int)(($val %86400)/60),0);
                if ($key=='civil_twilight_begin') $mqtt->publish("dawn",(int)(($val %86400)/60),0);
            }
    $mqtt->close();
}
?>

Hopefully now I can stop worrying about reliability and start having some fun. I have suggestions for better ways to store things in FLASH and there is much to learn about Node-Red, OpenHab and much more so this is really just the beginning.

Facebooktwittergoogle_pluspinterestlinkedin

Raspberry Pi 2 Fast Enough?

The Raspberry Pi is a nice, cheap little computer but for me it has never been fast enough – I’m not interested in making another media server (I have a DISKSTATION which does that just fine) but as I’ve recently been working with MQTT in my home control setup, I did think it would be nice to have an MQTT broker and some ability to send commands to it in one little reliable box. 

Repeated messages out there indicate that the Raspberry Pi is pushing it’s luck to do all of that at high speed as it approaches the limits of speed (and possibly even memory).

What I’ve been looking for is the same thing with much more memory and much more speed. Well, how does (claimed) 6* more speed and twice the memory sound – for the same price?

I’m sure those who have recently purchased the original Raspberry Pi will have a million reasons why it’s not necessary – and I feel sorry for them but now it looks like the Raspberry Pi II (2) at long last has the power I need.

I wonder how long it will take before the price settles to what we would expect – I have NO doubt that early copies will be expensive – that tends to happen in Britain.

And as for Windows 10 – apparently Microsoft will make this available for free – that could be desperation or it could be EXTREMELY good marketing – for those who don’t really want to get into Linux – Windows development + Windows in the embedded code… has to be some mileage there.

More on this when my board turns up!

Facebooktwittergoogle_pluspinterestlinkedin