Eclipse and Node_MCU on Windows

Does anyone know what I’m doing wrong here… I have the full Eclipse set up on my Windows PC and have already imported the MQTT project and tested it – lovely. Like other projects you end up with CLEAN, ALL and FLASH controls to wipe old firmware binaries, compile new code and FLASH the ESP8266 modules – all very civilised and easy to use.    I did exactly the same installation with the node_mcu (ie LUA) software – and… nothing – no apparent way to do any of this within the Eclipse environment. Did I do something really stupid here? Hopefully, getting a solution in here will help others as well. Everything was installed from scratch on my laptop this morning so there is no old code here. It is all the latest downloads – and until Lua all went splendidly smoothly following instructions I’ve referred to in earlier blogs.

Examples – AT code – works fine.

AT Code

Example – MQTT project imported – works fine

image

See MQTT above – straightforward installation – the 3 buttons ALL, CLEAN and FLASH appear just like the other projects… but in the case of NODE_MCU….

image

Oh dear.- no buttons!

Also – if someone knows how to rectify this.. they might also be able to answer another question. Somewhere in the above project – I guess in the INCLUDE folder – is the 0.9.5 SDK.  In the other examples in ECLIPSE the best we have is the 0.9.4 SDK.  So, for example, what would one need to copy across, into a copy of the AT example from the nodemcu-firmware example, to be then able to compile the AT example with 0.9.5 SDK?

Any easy tips/answers in there I suspect will help a lot of people as well as myself. I could find all of this out with a lot of wasted time and experimenting, I’m hoping someone has done all of this.

ESP8266 Tuesday Update

esp-03[7]I noted this item on EBAY showing the ESP-03 at well under £2 each.. Not sure about those ceramic antenna – anyone any experience of how they compare to the excellent PCB version on the ESP-01 ??

Another item of note – I see there is a new LUA update out – looking forward to checking that out at the weekend and I’ll do a write up – apparently it’s based on the 0.9.5 version of the SDK. Is this out of BETA – and if it is does anyone have the link? And any updated documentation so we know what’s changed? I have to say that Espressif don’t do the best job when it comes to promoting their own updates.

That’s it for now – later this week I plan to put together a temperature sensor using only the ESP-01 and even consider sticking a lithium and a solar cell on it (I know, not the best time of the year for solar power) – more to have a permanent test rig than anything else sending out MQTT data.  The /TIME/ message I set to run every 10 seconds on my PC 3 days ago using Really Small Message Broker set up as a service, and MQTT-spy – is still ticking away (I can test it in meetings using another copy of MQTT-spy.   You might have noticed I did some frighteningly fast message blasting and everything help up ok. I expect soon to have MQTT traffic running back and forth – I’ve at least 3 locations that need external solar powered temperature and humidity monitoring.   MQTT-spy is due shortly to get some more improvements – looking forward to it – as for RSMB – I can’t think of anything wrong with it!

Feeling MQTT Thick

Oh firstly, after filling in the form with Espressif to keep commercial confidentiality about their SDK info which I’m still waiting for – I discover it’s freely available here – http://www.esp8266.com/viewtopic.php?f=5&t=449  granted that IS for the 0.9.2 version which is a tad old now..

Tonight as I get ready for a round of meetings in London which will severely hamper my research until later this week, I’m struggling with MQTT-SPY. I should say I’ve had some communication with the designer and he’s been MORE than helpful  – he’s added a demo time script, he’s changed the XML format slightly so it’s readable for the likes of Notepad++ all of which is great, but I want some pre-programmed scripts to send out publications – and can I HELL figure out how to use them.  I’m hoping for an update to the WIKI on that otherwise excellent free program. If nothing else I hope to set off a script every minute to transmit the time on “/time” and I can keep an eye on it while I’m away on business to check for reliability.

I didn’t get a chance today to update the ESP-12, now that the MQTT code works so well in the Windows environment, to add port operations to that as I thought I might use a couple of pins of the board as indicators instead of all that serial info. All I want coming out of the serial is MQTT messages.

My unashamedly Windows-only ESP8266 Facebook page  is doing well and how has over 170 followers which is nice.

Not much else is new. Quite interesting that people made so much noise about the Lua interpreter code going open source – the guys did that and what’s happening? Not  a lot right now.. the Frankenstein code? Nothing for a month….   the beta of the SDK? Nothing new.  Maybe everyone’s having the week off after Christmas.

Here’s hoping for lots of new developments over the weekend. Something I don’t really understand about the Lua code – it’s constantly short of RAM – and yet, those who are trying to understand the chip say that it has a LOT more DRAM than it has RAM… so I wonder if any of that is being used.. perhaps that will remain one of life’s mysteries.

And on a completely unrelated subject – if you’ve been struggling with your old Nexus 7 (2012) – the 5.01 Android update is out -  installed it today (with a lot of wheel-re-inventing) – and.. yes, I think it speeds it up again.

Brief ESP12 MQTT Update

After a little conversation back and forth, the MQTT code now works and the Really Small Message Broker is running just fine as a service, no surprises with the ESP-12 and tomorrow if time permits I’ll import some port control into the package and use a couple of those handy port bits to give out status information.  Tackling input into the serial port is another matter – no idea how to do that yet but how card can it be.

It really would help if Espressif would release the SDK technical docs as I asked. You’d think they didn’t want to sell any chips!

A World of MQTT on ESP8266

MQTTFrom no-where, I’ve been immersed in the world of MQTT for the past day or two. If you’ve read my previous posts you’ll know I’ve been working on home control for years, mainly as a hobby and so mainly on a budget. I’ve tried several systems out there and eventually settled on doing my own thing because many of the packages have been developed so far then stopped or they’re very complicated or expensive etc..

ESP8266My earlier posts will show you that I’m walking around with a mobile phone with fairly decent control over 3 properties right now, so it’s not that I don’t have solutions – but the controls could be more responsive, I’ve had a hell of a time with the NRF24L01 radios which I plan soon to put up against a wall and shoot and I was in the process of swapping over to some 433Mhz units when out of the blue the ESP8266 modules appeared and changed all that.

Anyway there is one guy developing a network of these things – early days yet and when I re-discovered an MQTT library was available for the ESP8266, it seemed the natural way to do the job (don’t rush – the version out there yesterday has developed a big fault – give it a day or so) – each unit, be it an ESP-01 on it’s own with a sensor – or attached to an Arduino or something more powerful, would be able to send to and received messages from any other unit – marvellous.

The “broker” for messages is the package that accepts messages from devices (or PCs or whatever) and makes them available to other devices. Loads of advice from people to use “free” services – but after wasting many hours – they all come with a catch. Limits on use, lack of guaranteed they’ll actually be up and running or in the case of one – your messages are open for everyone to see. NO THANK YOU.

Petes MQTT TesterThe obvious choice was a local copy of MOSQUITTO – the free package designed, apparently by Roger Light. A simple DOS application which can also act as a service. Marvellous. Now I needed to put the code into the ESP8266 – that worked – marvellous. I even developed my own little client application (well, I tarted up a demo) on Basic 4 Android (B4A). Now I needed some PC client to test the messages… not so marvellous. The command line tools provided with Mosquitto are, well, command line tools – I may be 60 but I’m still part of the pretty-coloured-buttons generation – I really would rather have as little to do with black boxes as possible.  At least half of the links I tried on the web went to projects that haven’t started yet, or old ones that were dead – or just no-where. I finally settled on MQTT-SPY and I have to say.. it’s lovely both in operation and visually. MQTT messages are really trivial comprising a topic – and some content. I set up Mosquitto, subscribed to an arbitrary topic – and sent a message to it. LO AND BEHOLD it appeared at the bottom of MQTT-SPY.

I realised at this point that the messages were utterly non-secure and started to read the documentation for Mosquitto. After a while as I started to ponder cutting my wrists I came to the conclusion that this package was a TAD over the top for my requirements – I got password protection working and tested it out – very nice – but then two of us were using this and in both cases the package failed once.  At that point my friend who was helping me got very excited as he’d discovered RabbitMQ – a VERY pretty alternative with a nice shiny web interface for both Windows and Linux. He went off and set up an Ubuntu box and hours later we had our RabbitMQ setup. I started to play with MQTT-SPY.

Well, it didn’t take long for the varnish to come off. One of the things you might do when you have a home control system is have some gadgets saving power by sleeping and then just waking up occasionally to do the job. MQTT has a couple of ways to help you – QOS=2 and RETAINED status. You’ll see this in MQTT-SPY if you select the slightly more complex screen option – Window – Perspectives – Detailed option.

The idea is simple – someone sends a message – someone else isn’t listening right now – but when they do – they are guaranteed to get that old message as against the default status where they don’t get old messages.

Guess what – RabbitMQ doesn’t support either of these options. Despite the very pretty interface, that was the end of that for me. So what next?

Well, didn’t I discover this little thing..

https://www14.software.ibm.com/webapp/iwm/web/preLogin.do?source=AW-0U9

MQTT in actionApparently “Really Small Message Server” will run in as little as 200k and it’s a available in a variety of platforms. Anyway – the installation could not have been simpler. I unzipped the zip file into a directory – navigated to the Windows directory within and ran the program. Done, dusted.  Of course, no password etc.. but they’ve taken a different approach to Mosquitto – you start with no config and no passwords and add them in as you need them – the documentation is VERY clear.  I made a simple config text file and put in the name of a passwords file. I made a simple passwords file with a couple of names and passwords in it – and ran the program – it worked immediately.

I hooked MQTT-SPY into it – and tried the various alternatives – QOS 0-2, retain etc.. all worked perfectly.

That was last night – this morning the little DOS box is still sitting there running Really Small Message Server. I’ve no idea how fast it can work but put it this way, I can vibrate my finger as fast as the next guy and managed to get 100 button presses in around 2 seconds – the program FEELS as if it will handle MANY times that speed. That’s accepting a message and firing it back out. Not a small message either as you’ll see.

MQTT

In the model above you see how this works – generally you are sending a topic – which generally will be in this format device/topic  so for example “03434/lightcontrol” and the data might be as simple as “on” or “off” – it is however possible to send a very long string and I send things like “red=255;green=5;blue=25”  – I’ve had the ESP8266 wrap messages in {} before sending out the serial line so they come out as this {red=255;green=5;blue=25} – the Arduino easily picks up the starting character (I could make it more complex) and stores the string till the end character (or out of buffer space), rips the commands apart and goes off to sort my serial LED lighting out.  In the future I’ll have the ESP8266 do this directly – GPIO2 could directly control a set of serial LEDs.

One could imagine putting Really Small Message Broker on a Raspberry Pi though I did read that Mosquitto has a little difficulty – high speed messages coming in tend to get taken in and not until there is a gap do the responses go out – or so I heard. I’m thinking an old laptop might be a better bet. Having said that one of my PCs stays on 24-7 – I also have a Synology Diskstation – it would be REALLY nice if I could convince Really Small Message Server to run on the Diskstation as that thing runs day-in-day-out without a hiccup.

tmp3157

I modified the MQTT software on the ESP8266 just a little. In the default demo, any incoming messages display on the serial port along with status information. I’ve wrapped the messages in {} so that my Arduino can easily pull them out.  The next job will be to allow the Arduino to send via the serial line, messages and subscribes etc.. but I’m waiting for a fix to the ESP8266 library before I do that…. https://github.com/tuanpmt/esp_mqtt – you’ll see we’ve left issues. One resolved, what both my friend Aidan and I would both like to see is a development of this with a web-based setup so you don’t have to recompile every time – it has promise.

NODEMCU Board–a little winner

I think this has chance to be a little winner – in many respects. The NOCEMCU guys have made an open source board for ESP8266 that looks the business and should let more people experiment with this great chip – between that and AT LAST getting a proper Windows environment to program in (Eclipse) things are moving along nicely – I hope they don’t mind me replicating one of their diagrams here but it’s so good it deserves an airing – the numbering of course refers to their board but you should be able to cross link with the pins on other boards – here’s an excellent pictorial view of the ESP8266. NOW we can see for example that GPIO-16 is the wakeup lead – tied to RESET (RST) it can enable putting the thing to sleep for ages and saving power.. etc.. anyway you have the link to the site….I’m not promoting that over anything else and no they’ve not sent me a free sample. https://github.com/nodemcu/nodemcu-devkit – my thanks to GLENN for this information – well spotted.

ESP8266 Development Board

ESP8266–a Way Forward

Right, it’s becoming pretty clear how this is going to develop for some of us… I’m not interested in joining someone else’s circus when it comes to home control – I want to do my own thing… but I want inexpensive mechanisms to help me do that and it’s becoming clear that MQTT as a communications mechanism is going to be part of that. It’s also clear that the ESP8266-type boards are also part of that.

So here’s where I think we are right now – but firstly I need to explain MQTT for absolute beginners before they run away:

I’ve been messing with home control over 2 years now, I wasted a year of my life on those AWFUL NRF24L01 boards which can’t even manage a single stone cottage wall and won’t send and receive at the same time. Then I moved onto better radios and even did some work with a friend on the Atmel radio processor boards – and then all of that seemed to change – the ESP8266 WIFI boards came about. Why were they better? Well first off they could use your existing WIFI infrastructure, they had excellent range, they were CHEAP – and by that let me make my position clear – I think spending £30 to turn a 50p lamp on and off is STUPID… it needs to be a LOT cheaper – like “a few quid”. When it comes to complexity – a little WIFI board on it’s own is sometimes all we should need (temperature sensor), or for a more complex item that feeding, say, an Arduino. In the past the problem has been that by the time you add Ethernet libraries and radio libraries to the Arduino you end up with almost no memory left.. and hence my use of the more powerful 1284 chips on custom boards – but that’s not REALLY the answer.. Micro-Arduino boards from China at £2 is REALLY the answer.  So a WIFI board+micro-Arduino for £4 or so – that’ll do.

The ESP-01 board is a perfectly usable board which sadly has a couple of things missing – the link for SLEEPING being one of them – the chip pins are way too small for most of us to solder and so it looks like the slightly more expensive ESP-12 might be an answer – it also has lots of FCC and other stickers to keep those people who care about such things happy.

But how do they all talk together? It seemed at first that the ESP8266 would do it all then reality set in – you can’t be a client, talking TCP/IP to a phone – AND be a web client, getting the time etc. at the SAME TIME – OH DEAR, the dream was starting to come apart. And then along came MQTT.  It’s REALLY simple… you have a machine or service somewhere called an MQTT broker and all it does is this.. everyone logs onto it with a unique name, lets say we call our devices peter and paul. Peter and paul can receive messages from the “broker” and send message – to anyone. So Peter can sent a direct message to paul. Problem solved. But it gets better.

The TOPIC system lets peter only subscribe to messages he’s interested in.  So, if Peter was an external temperature sensor he might only be interested in messages requesting the temperature.  If Paul however is a thermostat control, he might be interested in knowing what Peter’s temperature is – and what the time is . He might also want to know if he’s on PEAK time or not, or what the current requested temperature is. If this is not exciting I’m doing a piss poor job of explanation as it’s got me excited.  So whatever this protocol is it needs to be available on PCs and Linux etc., it also needs to be available on ESP8266 for those projects that use it – and on Arduino for those projects with a hardwired Ethernet connection. Well, as of around now – IT IS!

MQTT is now available on the ESP8266 but BEWARE – the author himself says this is for messing with and not yet for production – so don’t get TOO carried away – a new release came out yesterday with SSL. https://github.com/tuanpmt/esp_mqtt – my own experience is – it WORKS. I’ve had a little light sitting there dangling from a shelf, listening to the broker and responding – and it just keeps on ticking – loss of power no problem – it picks up where it left of.

But what if the little device is not on all the time – won’t it miss messages? Well no because there are 3 types of message (it’s important this is implemented in whatever you use. Type 0 message means send it and take pot luck if anyone gets it-  type 1 means they are guaranteed to get the message – but they might get it more than once. Type 2 means they will get the message for sure – once only.  This is nothing more for you to worry about than putting a number at the end of a function – 0,1 or 2.

So, let’s backtrack – that time thing. Right now I have an Arduino which calls a web page I wrote to get hte time because I don’t find NTP time servers that reliable (they get a lot of use) and they don’t send me lighting up times etc. I wrote my own PHP page sitting on a public server so I could get what I want, when I want.  And that was fine, it’s in the blog and some of you have used it… but there’s a BETTER way. Given an MQTT server and the common ability of web servers using CPANEL to allow “cron jobs” – WAY more complicated sounding than it is… imagine if I could have the ISP call that page every 15 minutes. Imagine now that the page instead of returning the time and light up times, sends that info to the BROKER!!! (As it will from sometime this afternoon until eternity). NOW the lonely thermostat ESP8266 in the kitchen doesn’t need a whole new protocol to learn – it just subscribes to that message and every 15 minutes it gets the time – SIMPLES!! But by now your ears are probably pricking.. hang on.. if I can do that then… yes, the humble web page now not only can send off the time, but a load of stuff like “lamp 4 in the living room – it’s time to turn on”. Instead of having to write a whole load of shite in a little processor you can have a password protected page on a website with TONS of terms and conditions to setup and you can update them on any old tablet and… well, I’m sure you’re writing code already.

What’s wrong with the above..

The little ESP8266 powers up for the first time, has no idea what your router is called.  So what we need is the MQTT software on the board, COMPLETE with the simplest page…. what is the router called – what is the password and what’s the address, name and password of the MQTT broker. As the ESP8266 can be it’s own access point this could all be done by a mobile phone which talks to the unit which ONLY is an access point if you pull a lead down to ground – or better – only when it actually has no information stored or the info stored does not work. Anyone up for that.

Lua allows people with no engineering degree to interact with the ESP8266 boards – and it’s very nice and there’s one fellow suggesting a way to merge MQTT and LUA – that would be great – but again BEWARE – the Lua installation WILL let you down if you get too ambitious – the implementation is unforgiving when you make mistakes and it EATS RAM.

If we could combine ALL of the above – a Lua interpreter that has it’s own web setup page – and the MQTT client software and maybe a range of temperature sensor libraries (the DHT22 is good – reliable, accurate and gives both temperature and humidity)….

BUT we won’t always be working with the ESP8266 alone – we might want it to be part of a package with an Arduino.. SO –  the unit when it receives messages should always put them out onto the serial line – maybe wrapped in some unique combination of characters – like << and >>or similar so it’s a doddle for the Arduino to pull out the message from any other crap (like the ESPs start-up 78kbaud crap we can’t seem to stop) with the absolute minimum or parsing… so for example if we have a topic peter/stuff and a message “turn something on” – maybe <<peter/stuff:turn something on>>   – see what I mean – look for “<<” – store until the colon in one buffer then till >> in another – and you have 2 buffers – topic and message – SIMPLES!!  But then there’s the slightly more complicated bit – they Arduino would need to send into the serial port two things…. 1. a topic/message in the same format – but ALSO commands to subscribe or unsubscribe to topics…   I honestly think at this point that this is ALL we need from the ESP8266… that of course and the whole thing being in a Windows- Eclipse compatible GITHUB package we can drop in – open up ONE web page in which we put our own special bits – using the Espressif SDK manual which they seem to be rather reticent to part with.

MOSQUITTO is a free MQTT broker (or server if you like) and it’s fine – but it’s all command line and pretty gruesome for beginners to understand. It can run on a PC under Windows… it’s ACTUALLY not that difficult once you’ve used it but messing with that config file is like a trip back into the 20th century – someone needs to make a nice sparkly Windows screen with lots of tick boxes.  When it comes to clients on the PC I’m in love with the free MQTT-SPY – it’s just lovely.  As for Android – really – MyMQTT is awful – if anyone wants to re-write MQTT Spy for Android they would be on my Christmas card list for years.

So there you are – I’m playing with Mosquitto and Rabbit-MQ which looks really nice but I have to say it did collapse when I tried to send a level 2 message out… might just be me not understanding things yet.

From here I’m ready to start coding – there’s enough above to form the basis of a very large and complicated control system –  I’m THAT far off having an internet controlled SAD light for the wife… it’s sitting here waiting for commands but I need something on the phone with nice round, shiny buttons and flashing lights that looks the part – not sure Basic 4 Android is going to do that for me but we’ll give it a whirl.

Let me know if this didn’t make sense – because if it didn’t you’re missing out on lots of potential fun.

Regards

 

Peter Scargill

p.s. The easiest way to get to grips with this MQTT thing – get MOSQUITTO – install it  – ignore usernames and passwords for now.  Get MQTT Spy – tell it about the IP address of the machine with MOSQUITTO (can be same machine) and PLAY… subscribe to arbitrarily named topics – send messages to those topics – within minutes it will all become clear. 

p.p.s. If you’re a Facebook fan and want to read about this stuff ONLY for Windows users who like pretty interfaces like me – head over to www.facebook.com/esp8266wifi

ESP8266 and MQTT A Marriage Made in Heaven?

It’s been a very busy day – and a very frustrating day. I’ve had to make a start at figuring out how MAKEFILES work because of a fellow who implemented MQTT for ESP8266 so I could seamlessly compile his code and blow ESP-01 chips with the Eclipse environment in Windows.

It all started a couple of days ago when I utterly accidentally stumbled on a project to implement MQTT onto an ESP8266. I don’t know why I went for this but I’d just gotten to grips with the Eclipse setup so I was now a fully fledged Windows developer of ESP8266 software.. by that I mean I’d figured out how to alter code to get a light to flash on and off in the AT command software.

I remember playing with MQTT a while ago and I mentioned it in here or on the ESP8266WIFI Facebook page. Anyway I sat down with a large glass of wine and started to tinker. Essentially, MQTT is a lightweight protocol for sending messages around a network – apparently Facebook Messenger uses it.  You have a “broker” – call it a server if you are a techie… so this is free software like for example MOSQUITTO which you can run hosted, on your PC or on a Raspberry Pi. you can make an account with it – which might be open, have a simple password or have something far more complicated.

One of my fears of controlling the house remotely has always been security and I’ve made some primitive passwording which is really not worth a light.. so this caught my interest. My other issue as regular readers will know was that I was getting utterly hacked off with the ESP8266 as it can’t really do server and client at exactly the same time – so you would have trouble making a network of them – you CAN do it and there’s a slow moving project on the subject… but right now, not a viable solution – that might change.  The instant I saw MQTT my heart skipped a beat as I thought… can’t one device send a message to another?

I put IBM’s free MOSQUITTO on my PC (powers up with no passwords etc, doddle to use even if the command line environment makes some people feel physically sick – including me). IT uses a single port which you can change so it’s easy to make available outside via a little port mapping on your router.

I blew the code for this onto one of my ESP8266 boards – and left that connected to a serial monitor. Sure enough, it connected first time to MOSQUITTO. It SUBSCRIBED to a couple of messages (utterly arbitrary and they don’t need to exist at the time of subscription).

I grabbed a free but not very good program for Android called MyMQTT. IT’s not seen an update in AGES but I remembered it worked ok. I told it about my MOSQUITTO setup (ie the IP address of my computer) and that was that. I subscribed on the mobile APP to the same “topics” my ESP8266 had. I sent a message to that topic… sure enough instantly on the phone, the topic I’d replied to came back with a message – the same one I’d sent out… simultaneously the same message came into the ESP8266. We’re talking INSTANT here – no visible delays.

Immediately I grasped the possibilities. I modified the MQTT code (in the new sparkly ECLIPSE environment) on the ESP8266 to check the content of one of the topics it had subscribed to… a quick STRSTR on the zero-terminated incoming string… I made 2 comparisons – one for a message “GPIO0 ON” and another for “GPIO0 OFF”. I borrowed the heater and port info from a BLINKY sketch (all of 3 lines of code for everything)… and compiled away. I sat in the corner of the room and gingerly entered “GPIO ON” into my mobile phone app… and… BINGO the light came on.

Step 2. When the light comes on – SEND a message to the same topic but a different device number – I should say the author engineered auto device numbers based I think on the mac codes – they’re all unique…   /0033342342/data as it happens – I sent a hello.

Sat back with the phone, put my GPIO message in again, the light came on and IMMEDIATELY the message appeared on the SECOND ESP8266 as expected.

So with the minor inconvenience of a piece of “broker” software minding it’s own business on a minimal PC, a Raspberry Pi or some external server (your choice) the ESP8266 boards can now talk to each other without another processor. Not only that, I reasoned but if the server machine also had a client, it should publish a “TIME” message every 10 minutes or so…  the boards would IF APPROPRIATE be programmed to subscribe to this channel and LO  – ESP8266 boards which can turn things on and off – and also know what time it is. But what of the power of an Arduino – what about all those extra pins? Another project implements I2c on the ESP8266 and when my skills are ready I’m adding THAT into a mix – which means any number of peripherals to do things or return info using MQTT.

It’s a grand total of £40 or so investment to get yourself into the Android App trivial programming brigade using B4A.  Mine of out of date, out of warranty and so I’ll ahve to start again. For £10 a guy has written a library for MQTT and this afternoon on a friend’s PC – someone who has the full B4A, we wrote a simple messenger program that will send and receive MQTT messages. The results – again absolutely instant message passing back and forth.

Imagine – you have a button on the phone – you press it and it does two things.. it turns a little indicator called kitchen_lamp to grey then sends a message to /kitchen/lamp which it does not subscribe to – the message is ON… the kitchen lamp ESP8266 box which features nothing more than an ESP-01, a 3v mains PSU and a relay, gets the message and turns off GPIO0 which turns on the relay (there’s a good reason to do it backwards like that). It then sends a message back to another topic which it does not subscribe to called /kitchenresponse/lamp. THe phone however DOES respond to that – and when it sees an incoming message to that topic, it turns that same indicator green or red depending on the message.  So the lamp is off – you press the on button and your indicator on the phone almost immediately turns green so you know for a FACT that the kitchen light came on.

You might take that a stage further – because you’ve written the client on your PC to send messages like TIME, the kitchen lamp knows what time it is because it also subscribes to TIME.  if no-one turns that lamp off, at midnight it turns it off itself.

Multiply this by dozens of similar gadgets, some DO stuff like turning things on and off, others merely sit there, read the temperature and report it back – either every now and then – or on demand… same technique..

An old Android tablet sits on the wall, it has a program you wrote which subscribes to as many or little of the topics as you want and reports in pretty graphical format the various statuses-  it might even have a large round touch control reminiscent of a a certain apple-esque temperature controller…. and everyone talks to each other securely over WIFI..

BUT you might say, I really want to use Arduinos – ok you have the little ESP8266 do all the hard work of handling messages incoming messages it sends out of the serial port and if you want to send a message that could come in through the serial port… so now you have an Arduino that has to do nothing but take in serial messages and send them out – polling is easy – and you can of course wrap messages in any control character or sequence you want.

But hang on – isn’t Arduino serial interrupt driven? YOU BET – which means if you go in and tinker with that you could have that look for the starting sequence, start storing bytes until the ending sequence occurs, copy that temporary buffer to another, set a flag to say there is a massage – and simultaneously go back to looking for the next message – all using existing resources that are used in the serial handling anyway.  The Arduino ends up with a few bytes less than a full pack and can now receive serial messages and act on them with virtually no extra overhead which means the simple 328 has LOTS of room to DO stuff.

That enough for now? It certainly has me excited but I’ve had enough for one day… I need to turn most of this from thought processes to reality. The MQTT project is apparently in it’s early stages but I can assure you it sends messages with password protection as reliably as it receives them. Even if the designer does nothing else you have this at your disposal – links in earlier entries in this blog. Go get ‘em.

Now if anyone’s up for some collaboration I’d much rather someone else write the Android APP – a decent replacement for the promising but dead in the water myMQTT..  All in good time – good night all.

ESP8266 Development in Windows AT LAST

ESP8266 on WindowsHere it is… on the surface of it a MASSIVE Christmas gift to those of us who simply have to little time on our hands to get involved with Linux.

I got so frustrated waiting for up to date BIN files and the continuation of Chinglish error messages (I should not complain because many Chinese speak far better English than I speak Chinese) – I decided this morning to down tools and see if I could get the compiler working in Windows – but I wasn’t expecting THIS.

I was stumbling through various blogs and discovered THIS.

http://www.esp8266.com/viewtopic.php?f=9&t=820&sid=783b2f3021078ab65722108fdfadd5d8 – the link gives you all the files you should need to get working environment in 64 bit Windows – and this video https://www.youtube.com/watch?feature=player_embedded&v=eWGjADdjH98  shows  a demo in the video of the whole ESP8266 compilation and rom-blowing – WITHOUT reams of irrelevant warning messages!!

ESP-01AT LAST, ESP8266 compiling and blowing in human-readable form. I got VERY exited about this as there are several developments out there which are ALMOST what I’d like but not quite – a stress free way to mod the source codes would be lovely. For example one fellow has developed the AT command set for ESP8266 using the latest SDK and added NTP support – another has added a well needed internal buffering scheme to the serial – what would be great would be BOTH of these in one package – the only way to do that is to get the sources, compare, mod and blow your own chips – and now my Windows friends – you CAN.

Check out the link and follow the instructions EXACTLY – don’t go off on a tangent as there’s a similar page with failed links and lots of Russian – you’ll find the JAVA file on the linked website is later than the one he specified – won’t worry about it – still works. There is an issue also that in his diagram he shows the ESP-01 with pins GPIO0 and GPIO5 connected to the FTDI (USB-RS232 convertor) – well, you don’t HAVE GPIIO-5 available on the ESP-01 – I’d tell him that but I don’t speak Russian – I did leave a note on his YouTube site. . Matters not – you merely need to ensure as before that GPIO-0 is grounded before you start blowing chips – and don’t forget to cycle the power to the board before and after.

Follow his instructions TO THE LETTER. I installed each of the packages (with the updated Java package – when it came to his EXTENSION package which consisted of a BATCH file, I noted (typical command line stuff – whizzes by you too fast to see) some errors to do with packages already installed. Mad no difference, still worked.

Eclipse on Windows compiling ESP8266I followed the instructions for the Eclipse Luna program including point 8 in his documentation though that last paragraph I simple could not understand. But then I realised this was explained in the short video.

So – 5 files in all totalling maybe 400Mb – and worth every byte!

By the time I was finished (NO extra work other than following the instructions and no “assumptions” other than having Windows 8 64 bit)… and I ended up with this.. As you can see, pretty damned impressive,  a working rig with various projects already included on the left, all set up INCLUDING the latest AT v0.2.0 on SDKv0.9.4 – which is the one I’m currently interested in. No Lua but I’m sure someone can help there.

Compilation WORKED (wheeeee)…

tmp26DDBut then when it came to the last bit – blowing the file in to the ESP-01 – FAILURE.

I found at least 2 places in the MAKEFILES referring to COM2 – which I changed to COM5 (all done within the environment) – that just seems the WRONG way to do this – surely you would set the COM port outside of the MAKE file and pass it as a parameter – if you figure this out – please WRITE IN… 

I changed the COM port manually and eagerly double-pressed the button to blow the chip. My little board flashed for a second and… failure. I’d forgotten to short GPIO-0 to ground. Power off then back on with the link, plug into the PC via my FTDI –and…..SUCCESS. 

Right about now I can make a minor mod then compile and blow all within 26 seconds – which is amazing.

ESP-12So – there you have it – that and the revelation that my FTDI can indeed generate it’s own 3v3 and hence I can run the Arduino and the ESP8266 on 3v3 instead of messing around with level convertors…. it’s been a GOOD DAY so far. No longer the poor cousins of the Linux crowd..

I hope you get as much fun out of this as I intend to. Next stop I need to ensure you can just pull in a GITHUB folder structure as I’m sure these won’t be ENTIRELY up to date… he doesn’t seem to have the LUA interpreter in here – as that has only JUST gone open source – again if you manage to pull that in and compile and blow, please come back in here and give us a step by step along with any other news of updates to install – I can see this environment getting a lot of use.

I installed this on 64 bit Windows 7 without ANY issues, next stop I hope to repeat this with Windows 8. If only Dropbox was faster…

07:04PM – Tested in Windows 8.1 64-bit – no problems – same procedure, same results – success.

08:02PM – Tried the MQTT demo – loaded it in from the site ZIP, imported all fine, compiled all fine but did NOT generate a firmware directory and so blowing the files could not proceed. Maybe this is a one off problem?

If you’re on Facebook don’t forget to LIKE my Facebook page – where I can concentrate purely on Windows users.. https://www.facebook.com/esp8266wifi

ESP8266 More Christmas Goodness

News:  There is an SDK beta at 0.9.5 out…

There is also a new AT beta with buffered output and a CTS pin (yes, REALLY needed) – but as it’s beta I’l leave you to find all of that at the Expressif BBS site below..

timeBut here’s the more interesting one http://bbs.espressif.com/viewtopic.php?f=15&t=105&p=352#p352

I just grabbed the AT binaries based on 0.9.4 with NTP support added – hell of a lot faster than my website interrogation!!

Set the board up – do AT+CIPNTP=0

(where 0 is no offset from GMT – if you’re in the UK – adjust accordingly)…

Assuming it comes back to say it sorted it – (I HAVE asked if we can have “OK” or “ERROR” on the end)  use AT+CIPNTP? to get the time and date.

A good move forward – NOT tested the rest of the code as it’s Christmas and we’re now off to see the family – enjoy.