A non-trivial ESP8266 project

If the name Aidan Ruff rings bells with you, it’s probably because of the frequent mentions he receives on Pete Scargill’s blog and for his designs of their “Hackitt & Bodgitt” series of ESP-based hardware (Aidan’s board designs, such as "Hackitt & Bodgitt" Nextion Display Boardthis ESP12 board aimed at supporting a Nextion display, are especially useful for general purpose ESP8266 development and he makes the files freely available on-line).

Aidan is in the process of having an old farmhouse (in an olive grove in Spain) rebuilt and, because there are no mains services (electricity or water) available, has embarked on what, to most of us, would be the non-trivial project of providing enough solar (and possibly wind) power and enough battery capacity to provide summer cooling and winter heating without having to resort to the use of a generator during prolonged, adverse weather conditions.  His outline plan on how he intends achieve this (along with some impressive floor-plans) are available on his “Off Grid in Spain” blog.

Of more specific interest to ESP aficionados though, is the solar-tracking sub-project he’s put together to ensure that the (MPPT) output from his panels is maximized by adjusting elevation and direction.  The tracker controller is an ESP8266-ESP12 of course, but with a novel twist.  Instead of using the tried-and-tested optical tracking method (with its inherent problem of “hunting” on overcast days), Aidan has hooked up a GPS receiver to the ESP and uses a combination of the precise time and positional data to compute where the sun should be in the sky at his particular location (whether it’s hidden by clouds, or not).  The ESP communicates via MQTT (but also has an embedded web server and an attached OLED display panel), which means that, with additional data from a connected weather station, Aidan can add features such as having the solar panels rotate down to lie flat when the wind speed exceeds a pre-set limit.

The initial prototyping and testing of the two-axis, linear actuator based tracker is already completed and Aidan has put up his board and mechanical design files and a couple of videos on a Hackaday I/O project page.  Unfortunately, at the time of writing, the ESP code doesn’t seem to be available either on that page or from Aidan’s GitHub repository, but despite that, it’s definitely a project worth watching (tracking?).


A wee bit late for Xmas, but…

Here’s a very seasonal item, courtesy of Hackaday  …Sean Hodgins’ ESP8266-enabled Xmas ornaments.  They’re worth checking out for the really neat, multi-coloured PCBs (although I’d probably decide to do without the piezo speaker if I were to build any).

Sean Hodgins' Xmas Ornaments

No word yet on where Sean sourced the PCBs, or on what the battery life is like (even with deepSleep(), not long, I’d guess).

Sean’s GitHub repository has all of the code, if you fancy knocking a couple of these together on Xmas morning.

ESP8266 for the Pi-Zero

Lots and lots of breakout boards recently …but here’s an interesting looking PCB with a slightly different target — to enable WiFi on a Raspberry-Pi Zero.

ESP-12 to RPi-Zero adapter board

It’s obviously an adapter board which would plug directly onto the Pi-Zero headers.  Unfortunately, there’s no further info on the OSH Park page and an Oogleg search doesn’t find anything related, so if anyone knows “Eikacy” or has any other info on the project, please do let us know in the comments field (below).

Update:  As “Gon” points out in his comment below, this is a derivative of Andrew Litt’s RPi-WiFi project (which I certainly remember reading, but don’t recall having seen the original PCB).  All of Andrew’s original work is from his “esp_hat” GitHub available repository.

Anthony Lieuallen has also produced another version, based on Andrew’s original.

And another one for the ESP32, too


Explore Labs ESP3212 breakout board

Just in case you’re looking for a breakout board for your ESP3212 (rather than the boring old ESP8266), Tindie has you covered for that, too.  It doesn’t have the neato prototyping area that our previous offering had (in fact, as far as I can see, it doesn’t have anything at all, except for 0.1″ spaced connectors for all of the ESP32 pins), but it is considerably cheaper, at only $1.49 plus postage.  Of course, first you need that ESP3212.

Another nice breakout board on Tindie

McUdude Breakout Board

This one caught my eye recently, mainly because it’s so versatile.  It accepts several flavours of ESP8266 module, has two voltage regulators to support different input voltage options and also has a prototyping area.  The prototyping area is nicely laid out, with ground and 3v3 rails running up the middle and the broken-out GPIO connections from the ESP lined up along one side.  The only down side is that it is a touch expensive, at $9.90 plus shipping for the populated board (not including an ESP8266 module).  It’s available now on Tindie, shipping from Norway (which unfortunately adds $4 to the price for my particular location).

ITEAD Studio delivery

Well, I can confirm that, for Japan anyway, delivery from ITEAD Studio is much faster than the normal Middle Kingdom standard (wait, wait, wait some more, then wait).  I ordered some bits and pieces from them on Monday (which was the first normal work day for them after their new year’s holiday) and the parcel arrived on my doorstep here in deepest, darkest Nagano at lunchtime on Saturday.  I had to sit down and have another cup of tea.

I was pleasantly surprised by the fast delivery and also fairly happy with the contents of the parcel.  I’d ordered a few of their AC to DC isolated switching supplies based on the iW1700 chip, along with a “Sonoff” ESP8266-based WiFi mains switch module (the non-RF version …it doesn’t have the optional 433Mhz card or a key-fob remote control).  I expected the PSUs to be small and I wasn’t disappointed, but what did surprise me was how tiny the Sonoff unit was.

Small hand, smaller Sonoff
Sonoff is tiny!

I’ve got very small hands, by the way (and probably none to clean either, come to think of it), so just image that it’s about one third smaller than the impression you’re getting from the photo.  The screws in the mains connectors are too small for a general-usage small bladed screwdriver and need a smaller “precision” type.  The box which the Sonoff came in was actually smaller than the boxes for the (tiny) switching PSUs, which had me thinking that they’d mixed up my order quantities, until I opened them.

I haven’t used either the Sonoff or any of the PSUs yet, so this is very much just first impressions.  So first, here are the PSU photos (click on them for larger images):-

From the top you can see the switching transistor nestled between the transformer and the 400v electrolytic capacitors.  The pins closest to the camera are the output side, with the middle connection labelled as 3v3.  However, there is actually no pin in that position and, although there are pads for a regulator on the bottom of the board, it isn’t populated either.  It looks as though it would be fairly easy to add a regulator in there, but as there are no pads for capacitors, it would be just as easy to put the regulator and caps on the target PCB instead.

On the photograph of the bottom side you can clearly see the slot underneath the transformer between the primary and secondary side which also runs across almost the full width of the board, providing galvanic isolation between the mains input and 5v output.  The iW1700 is the six-pin chip you can see underneath the transformer,  but on the primary side of the isolating slot.  It gets current feedback from a sense resistor connected to the emitter of the switching transistor and voltage feedback from a separate primary-side winding on the transformer; there is no feedback path from the secondary.  The two larger resistors at the extreme right of the photo are marked “155” (that’s 15 + five zeros, or 1.5 megohms) and they’re wired in series to give a very high impedance “bootstrap” supply to the iW1700 (this one of the area where the ITEAD design differs from the reference design – the reference uses a smaller limiting resistor and a “normally on” depletion mode MOSFET connected to the “active start-up” pin of the iW1700, so that once the power supply has bootstrapped itself the power flowing through the bootstrap resistor can be turned off).  The big, square, four-pin block next to the input pins is the bridge rectifier.

This isn’t a particularly efficient supply for a switcher (running, according to the design sheet, at roughly 75 to 80%, depending upon the combination of input and output voltages), but it does have a remarkably low quiescent current under no-load conditions, so is pretty good for something like a phone charger where the load will suddenly drop off (at full charge), but where the unit itself may remain connected to the mains supply for long periods.  Similar conditions might be found when providing the supply to  an ESP8266 which operates normally for a while and then drops into sleep mode, so it’s no huge surprise to find that ITEAD use virtually the same circuit in their “Sonoff”, ESP8266-based WiFi mains switch.  Looking at the photos of the (shockingly naked) Sonoff we see some very familiar components (again, click for larger sized images):-

Looking at the bottom side of the board, you can see the square block of the bridge rectifier at the top, left-hand corner and then slightly below and to the left our familiar “155” resistors (labelled R16 and R17) with the 6-pin  iW1700 chip sitting over to the left and slightly higher, labelled as U12.  The right hand side of the board is almost entirely given over to the ESP8266 (note the antenna at the extreme top right) and the tinned bus bars connecting the output screw-down connector to the relay and input side.  The empty row of holes slightly to the right of centre bottom are where the 433Mhz RF module sits (in the more expensive remote control “RF” version).  Over on the photo of the top side of the board the same row of empty holes can be seen slightly right of centre closer to the top edge of the board.  Just below them is an unpopulated pad for a QFP chip, labelled as U5.  That’s for the 8051-based “Busy-Bee-1” chip, which appears to handle the control of the 433Mhz module on the “RF” version.

Further down at the bottom of the photo and further to the left of centre is the (yellow) transformer for the power supply and you can clearly see the switching transistor sitting just to the left of it.  The big black box with the white paper label is the relay which switches the output load.

Backing up just a little bit, you’ll note that I said I was “fairly” (not “ecstatically”) happy about the contents of the parcel and the photo of the bottom of the Sonoff board shows why.  If you compare the photo of the PSU board and the PSU section of the Sonoff board you’ll notice a couple of things.  First, the PSU PCB has an isolating slot between the primary and secondary sides of the transformer, while the Sonoff doesn’t.  Second, the iW1700 chip is under the transformer, but on the primary side of the slot on the PSU PCB and, while it’s in the same approximate place on the Sonoff, it has been rotated 90° so that the tracks from the pins now come out towards the secondary pins.  Mmmm, not so good.

Don’t get me wrong.  This is still an isolated supply (the transformer and the winding on the relay both provide isolation to the ESP8266 circuitry), but I don’t believe that the “Sonoff” would pass regulatory inspection in the U.S. or in Europe (the fact that it has screw-down terminals instead of a molded-in power outlet probably makes the PSU issue a moot point, anyway).

Would I use the Sonoff myself?  Heck yes!  I’ll probably buy some more of them, too.  I’ve built much worse things myself (think full-wave rectified 240-volt mains with thyristors on stripboard and run away, screaming), although admittedly, I didn’t sell them as products.  The Sonoff will enable people with minimal knowledge or experience to put together an IoT set-up relatively safely (without having to resort to the horrible mix of stripboard and mains) and, whatever its faults, it is orders of magnitude better than any of the duct-tape-and-hot-glue IoT instructables out there.  Going back to my initial impression, it’s also small.  There are lots of places where a Sonoff would fit in unobtrusively (behind your TV, in an equipment cabinet) where it would save the trouble of needing to be physically there to simply power-cycle some errant piece of electronics.  It looks like a winner to me and that’s even before you factor in the ability of most ESP-aware folks (that’s you) of being able to reprogram the on-board chip to talk MQTT.

Update – See the newer post “No-Phone Sonoff stuff” for more information on loading an MQTT capable package onto the Sonoff.


Yet another offering from AI-Thinker

Well, like just about everyone else in the world, I’ve been waiting for the Middle Kingdom new year’s holiday to get itself over with so that we can get back to ordering stuff in the hope that it’ll turn up in just a couple of weeks, rather than a month or so.  Much to my surprise though, the postie dropped off a little package for me today which I had pretty much assumed hadn’t made it out of the starting gate before the beginning of the holiday.  My second surprise was that the boards in the packet actually worked, right off the bat, without the involvement of soldering iron, boot or hammer.  I was so shocked I had to sit down and settle my nerves with a little drink (luckily the teapot was already warmed, as we’re right out of Scotch).

I’d taken a chance and ordered another couple of AI-Thinker boards, working on the principal that nothing could be as abysmal as the initial experience of the “T5” and, as before, based on the fact that the cost of each board was significantly less that the cost of the components if I were to buy them separately.  These boards are generally referred to as the

Yellow Serial Development Board
AI-Thinker “Yellow Dev Board”

“Yellow Development Board” (or sometimes, “Plate”) and have been available for quite some time (longer than the “T5”, I think).  They come with an assortment of LEDs (most of them tiny little surface-mount parts, but also one ginormous, RGB, through-the-hole jobbie, too), a CDS light sensor (tacked onto the ADC pin), an on-board HT7333 low-quiescent-current voltage regulator, a battery box (3 x AA cells), a jumper to enable programming mode and an ESP8266-ESP12.  One of the neat points of this board is the fact that all  of the ESP8266 pins are available on header pins on the top side of the board and there’s also a separate programming header (which, unfortunately, seems to be incorrectly labelled on the silk screen, with the TX and RX pins reversed when compared to the ESP8266 header pins).

The board comes pre-loaded with a demo which does actually seem to work.  If you have an Android based phone or tablet you can download AI-Thinker’s app to control and mix the colour balance on the RGB LED and to switch the other LEDs on and off.  All very much better than the “T5”.  There are a couple of reviews out there already (here’s Marco’s short video review).  One of the better ones was written by Squix, way back in January of 2015 (I told you this one has been around for a while), including a very nice labelled photo which shows the correct pins on the programming header.

So, why the interest in an old board?  Well, first off, after my bashing of the newer “T5”, I wanted to be able to recommend an AI-Thinker board which is actually functional and good value.  This board is still readily available from lots of sellers and is a cheap way to get your hands on an ESP12 .  As it stands, it is a functional, nifty demonstration of what can be done with a single ESP8266 and a couple of AA batteries.  It is also readily reprogrammable via the 3-pin header to run your own firmware (how about a novelty night-light toy for a child …run a simple light display for a while, sleep for a random amount of time, display, sleep, display…).  Anyway, it seems as though the board would make an excellent platform for hacking into more useful devices, especially as all of the I/Os are split out already.  Adding a few sensors and MQTT functionality should be fairly easy …and that’s what I’ll get into next time.

Update:-  Just to show that you don’t need huge amounts of work to get a small project working …here’s one of these boards with an ENC28J60 module simply wirewrapped to the existing pins (8 connections in all), serving web pages, courtesy of Cicero and Sprite_tm.

Reworking the AI Thinker T5 – Part V

For this instalment of the rework series, we’re going to keep things simple and only do one, relatively straightforward modification.  Although there’s only one goal, it’s a relatively important one; we’re going to update one of the switches on the T5 board to provide “program” functionality for the ESP8266.  In other words, holding down the switch when you power on the board will put the module into programming mode.

The switches on the board are labelled as “K1” and “K2”.  It turns out that, after a little probing with a meter, the schematic provided for the board is incorrect, in that it shows K1 as being connected to pin-4 of the QFP chip and K2 as being connected to pin-5.  This is actually the reverse of the physical connections on the board, which actually has K1 connecting to pin-5 and K2 connecting to pin-4.   While this is immaterial in the context of this rework, it might be useful information for anyone (AI Thinker?) still trying to struggle along with the original QFP 8051 chip (I should probably add here that, despite all of my AI Thinker “bashing” in this series of posts, the vast majority of the ESP8266 modules which I own were manufactured by AI Thinker and the vast majority of them are actually great products …it’s only this one that turned out to be a stinker).

When you look at the T5 board, one of the things which is very noticeable is that there are some tiny vias and traces on the board which are signals and there are other, much larger, vias and traces which are dedicated to the power rails.  This is standard practice and it also simplifies the work of tracing signals and connections.

“K1” Switch Wiring

It also gives another couple of options when trying to formulate a rework plan (how best to physically connect and route wires and place components) to give us the least amount of work for what we want to achieve.  I this particular case, a via provides a useful connection to the 3v3 supply line on the top (component) side of the board in a location which is almost ideally placed; very close to the K1 and K2 switches.  For this modification, we’re going to provide a pull-up resistor on the GPIO0 line and connect it to the K1 switch, which will become our “Program Mode” switch.  Because the via is so well placed, we’re actually going to use it to provide a second pull-up for K2 as well, but we’ll leave the actual implementation of that second switch for a later article (K2 will become the “User” switch).  So the first part of our rework modification is to add a couple of 22K resistors (this value isn’t critical, but 22K is a good compromise between stability and current draw) between VCC and the switches K1 and K2 (the other side already being connected to ground).  Looking at the photograph above, the ground connections are one the two pins of the switches furthest from the edge of the board (the pencil drawing to the left of the board shows these connected together in a continuous line).  The logic signal connections go to the two pins on each switch closest to the edge of the board.

Pull-ups first …grab two, 1/8 watt 22K resistors, hold them side by side and wrap a couple of turns of one lead from one resistor around the (still straight) lead of the other.  Solder the wrapped joint and trim back the bent lead to make it tidy.  Locate the VCC via on the board between switch K1 and the QFP pads (click on the photo above to see a larger version).  The via has a trace running to pin-10 of the QFP, so it’s easily identified.  Scrape the via clean (if needed), so that the copper is visible (a small, cross-point “plus” driver will work for this).  Bend the soldered leg of the resistor pair to a 90-degree angle, push it through the via and solder in place.  On the resistor which is closest to switch K1, cut the lead short (about 4mm), bend it into a “U” and solder it to the adjacent pin on K1 (again, see photo for details).  The long lead on the remaining resistor should be neatly bent clear of the metal casing of K1, parallel with the edge of the board and soldered to the same pin on switch K2.  You now have pull-ups on both switches.

That was the easy part.  The next bit is a little fiddly (which is why we’re only doing one).  Take some thin, single strand wire (insulated wire-wrap wire is a good choice, you might want to try varnished bell/coil wire if you’re confident that you can get the varnish coating off to tin the end reliably).

“K1” Switch Wiring

We’re going to join switch K1 to GPIO0, so you need to solder one end of the wire to the second pin in on the corner of the ESP8266 next to the DHT11 sensor (I take issue with the pin numbering on these modules …if it was an IC and the antenna was the notched end, then it would be pin number 8.  If that doesn’t make any sense to you, just check the photo instead).  Note that we’ve already, in a previous posting, connected the adjacent pin, GPIO2, to the DHT11 data pin, so you  should now have two wires next to each other.  Route your new, GPIO0 wire under the DHT11, down along the side of the jumperblock and then solder it to the pin on K1 which is opposite the pin where you connected the pull-up resistor earlier.  Tack your wiring down with a couple of small drops of “Super-Glue” (if they sell it where you live …in my country of residence it’s actually an illegal substance — dunno why* — so I use toe-nail** pairings from a hot-glue gun stick, melted with the soldering iron onto the wire***).  Check your work with a meter and hopefully you’re good to go.

Why didn’t we wire up K2 as a “reset” switch?  Well, there’s already a slide switch in the supply line on the T5, so we can save switch K2 for use as a user-defined input device (yup, a “switch”).  To use your new program switch, simply turn off the power to the T5 using the slide switch; hold down switch K1 and then slide the power switch back to the “on” position.  You can let go of K1 pretty much immediately.  That’s it, you’re in program mode …you can throw away those fiddly jumpers now.

For our next instalment, we’ll be adding long jumper wires (now that you’ve got the hang of it) to connect up the green and red LEDs and updating our program to implement a spinning colour wheel.  Whee!  Blinkenlights!


  • – Perhaps the powers-that-be are scared that people will glue all of the politicians’ mouths shut.  🙂
  • Don’t use real toe-nails!
  • Don’t breathe in the fumes.  Do clean the tip of the iron ASAP.

Reworking the AI Thinker T5 board – Part IV

I noted last time round that I wasn’t too happy with either the relay, or the red LED on our modified board, so this time we’ll take a look at the simple butchery updates needed to eliminate those particular issues, as well as updating the the hardware and the software to do something a little more useful with the board (and noting another couple of issues which cropped up along the way).

First, it’s time to heat up the soldering iron and get out the de-soldering pump again.  That relay and the associated screw-down terminal block have got to come off (the more I look at this thing, the more the idea of someone being tempted to connect mains up to it for an IoT lightbulb gives me the screaming heebie-jeebies).  The red LED is fairly inoffensive, but seeing as it sucks battery power, it’s “off with its head!” there, too.

Red LED – There it was, gone!

While the LED just needs some gentle coaxing with a hot, small-tipped iron, the relay and the screw-down block do need some serious heat to de-solder the pins, so don’t expect to do the job with a 15w Antex (nice though they are) and some pre-used solder braid.  If you have one of those neat, refillable gas irons (the ones which have a catalytic heating element and run on butane lighter fuel), this is exactly the sort of job you bought it for (but a 60w rated electric iron will work, too).  Use some flux if you have it, or a tiny bit of cored solder if you don’t, so that the joints are well “wetted” before applying the de-soldering pump.  In this case (as we’re not planning on replacing, or ever using those components), it’s also acceptable to use a flat-bladed screwdriver to apply some mechanical force to the de-soldered pins to pry them away from the side of the hole (this can break the through-plating on pin holes, so don’t ever use this technique when replacing components on multi-layer boards).  When in doubt with this particular board, brute-force and ignorance are the order of the day (just remember that incessant beeping and act accordingly).

Relay/screw-down removed

The end result of these mods is some extra space on the board and a drop in current consumption, too.

Keen-eyed readers will already have noticed the ugly, short yellow wire visible top-centre in this photo.  It’s a quick link I added between GPIO5 on the ESP8266 and the blue LED on the board, just to give me some extra debugging and a visible indication that the board is powered (the code in the previous article already has a few lines in there to give this LED a very quick multiple flash when power is first applied and a single short flash when the DHT11 is accessed).  Note that in the photo above, the DHT11 is now standing up vertically on the board.  This is because the heat from the ESP8266  was adding about 3C to the DHT11 readings after a few minutes of continuous use (no wonder the batteries weren’t lasting long …we were powering a space heater!).  The second part of the fix for this issue was to add another, short jumper (not visible in the photo above) between GPIO16 and the reset pin on the ESP, to enable wake from deep-sleep.  Now we can have the ESP wake itself up, take a temperature reading, then connect via WiFi to send the data to an MQTT server before going back to sleep.  Wow, something useful!

Before getting to the software, I should mention the second issue I found with the hardware (the first was the poor positioning of the DHT11 right next to the warm ESP8266).  While I was levering junk off the board with a crowbar and blowtorch, I also did some preliminary investigations into the feasibility of using the tact switches, “K1” and “K2” as reset and program buttons for the ESP.  I was looking at whether either of them had tracks or vias which were close enough to the ESP to make wiring them up quick and simple (the quick and simple answer to that is “No”).  It turns out that the silkscreen on the board and the schematic do not match.  Switch K1 is shown on the schematic as connecting to pin-4 of the QFP chip and K2 to pin-5.  In fact (on my board, anyway), it’s the other way around; K2 connects to pin-4 and K1 connects to pin-5.  That information might be useful if you’re planning to do something with K1/K2 in the future (or if you’ve got an original board which, for some obscure reason, you haven’t butchered or stamped-into-the-ground, yet).

Here’s the link to the next (short) article in the series, with the software description.


Vinduino (with added ESP8266) wins Hackaday “Best Product” prize

Regular readers of Hackaday are probably already aware of the Hackaday prize competition, where readers are invited to submit their own hack or design to win a grand prize.  This year’s competition also included some extra prizes for specific categories and Hackaday have just announced that the “Vinduino” project is the winner of the “Best Product” category.

Vinduino is a project which I’ve been following with interest, as it centres around automated irrigation of a vineyard and I happen to be a fruit farmer who has irrigation problems (usually solved with a big water tank and lots of buckets) and also grows grapes as a major crop (though not for wine).  Reinier van der Lee has  put a lot of effort into experimentation, production and documentation of his project over the course of the past year and has now reaped the reward in the form of $100k cash funding, as well as a full year of residency at the Pasadena Supplyframe Design Lab, to get his project developed into a product.

Vinduino_R PCB imageAs you’d expect from the name, the project started out as purely Arduino based but, as with many projects over the past year and a half, has managed to incorporate an ESP8266 along the way for internet connectivity.  Although using an ESP-01 connected to an Arduino Pro-Mini and using the AT commend set is unlikely to have any of our more seasoned readers sprinting for their soldering iron, it’s worth noting that this is a working project with PCBs available on-line (from our friends over at OSH Park) and full code from GitHub, so you can replicate it and have it working in a very short time.

Very many congratulations to Reinier for a well executed project and a deserved win.  I look forward to seeing the finished products and will certainly be breaking out the plaster-of-paris over the slower winter months to try my hand at his version of soil moisture sensors.