Category Archives: Espressif

HC 2018 Experiments

Throughout the development of the Home Control 2018 project I’ve constantly had the software tied a via a serial umbilical to my PC to monitor passing messages, make sure all is well etc. and to periodically check on RAM space to make sure nothing I’m doing is running away with precious memory.

You may have seen elsewhere that I’ve been working with a prototyping board which is basically an ESP12 with a prototyping area in which I’ve put rows of pins for ground, 3v3, 5v and the two lines I use for I2c as I add various peripherals culminating in the recent idea to use an Arduino 328 chip as an “ultimate peripheral”.

Well, we’ve taken that one a stage further and we’ve been discussing making our own prototyping board (Aidan’s a whizz at PCBs and of course we use the likes of Dirty PCBs in China so it is quite cheap to knock up a few boards) and the last few days I’ve been formulating a planas Aidan puts together the schematic. What I’ve realised is that I always run out of the power and ground lines no matter what I do. Add to that the FTDI so I can monitor serial Comms and it all gets a bit messy.

Display for HC2016

So right now we’ve been discussing a board with the ESP-12 module with lots of pins and additionally a 328 SMT chip with Xtal. Of course that means 2 serial monitors. I’ve been playing with the old QDTech 128*160 displays since I discovered that they work pretty well when driven from the proper SPI pins on Arduinos (don’t even think of using software SPI on them) and ramping up the SPI speed – and so it was that in conversation, we were saying “if only you could scroll them” – that led to thoughts of having a RAM buffer larger than the total available on the ESP8266 or Arduino and… well, I thought I’d use our friend Google to go take a look. It turns out – I was completely unaware of this and VERY pleasantly surprised to find – that the QDTECH chip has the ability to scroll up built in – all that is needed is to scroll up an area then paint a fast horizontal black line after each scroll.

There is a version of the driver for the board here and at some point in 2014, it turns out that an M J Sage added this scrolling ability. Well done.  I wonder if he or she realised what a useful addition this could be.

So now we have a display, easily driven by the 328 which can scroll constantly (I’ve had it on several night’s test) and hence provide a boatload of status info. Top and bottom can if needed remain static.

First Stab

We’re going to incorporate the display onto the prototyping board and it won’t take any additional space as it will sit neatly over the other components! The image above probably bears no relation to the final board but I’m just trying to convey an idea here. The prototyping area on the right of the board will be chock-full of PTH holes but there will be long runs of connected holes for power and I2c as these end up being needed the most with connector wires. All 0.1” of course.

With the QDTech display you can connect the reset line to the 328 reset and hence here are my first thoughts at the use of the 328 which will have access to A6 and A7. I’ve pretty much got this working – just need to add in the temperature handling code I already have for Dallas and DHT chips.

D0-7 – general purpose port extender – inputs or outputs or any mix
D8     D/C for QDTECH
D9     16- BIT PWM out
D10  16-BIT PWM out
D12   MISO
A0      CS for QDTECH
A1      Temperature
A2      Temperature
A3       Debounced input
A4      I2C to ESP
A5      I2C to ESP
A6      Analog in 1
A7      Analog in 2

Aside from losing GPIO2 and GPIO14 inputs (as they’ll run the I2c) the ESP use will remain the same.  The only restriction being that we cannot run ESP PWM at the same time as the I2c due to timing interference– a pain but not something I can see away around. The I2c 16-channel PWM controller does seem a good way around this as it offloads all PWM work onto a cheap board – for single colour PWM lighting the new 16-bit PWM on the 328 works fabulously.

Given that the 328 can handle inputs for the main board we can do away with our normal GPIO2 and GPIO14 and they can have the job of I2c, leaving all normal outputs as for the existing system.

I guess the end-game here will be the smallest possible board that contains both the 328 and the ESP wired to this spec for general use. But that comes later after we see how well all of this works in practice. First the prototyping board. Watch this space.

Sadly in the link I’ve enclosed, the author refers to Banggood who used indeed to offer these displays for under £3 at a time when there were no software drivers for them – (I think we paid £2.60) but I’ve noticed recently that Banggood have been getting greedy and jacking their prices up – a cursory check of the link shows they now want £5.48 for these simple LCD displays – well good luck with that Banggood.

The only ones I’ve found up to now – and the price is good – as usual – is AliExpress.

Someone have another link?  the board has an 8-way connector at one end and a larger connector at the other – with a full size SD socket on the underside. See the AliExpress link.

This blog entry could well change dramatically as we spot fatal flaws in the plan above Smile


A Flashing ESP Chips Surprise

Well, you could have blown me away.  Tonight was making a little relay controller for the hot tub using a WEMOS board and relay board. I carefully soldered them together and plugged them into a USB connection on my PC, as I’ve done thousands of times.

Also as I’ve done thousands of times I flashed the board with my ESP8266 standard software which I have down to a single button-press in Eclipse.

Continue reading A Flashing ESP Chips Surprise


Flashing HC 2019 Code

Hackitt and BodgittThis entry is now incorporated into the main Home Control blog entry. This is for the people who’ve been trying out my software (or thinking of trying it out) on the ridiculously cheap (£1.40) but very reliable, powerful and comprehensive ESP12 WIFI processor board and those who’ve gone ahead and gotten some boards we made – all referenced in earlier blogs. For the latest on how to FLASH the chips see this blog update.

Essentially the assumption here is that you have an ESP-12F-based )(or variation such as ESP-12E) board of some description and that GPIO0 is used as a programming button (held to ground to program etc) – and also as a web setup button.

Continue reading Flashing HC 2019 Code


Espressif New Board

imageWell we know that the ESP8266 replacement will have Bluetooth low energy, a different architecture and more RAM – something to look forward to – so now here’s a sneak preview – this is not the latest PCB but it’s better than nothing I’m sure you’ll agree.

So we’re looking at something with a few more pins than we’re used to and very little else – I’m seeing a crystal – I’m not seeing EXTERNAL flash or RAM here so one can only assume that it is internal this time? I’m looking forward to seeing more of the new wireless SoC with two Tensilica L108 cores and called ESP32. So, faster WIFI, Bluetooth, dual core, low power improvements, more peripherals, more RAM, better security and simplified APIs and approaching 40 I/O lines (though I’m only seeing 37 actual edge connections in total on that board) –  what more could you want.

Do you know more? If so – spill the beans!!! Unlike some posts I’ve seen this is not a random image – it was supplied to me by Espressif themselves for your entertainment! Oh – here’s a link with some useful info…  also a contribution by reader Rudi here –





ESP32 Coming Soon

So many of us have been happily using in the inexpensive ESP8266 chips for some time now for IOT applications, home control etc and long may that continue. They do have SOME issues – for example they are short of RAM memory to the point that all except critical subroutines have to be stored in FLASH and pulled out when needed. The somewhat slows things down as the 80Mhz processor (160Mhz at a pinch) has to pull stuff out of the external serial FLASH to use it. In practice the ESP8266 is still very fast but this is just one step that would be nice to avoid. Lack of IO lines also is a little painful as so many of the available lines are dual purpose – GPIO0 for example cannot be held low on powerup as it is used to put the processor into programming mode. We get around these issues but wouldn’t it be nice if we didn’t have to.

By the look of it, the upcoming ESP32 will have more RAM (400KB) and more IO (close to 40 !!!) IPV6, a little more expensive – we’re hoping not MUCH more as initially Espressif were saying it would not be more expensive! Bluetooth will be supported, there’s a dual processor (two powerful Tensilica L108 processors), better security, faster WIFI (the WIFI will have it’s own processor hence no more worrying about delays – that’ll be a relief) – and low power. QFN packaging.

All sounds very exciting and thanks to Espressif and readers in here for bringing this to my attention.


Drilling into Blynk

zeRGBaYesterday I referred to using DELAY in Node-Red to slow down one of the Blynk controls. To backtrack a little…  We’re talking here about controlling devices such as ESP8266 boards using MQTTT – which I maintain is the best way to have a boatload of devices around the place and talk to them. I do this from a Raspberry Pi 2, using Node-Red which is a visual system, relatively easily fitted to the Pi (see my articles about my script). Once you have this in place, you can use simple (but excellent tools such as MQTT-Spy to send out MQTT messages to your devices and get input from them.

But in the real world who wants to sit there programming a tool just to turn a light on. So there are various options including the rather expensive Raspberry Pi touch display. A better option IMHO for local operation are the Nextion touch displays which work serially. I’ve covered these elsewhere –  a project that is still in it’s early stages but with a little work is usable – so much so that I plan to use them in my place here in Spain and back in the UK as thermostat wall mounts – I’ve covered that elsewhere under “Nextion”.

And so to Blynk. For many months I’ve been trying to get a decent control/display combo for the mobile phone. I’ve written my own in jQuery mobile and used the likes of NETIO and THINGSTUD.IO – all of these are viable methods – another that is coming up is Blynk – again very preliminary and I’ve reported lots of issues with this – but it works.

There are several useful controls – you see in the image above some simple LEDs (which can be set to various intensities though you can’t programmatically set the colour, sadly), some simple status outputs and two buttons (which can be set to ON/OFF or push to operate). They also have a controller called the zeRGBa which is a visual controller for setting RGB lighting. You see 4 of them in use top right of this article. You can basically move your finger over the control – which will then fire out RFGB values. Thankfully you can set the maximums as not everyone works in the 0-255 space. My PWM controls for ESP8266 use 0-99 for example.  This widget falls down currently in 2 areas, firstly you cannot SET it’s position – you can only use it as an output control. Secondly and arguably more importantly it sends out rather too many commands one after another when you move the unit around. I prefer courser control, smoothing the transition in my ESP boards.

So, given a control that fires out RGB sets rather too rapidly, how can Node-Red help. Thanks to the developers who I’m fortunate enough to get lots of feedback from, it’s actually quite easy.

RGB Control

Here we see 3 inputs from the App coming in via the Blynk Node. The first thing I need is a function to convert that data (a simple array of 3 values) into an MQTT statement to fire out.

msg.payload=”{rgb:4,” + msg.payload[0]+”,”+ msg.payload[1]+”,”+ msg.payload[2]+”,70,1}”;
return msg;

Easy enough – I set the topic for MQTT to my wall RGB ESP8266 board (the format is my own, don’t get hung up on that) and I use a message payload of say “{rgb:4,255,0,0,70,1}” – what the hell does that mean? Again my own format… the braces are there for technical reasons – my ESP boards accept MQTT or serial – and the ESP’s put out some crap at the beginning and debug info – so I wrap my messages in “{}” just as delimiters. So the actual message is “rgb:4,255,0,0,70,1” – which means – using output 4 of the ESP, send out RGB 255,0,0 (i.e. RED), smooth the transition from one colour to another over 70ms – and I can’t remember what the last parameter is – irrelevant here.

If you look at the code, what you’re getting from the Blynk node is an array (msg.payload[0-2]) so a simple substitution.

That one string goes out RATHER TOO QUICKLY on message after another for my little boards and I was wanting to slow them down just a touch. the DELAY node can be used for this..


Absolutely brilliant – so it will not allow more than 16 message a second – and if it gets more – it will drop some intermediates. Works perfectly – the actual rate of course depends on your project. I had utterly missed this – thinking that node was nothing more than a simple delay as suggested by the name – but dig in and it has so much more to offer.

So right now I can control several RGB devices around the house, limited only by the somewhat large size of the zeRGBa widget and the inability of BLYNK right now to handle several pages per project (though as of the other day you can seamlessly move between projects which helps).

In  case you’re wondering – the language used in the functions is JavaScript  – who’s ability to make life easy when it comes to handling different types of data such as arrays and JSON, is a wonder.  I look forward to the day we have a PROPER, fully working interpreter on the ESPs themselves.

Oh – and to run the Blynk server on your own kit – you need Java 8

apt-get install oracle-java8-jdk

And I made my blynk directory and those below it full read/write/execute.


The Boston Trip

beersolar binsSome time ago, the CEO of Espressif, makers of the lowest cost WIFI-enabled processor on the planet and a chip I’ve blogged about frequently in here, invited me over to MIT at Boston to the FAB11 conference with them. As it turns out this was a rather small affair featuring things like 3D printers and other fabrication equipment.

However the main point was to run a series of workshops on the MIT campus about the ESP8266 and so along with me were employees of Espressif including Jeroen Domburg (ES_-HTTPD) and also an independent like me, Ivan Grokhotkov (Esp8266/Arduino).

We arrived on Sunday in sunny Boston and of course the first thing that happened was that Iberia Airlines lost my large case complete with samples, laptop+presentation, clothing, pills, flashy LED ring I had such a hard time getting from China thanks mainly to UPS.

Simmons Hall or Stalag as I will no doubt remember itJust before arrival I’d received a note to say that due to flooding, my single room accommodation was to be “shared” – with someone I’d never met before. Ok, I’d emailed Jeroen before but I did stress to the staff at the hostel (or as I now call it, Stalag) that I really would like my own room – after all I hardly class as a student. I arrived and despite protests, no change – the place is run by mainly apathetic students or so it seemed to me. Now as it happens, Jeroen and I get on just fine and there was not a problem – but if this is typical of how they treat students – you can keep Boston hospitality – not even remotely acceptable. I would not put my cat in the room they gave us, essentially a rectangular concrete prison sell with 2 beds, Ikea wardrobes and 2 simple desks.

However, Jeroen turned up later than me on Sunday– near midnight and as technical people often do, the moment he walked through the door we started chatting about technology and I think we finally gave up around 1am.

We got along just fine.



MITIvan and Swee-AnSo first thing Monday I went off and bought a load of clothes. The Americans invented the term “convenience store” but I think they only meant that to apply if you have a car. Walking and taking the bus is not at all funny in the heat and so it was I arrived at the mall mid-morning to find the old American staples – CVS, Walgreens, Seers, J C Pennys etc..

I have to say for a country with some pretty large people I had difficulty getting clothes my size (at least with any choice) but finally came away at lunchtime armed to the teeth with new gear. As for Pennys – they don’t even sell plugs! Give me B&Q or Brico Depot.

I’m not sure what I was expecting at the venue, certainly organisation was high up there somewhere but inside MIT campus, 30 minutes before our presentation, no laptops – eventually they turned up in 2 black boxes,  half of the laptops with the wrong power supplies rendering them useless.

As it happens it was not a full house and so we managed just nicely – talking about ESP8266, MQTT, Node-Red and finally a little about ESP-Arduino to an enthusiastic audience.

MIT[6]Of course in each of the three versions of the workshops we improved and I have to say that by and large they went down very well. Clearly the organisers had done little to help promote us because I know the level of interest I get when I talk about ESP8266 and I was expecting a full house every time – still – all good fun.

Part way through the trip and in the middle of a heat wave, the heavens opened up and threw out some pretty amazing hailstones! I mean MONSTERS.

Myself, Jeroem Domburg and Ivan Grokhotkov spent much of our time when not investigating the city, in room E25-117 at MIT giving presentations and practical workshops to an enthusiastic audience – in the main with great weather, to boot. We demonstrated a NETIO page which I put together talking directly to a servo running under ESP8266-Arduino which Ivan put together.  I’ve documented this elsewhere here in at  We also discussed MQTT communications and more including my favourite topic – Node-Red.

We went out at night – the first walk was rather too far for my airplane-equipped feet and I’ve been hobbling since. Amazingly despite having a medical dispensary within MIT itself and a near by Co-op (or as the lady kept insisting COOP as in soup – I didn’t like to tell her the name is made from two words) – no foot fixing kit, so being the inventive type I went off and bought a box of cork tiles and a pair of scissors – and DIY fixed the foot which is going to need some tender care and a pin when I get back to Spain.

MIT[8]Just as we were finishing off, I received my case at long last, I should say thanks to Iberia but frankly I think they have shown themselves to be a bunch of complete tossers. Not only did they give me someone else’s reference number which confused the issue but the fact that I had important medicine in the case didn’t seem to phase them even slightly.

Had I fallen ill while away things would be very different now – as it is, lets see how promptly they cough up for the clothing and toiletries! They’ve offered 50 Euros per day – assuming I guess that everyone goes off and buys t-shirts  – in reality I needed decent shirts, trousers, underwear and toiletries so I can see a battle coming on featuring their social media.

PeteThe end result of all of this however is enlightenment and a pretty good time generally. I’ve met some great people and learned some new stuff. I’m now back in Spain with new ideas, some new thoughts on China having spoken at length to the Chinese guys here – and generally feeling that this was another worthwhile adventure.

I can’ wait to get back into the nice cool lake in Spain (I’ll never complain about cold water again) – heat can be a great thing but in a city built for commerce and not comfort in heat, give me the wilderness any time. Sadly right now in Andalusia it’s a bit foggy!

I’ve written a blog on on the work Ivan has done with ESP8266-Arduino  which I have to say is pretty good –  in our talk we drove a servo from a NETIO Android App – it is so easy it’s like falling off a log. For now, I’ll leave you with some photographs. My thanks to Espressif and to Swee-An for looking after me and providing thought-provoking conversation.







ESP8266 Arduino NetIO Server Demo


This week as regular readers know I was far away from our little home in Spain – in fact I was at MIT (Massachusetts Institute of Technology)  in Boston, helping promote ESP8266 technology (why? because I could).

IvanAlong the way I met up with Ivan Grokhotkov who as some of you know has done a lot of work to bring the Arduino environment to the ESP8266 community.  As part of what we were doing at MIT, Ivan and I decided to put together a simple demonstration – this would use NETIO (my favourite IOS/Android visual interface) and ESP8266-Arduino to help an ESP board drive a servo via wireless control. 

As it happens any old ESP board would do – an ESP-01 would be just as easy, however both there in America and here in Spain I just happen to have the NodeMCU boards handy and so this short blog will show this in action using pin D5 on the NodeMCU – but there is nothing clever about these boards – if you have something different, use it.

NETIO – so firstly what is NETIO? It is a very inexpensive APP for IOS/Android with a free visual web interface – I’ve discussed it before in here with examples. Essentially you create a free account at and having logged in, you go to the online design editor and put together your dream interface. In this case a simple slider to control a solenoid will do – but more of that in a moment. You then sync your phone to the account and the control page becomes available to your device. The point being it is just SO easy to make pretty interfaces.

ESP8266/Arduino – this is a free add-in for the Arduino environment (which in turn is also free) to allow you to compile C++ code for the ESP8266 chips – just as easily as if you were using an Arduino. Indeed with the nodeMCU board you simply plug it into USB, fire up the environment, fire up an example – and you are up and running. I believe the forthcoming (Kickstarter) node.IT boards will be similarly easy to use.

In my case I firstly downloaded the standard Arduino 1.6.5 environment to my Windows PC – I then followed the instructions on Ivan’s GitHub page – everything you need to know is included in his readme file so I’ll just take you straight there.

The example Ivan put together to control a servo is here.

The only thing you have to do to run this sketch is to put in the name and password of your router. Running the program and using the Arduino serial monitor yielded (in my case) this…


As you can see the little board immediately connected to my router which gave it the address of – this actual address will vary from system to system.

The demo program sets up a trivial web server which will work as follows: In a browser I typed and here’s what appeared in the browser…


Check out the example code and you’ll see where this comes from.  The next step is to add an argument to that URL – so let’s try (remember you likely won’t get that actual address)


You can see that the value has been extracted and passed back to the browser – meanwhile in the serial window…


What you don’t see is that on pin D5 of the ESP8266, a constant pulse is being sent out and this pulse WIDTH has been altered. Values 0-180 work and turn the servo from 0-180 degrees.

It REALLY is that simple to drive a servo – in my case the 3-wire DIRT CHEAP servo is a Turnigy TG9e with 3 wires – ground, power (3v3 in my case) and signal (D5 – but doesn’t have to be that pin).

So by firing the argument (value 0-179) as above to that address I can control the servo – how about doing this remotely via a mobile – for now we’ll assume internal addresses so this would only work within the area covered by the router… but I’m sure you’ve already considered world-wide servo domination.

The image below pretty much covers it – in the web browser I dropped a slider into the NETIO main screen.


The only thing missing here is the code for the slider. Click on the slider and…


(I’m pretty sure I should have made that max value 179 but whatever… it works) So I have set the slider to emit code /servo?value={value} where {value} gets replaced by the actual slider position as you run the app and move the slider around – add that to the address in the main panel and you have exactly the same result as we saw higher up this blog entering the value into a browser manually. Hence… here I am moving the slider around on my Android phone – the result in the debug serial window is:


And as this happens the actual servo is rotating back and forth up to 180 degrees. Whether this powers a piece of paper or a ton of concrete is down to the servo!!!

This is of course trivial – the same APP could control a whole HOST of sliders and the ESP8266 code could perform all sorts of transforms on that data – an ESP8266 spider could be fun (I got that idea from the giant cockroach which appeared on the floor while we were experimenting at MIT)! A nice addition to that code might be a timing arrangement to smooth the value change as moving your finger across a phone tends to produce slightly jerky results.  If you were using this for a window opener or other visual toy…..

When I get a minute I’ll do a video of this for YouTube – in terms of development, if you have everything to hand you could have this all running from scratch within 10 minutes, it is that easy.

My thanks to Ivan for bringing the ESP8266-Arduino environment to my attention – I talked about this ages ago when it was new but at the time was not that impressed – today – hell yes this is a very easy way to get quick results with ESP8266. If you have any code issues, Ivan is really approachable.



That’s it for now. Just back from the states to our little village and I’m thinking a pint is in order..


A new Day – A new Board

New dayWhile waiting we’ve done ourselves a new board – it’s not too obvious but under that power supply / dc/dc convertor area – are three MOSFETS for PWM use and we’ve added a connector so you could stick some RGB serial LED strip straight onto a connector.

GPIO16 is on there and on this particular board we have NOT shorted GPIO16 to reset so it can be used for purposes other than for SLEEP mode! The board is designed to take ESP-12s (or ESP12-E ignoring the new leads) but at a pinch could use an ESP-01 if all you wanted was a RELAY output and a sensor.  Before anyone asks – with the DC/DC convertor, the board with no lights attached uses around 100ma with 12v in.  The Tiny85 is there for interest only so some of those parts on the left would normally not be used. In a couple of of weeks we should have boards and get one built up – but 95% of the layout is already tested. More details on the main Home Control 2015 page.


New Board


ESP8266 SDK 1.11

Just a short one for those of you who’ve not tried the new Espressif SDK update yet (SDK 1.11).  I noted a pair of commands “system_param_load” and “system_param_save_with_protect” which appear to replace the need for the load and save functions that TuanPM uses in his code in /mqtt/config.c  – so for the sake of it I gave them a shot – and just to make sure, changed the location a little.  Originally TuanPm was using 3c and I’ve long since moved that up to 7c… well, of course the saving mechanism only uses three 4k sectors, so now I’ve moved it to 0x7d.

With the new base at 0x10000 and the code finishing in my case at around 0x43400, even on the humble ESP-01 that means there is now a WOPPING great 236k of FLASH left… can’t be bad. Tested, works a treat.

As I start to get to grips with the importance of ICACHE_FLASH_ATTR for keeping functions out of limited RAM until they are actually needed, would those who know agree that it is probably better to split up any large functions into smaller ones?  Presumably if not, when any function is called, the whole function ends up in RAM? Yes?


ESP8266 Test Board

I mentioned that Espressif were kind enough to send me a test board to play with – and very nice too. Not had time yet as I’m struggling with learning how to make an installer for my Node-Red package – with some great help from the guys involved with this….

So meanwhile here’s a lovely diagram – which I asked Espressif for specifically so you could see what the board does.

If you double-click on the image you will get a larger version. What’s really nice are the logical groupings. Not TOO keen on the tiny connectors on the right – but the main ones are 0.1” standard stuff. Quite looking forward to having a play.


ESP8266 Development Board