ESP8266 Current State of Affairs

As the weekend begins, here’s where we are as far as I can tell with the ESP8266 WIFI board. The LUA-based software I refer to elsewhere is showing promise. I could not get the web client to work (first thing I tried) but I’ll try again this weekend. I have questions.. Why only 9600 baud, how much space is available for programs in there, how much space for variables?  I’d be happy to put a board together to expose the remaining pins on a 0.1” header if I thought this was viable.  Then there is the “Frankenstein” firmware also referred to in another blog item here. I get all manner of strange control characters appearing when I use that (as well as valid data) and I can’t get it to connect to my routers. I’ve commented twice but the author either isn’t getting my comments or figures I’m too thick to respond to. And then there is the original v9.2.2 software from the designers. That is the ONLY software to date that to my knowledge actually works, BARRING the “busy…s” problem, which may or may not be less prevalent at really high speeds but really does need fixing – and of course, “Chinglish” messages like “no is fun” etc.

So with the original software I can make a simple on-off light app but I would not want to rely on it – using a simple TCP socket. With the other two sets of firmware I’m not yet able to make a decent application. It’s so frustrating as the little boards have so much potential (not to mention any boards we may make ourselves). I have a Windows-based compile setup but the last part of it will not work – I finally figured out that you have to set the path THEN open a DOSBOX… and so now my computer knows about the ESPTOOL but..

Before I twigged..

Dodgy ESPTOOL

And now..

ESPTOOL SAYS NO

I’m hoping the weekend brings more improvements and will report back if I spot any. Meanwhile if anyone has any idea what’s wrong with the above image… do let me know.

Advertisements

ESP8266–An Interesting Development

Updated Sunday night:

I got up this morning to see if my ESP-01 board now set to run at 57600 was being any more reliable, constantly polling the state of an output and sending it back over WIFI… erm, no, the board had reset for some reason. Still struggling with the official software. Anyway, I thought I’d scan the web to see if anything was new. I’ve been using Google since it was invented and I’ve only just discovered the option to see only what’s new (I know, sad).

Anyway, I stumbled across this link – something called esp8266-frankenstein – “alternative firmware for ESP8266 modules”. In there is a BIN directory and in there are two .BIN files. I took my new FLASH DOWNLOAD_TOOLS_V0.9.2 tool (for Windows) using PYTHON (essentially loaded Python onto the PC (couple of button presses) and run the code… that lets me download multiple .BIN files onto the ESP8266 boards… I’d never had any luck up to now but then, these two .BIN files load at 0x00000 and 0x40000 respectively. I punched in the information and… GOOD GRIEF – it worked.

tmp6CBCThis is completely new software for the ESP8266, it says “release candidate”, Andrew has even made a very nice prototype board up to add reset and other bits to the board… but up to now I can find zero documentation because there isn’t any – this is in fact just very early alpha stage software – but apparently an update will appear late tonight – worth keeping an eye out? The new software does not use AT commands, but has a pretty verbose setup… here it is in action when I type help. As you can see, nothing like before. When I asked it to show a list of access points, it showed a disappointing one access point (normally shows 3 or 4) but I’ve no way to understand right now why the discrepancy.  If you’ve figured out how to blow .BIN files into your #esp8266 board you’ve nothing to lose but time by having a look at this to see if it has wings.. and it is Sunday after all. As things stand, the commands are indecipherable to me but then it may be this is some standard I’m not aware of – or maybe I’m just missing the point.

Has anyone else spotted this software (well, you have now)? At least out of this I got the confidence that the Python-based chip blowing software actually works so if nothing else that’s a plus.

As an update, a new set of binaries were uploaded tonight and some instructions – but this loops permanently for me – I’ve been in touch with the author and as soon as I get it working (next iteration hopefully I’ll try some simple TCP/IP socket commands – if this works – could this be an alternative to the buggy AT command set??? Time will tell.

ESP8266 Alternative?

USR-WIFI232-TThe ESP-01 and similar boards offer a great hope to many in terms of offering cheap WIFI for low-cost projects. Certainly at around £3 if they ever work correctly they will be amazing – up to now there are lots of –people talking about them, there are several projects out there but the software remains buggy and no sign of the manufacturer fixing it.  So are there alternatives? Sure – if you want to pay – but then that quite defeats the object.

Here’s something – I’ve no tested any of these but they’re worth a second look. There’s a blog on the subject of the USR-WIFI232-T here (shown on the image on the left) and an Ebay link here. Personally for now I’m sticking with my ESP-01 boards in the hope we can sort out issues with them – but the boards referred to here look like they are streets ahead technically in that they have their own proper setup pages. See the blog for more info.

Right now the the ESP8266 has no ability to set  a fixed IP, it has no web based user interface and a myriad of little bugs and semi-English mistakes – if you need something better then the USR-WIFI2323-T may be at consideration but at well over twice the price and needing an external aerial, no these are not a direct alternative – but for some they might be the solution to a problem! Enjoy… 

ESP8266 Woes… a Ray of Light

tmp7BABSo I’ve been continuing to test the Espressif (manufacturer) ESP8266-based WIFI module called the ESP-01 and I’m starting to get somewhere with the “busy s” problem. This board is the more common of a few variations of the board and has power, ground, transmit, receive and 4 control lines called GPIO0, GPIO2, CH_PD and RST. The board runs on 3v3 and consumes up to 250ma (note that some of the smaller Arduino-type boards which have 3v3 power supplies internally, cannot supply this much current. Better to use a 3v3 regulator capable of handling much more. I use one on my home-made Arduinos which can handle up to 1 amp.

Some more hardware info – the pins are not 5v tolerant… clearly the output TX can be connected directly to a 5v Arduino input but you need level conversion for output from Arduino to the WIFI board. I use a resistive divider. 560r from the Arduino output to the WIFI input and 1k2 from there to ground. In normal use including programming you only need 2 of these dividers. This fellow gives a lot more info on hardware.

I’ve done some in-depth tests with an Android mobile phone (Samsung S4)  sending commands to the board over a WIFI TCP socket (using NETIO) – and monitored what happens (I use a 1284-based board so I have 2 serial sockets – AWFULLY handy for testing but you could do similar with a bog-standard Arduino). While the phone was sending polling commands constantly, all was working well, until I swapped apps on the phone (or shut it down or had an issue with WIFI signal)  in which case it might only get part way through sending the command.

You CANNOT avoid this happening with WIFI by the very nature of it being wireless, there might be a glitch, might be a lack of signal momentarily, interference etc., there will always be occasions when you lose data.

Rather than recover gracefully, the ESP8266 (I imagine) has a flag set to say it is in mid-command… as it pulls in data. A new command coming in is NOT clearing that flag (this is a sheer guess) and so no matter what you do it will just say “busy s” until you reset. One kind gentleman has added a blanket reset command to the ESP8266 but that’s not the answer as you then have to wait for the reset and set up your modes again – what’s needed is for the designers to fix this bug.

SO yesterday afternoon I wrote to them, not very hopeful as I figured they’d be Chinese and might not even understand what I had to say.

Imagine my delight when this came back from ESPRESSIF  – a lady by the name of Sue Chen….

Dear Sir,

Thanks for contacting Espressif Systems!

This is due to a software bug. We will fix this bug in a software release soon.

Have a great day! Thanks.

Best regards,
Sue Chen 陈思祐

ESP8266 typical pinsThis not only confirms that it IS a bug as I thought – but gives us hope that they will soon sort it out – I’ve asked ESPRESSIF to let me know when the update is available and I’ll be sure to put the info in here (make sure you follow my blog – there’s a “follow my tech blog” blue indicator on the upper right of the blog screen).

In the early hours of this morning, I received another email from them asking for debug info – basically which version I’m using – I told them 0019000902 which is the latest though I’m not sure now if it’s the official latest number, as my version has the AT+XRST command which was added by a third party (detained in this or previous blog items)… which WORKS but really you don’t want to be resetting the unit as it takes too long and happens too often.

tmpC37ESPRESSIF confirmed that the issue is incomplete commands – I suggested that such commands should be quickly timed out… you might even be sending data with AT+CIPSEND=ID,value,data and if it’s a mobile device sending this, it could fail at ANY point… the ESP8266 needs to recover from this rapidly and move on without losing the current mode – this should be simple enough – if I were designing this I’d simply time out commands. So let’s say you are talking to the board at 115k baud, that’s 10k characters a second – let’s say 1k characters a second to be charitable… so if there is a gap of say 1ms or more mid-command, or an unexpected character then the unit should simply wind back and start looking for AT….  I believe this would solve the problem…

I’m getting excited already…I could be using these boards in so many projects…  #ESP8266  #ESPRESSIF #ESP-01

Further back on this blog you’ll see other items on the subject of the ESP8266 as I fumbled my way along with very little info. There is also some technical blogging regarding Arduino and similar on my home blog

There is some code for the ESP8266 on this blog for the Teensy 3.1 …   http://forum.pjrc.com/threads/26873-ESP8266-with-Teensy

123D Circuits for a bit of fun

If you want to have a little bit of fun with electronics and basic programming without actually having to buy or make anything, head on over to 123D circuits website where they have an emulator for the Arduino Uno and other chips and components. You can even write a program and run it on your virtual breadboard.  It’s no perfect, the fact that the microchips run on a 9v battery whereas in reality they’d blow up at somewhat over 6v – so you have to give them a little artistic licence (though WHY they picked a 9v battery I do not understand)… In this example, I originally made a simple traffic light sequence but then ramped the speed up to 1Khz and according to the virtual scope, it’s still working – all this in a web page for heaven’s sake!!

Good fun with meters, scopes, pushbuttons and more.

tmpD06B

Controlling WS2812 LEDs

I thought this might come in use for people wanting to simply control a strip of WS2811/2812/2812B LEDS. This is not all-singing – you can control individual LEDS but the fancy stuff you’ll find elsewhere.  In my case I wanted to smoothly update a whole array of these things in a home control board using the minimum of room and having to do the least setup or re-programming.

I’ve been using the ADAFRUIT library for some time – that is all singing – but.. it also has bugs. I found when adjusting colour and brilliance of strips of LEDS at the same time there were inconsistencies – also the library was using up a lot of space I could not afford. So I went off looking.

I stumbled across THIS library.

https://github.com/cpldcpu/light_ws2812

You’ll find if your needs are simple this does a lot of what you want – basically you define an array of LEDS – set the colour for each one – or the lot in a loop – and call the update routine – no setup for different types – it just WORKS and works quickly and takes up very little room.

But it was a TAD too basic. So I added some stuff. I wanted to be able to dynamically adjust the number of LEDS without reprogramming the chip. On inspection the room for each led (3 bytes per LED in RAM)  is MALLOCed… so a simple addition to the library…

Add this to the public definitions in the header

image

and some code into the main SW2812.cpp file..

tmp7B7F

And that’s it – so now you can change clear an array of LEDS to off – OR specify an RGB colour for the lot.

All of that was fine – all I needed now was a routine that could be called in the background…..

I have a byte variable which contains the brilliance of the strip – and another which contains a colour from a FLASH-based lookup table…

For historical reasons these bytes are called neocol and neobright.

Here’s the lookup table – you don’t need it of course but I was short of room.

tmpD7A4

 

And here is a routine you might call – every few milliseconds – to arrange smooth change of colour and brilliance to your array as you set those two values…

tmp1C33

I hope that proves useful to you – compared to similar code using Adafruit I gained over 1k of code space back and it does a smoother job.

100,000 Hours Bollocks

As someone who’s used LEDs both professionally and for my hobby since, oh, the 80s, I’ve always had my suspicions about WHITE LEDs.

As you may know, WHITE LEDs differ from the rest in that there is no such thing as white – it’s a combination of wavelengths, unlike blue or green or red… so in order to make white LEDs you can either:

1. Put a phosphor on a blue/UV led

or

2. Make a die with red, green and blue close together on the same chip and run them together with the right proportions

Mostly we chose (1) and for some time now manufacturers have been belting out WHITE LEDs en-masse without regard to lifespan – merely quoting the ideal-case figure of 100,000 hours in most cases.

But a trip to MAPLIN or any lighting store (B&Q) where demo white LED spotlights are running will reveal – duff or dim LEDS.. why is that?

Well, it seems that coloured LEDs, as long as they don’t overheat really CAN manage obscene lifetimes – but the whites? That’s nowhere near as clear.  My gut feelings tell me they don’t last anywhere NEAR as long – but that’s all it’s it – or was – take a look at this link and read for yourself – this kind fellow has taken the time to do a little research of his own.

http://www.nickhill.co.uk/white_LED_life_expectancy.html

What’s the answer? Well my answer – I plan to use the new RGB LED strip (WAY more expensive than the one-colour-per-LED stuff) with 3 colours in one chip – as much as possible.. and the added advantage…   you can chose what white temperature you want – think there’s only one WHITE? Think again.  Warm white, Cool white, Cold white – it’s all down to the mix of colours and with modern LED strip you can have any mix you like – without using phosphors!!

Charlieplexing

How do you control 3 LEDS with only 3 wires?

Impossible, right? Wrong.

Charlieplexing is a mechanism to do just that. It was developed by Charles Allen at Maxim.

Because LEDS are diodes they only work in one direction – and they only work above a certain voltage. These characteristics can be used to help control them in a multiplexing fashion.  Imagine for example you had TWO wires – surely you can only drive one LED with that. Well no. Imagine you put 2 LEDS and their associated resistors across the two wires – but in the opposite direction. Take wire A high and B low… and one of the LEDS will light up – takes wire A low and B high and the OTHER LED will light up. 2 wires, 2 LEDS.

So how many LEDS can you multiplex onto 3 pins… 3, 4, 5… no – SIX

leds

And here’s a library suitable for Arduino-like chips I spotted out in the wild!

http://playground.arduino.cc/code/charlieplex

Lies, More Lies and Solar Chargers

Thought you might find this interesting… one of the dangers of people selling things they don’t understand.

http://www.ebay.co.uk/itm/ws/eBayISAPI.dll?ViewItem&item=251078578217&ssPageName=ADME:X:RTQ:GB:1123

In this advert is what looks like a very nice solar charger from a company called DracoTek. It offers “11200mAH High Capacity Solar power charger with flashlight

Lovely looking device- just the thing for the traveller… Ignoring the flashlight – 11,200mAH – that’s 11 ampere-hours – that’s more than an alarm lead-acid battery – and from the sun, no less.

But here’s the catch… they claim it will charge in 3 hours from the mains or 11-12 hours from the sun.

To charge an 11aH battery assuming 100% efficiency (impossible)  – you need 11 amps for an hour so let’s say 12 amps – Or  6 amps for 2 hours, or 3 amps for 4 hours etc…. but the spec says the adaptor can only output 2 amps max.. that’s 6 hours, not 3. And solar – that’s asking a lot from a solar panel a mere 160mm by 90mm.

I wrote to them with these questions…

I have a question. According to the spec, the charge current on mains is 2 amps max. It’s an 11+A/H battery. That indicates 6 hours charge assuming high efficiency AT BEST. But the spec ALSO says it takes only 3 hours to charge?? How is that?
Will it really fully charge in under 12 hours sunshine only?

Also I’m not seeing a 5v output which would be needed to charge, say the iPhone in the example. The spec shows only 4.2v, 8.4v etc… no 5v??

The response??

“I am sorry that i can not be support with it, thanks.
Best regards
Vera”

Always check the specification intelligently before buying!

Unreliable Routers and WIFI access Points

Over the years I’ve dealt with unreliable WIFI access points and less frequently ADSL routers… and I’ve adopted a simple solution.

There seem to be many WIFI access points out there that are unreliable – that is they works for weeks on end and then at random stop working. It might be months, it might be days.

I’ve recently been piecing this together and one thought is resetting. No matter where you are but more likely in rural areas, you get mains spikes, dips or downright failures. Mains failures don’t usually cause a problem as anything over a second or two gives the reset circuitry in modern equipment time to discharge ready to run again – but quick spikes or dips, i.e. glitches, can leave microprocessors in a mess.

This is almost always down to rubbish reset circuits as I found out many years ago when designing PIC-based products full time. It is possible there’s a generation of designers still who aren’t aware of this and while some processors will have improved, others which CLAIM to have internal reset may well not have this down to a perfect art.

This certainly WOULD explain why some electronic kit which is left on 24-7 seems to fail on the odd occasion.

How many times have you heard someone say “I just turned it off and on again and it was fine”.  See my point?

Ok the simple solution is a timer – not the DIRT cheap kind with the rotary dial that work in 15 minute intervals and are HOPELESS as they lose time when the power is turned off… no, the slightly more expensive ones with an LCD display that KEEP the time.

Set them to reset the gadget at a time you won’t be worried about – say, on at 4am – and off at 3.58am… so they are on all day and turn off for 2 minutes near 4am. Of course if you work then you might want to pick a different time.

I’ve used this plan on several occasions and while not ideal, it’s a cheap, inexpensive and simple way to ensure your 24-7 kit remains working for 24-7, 365 days a year.   It’s a lot cheaper than a new router!