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

Advertisements

Google Drive and Bandwidth Limiting

As many of you will know, in the UK at least we have an issue with broadband in that it our upload speed is no-where near as fast as our download speed.  In my case, not untypically I can download (i.e. play videos, grab music,  files and web pages) at something like 6Mbps. However the less obvious UPLOAD speed is around 600Kbps (i.e. 10 times less). This is often disregarded and yet it is very important.  Some folk have as low as 300Kbps and this is very limiting – especially if you want to run something like Skype.

Where web pages are mainly about downloading (i.e. grabbing content) Skype is mainly about uploading – i.e. you are SENDING (uploading) your voice and video to the other party.  As uploading is the slower of the two, this then becomes the limiting factor for quality and reliability for Skype and other forms of conferencing software.

If your connection was doing nothing else, this would likely not be an issue – but even if you only have ONE PC on the network connection (and many homes and offices have several) you might still have issues thanks to OTHER processes/programs using up your limited upload capability.

Examples might be Google Drive, Dropbox, Box and other backup/sync solutions.  In the background these programs check for changes in files (perhaps a WORD document you may be editing) – and if there is a change this triggers an upload to the cloud. It happens automatically and in the background.

Thankfully the people at Dropbox put a LIMIT as to how much of your bandwidth the program can use – hence allowing it to work while you’re Skyping without bringing Skype to a grinding halt.

The people at Google are no-where near as thoughtful despite having (arguably) a better product and yet despite many discussions and gripes in Google forums – right now there is nothing to stop Google Drive eating up all of your available bandwidth. Similarly programs like LiveDrive may do the same though in this case you can, if you know what to do, limit the upload bandwidth.

But the real problem is actually knowing if this is happening. Let’s say you’re right in the middle of a Skype conversation and the quality degrades – is this your broadband connection or did you just update/overwrite something that’s now being backed up – what about the kids in the next room…how would you know if something else is using up your bandwidth – and if you DID know what would you do about it?

To the (possible) rescue comes NetBalancer. This is not free – though a limited version IS – go get the free download and see for yourself (I’m assuming you are on a PC, not a MAC – and I’m using Windows 7 64-bit – which works just fine).

image

The program once installed shows you (live) which processes are using what bandwidth – both for upload and download (*see up rate and down rate above and take note if the B in KB is upper-case that’s kilo-BYTES as against kilo-bits – roughly a kiloByte is 10 kiloBITS).  Note in the example here, I simply right-clicked GOOGLEDRIVESYNC and set an upload limit of 20KB/s i.e. that process is not allowed to upload at a speed of more than 200 kilobits a second no matter what… Google Drive left to it’s own devices would consume ALL of my upload bandwidth.

This program in the unregistered form will let you control up to any 3 processes. If you choose to pay them something like £20 ($29.95) you can control as many as you want. In my case, this will do just fine. In the example GOOGLEDRIVESYNC is the ONLY process I’ve limited. In addition (right click) I’m giving SKYPE HIGH upload and download priority!

Something I did notice- occasionally for no obvious reason – OUTLOOK does significant uploads in the background….. like 300Kbps significant – just briefly but enough to mess up a conversation.

I hope this is useful to you – if nothing else you now know where to look when having problems with upload bandwidth. For this to be effective you’d need this on any and all machines connected to your broadband as you never know what might be happening in the kid’s room when you’re having an important Skype conversation!

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!