Category Archives: ESP-210

FAB11–Boston

This coming Monday/Tuesday/Wednesday I’ll be working with Espressif CEO Swee-Ann TeoJeroen Domburg, Ivan Grokkhotkov and others at FAB11 in Boston – demonstrating how to use the ESP8266 chips in home control and other applications.Heading off from Alicante first thing in the morning tomorrow (Sunday) and arriving late afternoon in Boston. Should be quite an adventure.

As well as talking about the technology and helping others I’m hoping to learn a lot more myself about these chips and of course I’ll be spending time armed with camera, checking out the many seminars and exhibitions at FAB11.  For pics and info…. I’ll be updating this blog occasionally – tweeting at @scargill (#fab11) and on the Facebook page esp8266wifi

Facebooktwitterpinterestlinkedin

ESP8266 Reliability and ID

Questions for you C programming ESP8266 guys re: the ESP SDK (1.2.0) and some possibly important info on WIFI and MQTT reliability.

In the SDK:

wifi_station_set_hostname

wifi_station_get_hostname

HOST ID….  If you do an IP scan on a windows network – ESP units will coming up as IP addresses – and Manufacturer ESPRESSIF…   there is a WIFI HOSTNAME GET function in the SDK –  but not only can I NOT get it to do anything, the corresponding GET function returns something like ESP_945645  – and not what I put in and NEITHER are showing up in the Windows IP scan – so the question is… where are you supposed to use the SET function in the SDK to replace the info that comes out of the GET function – and why isn’t any of this showing up on a Windows scan.

wifi_station_set_reconnect_policy

I discovered that if our software was running happily on the ESP12, happily talking to MQTT, if I then disconnected the WIFI and router for a few secs and reconnected…… DEAD. The board would respond to serial but it had LOST the WIFI number.

No amount of waiting would fix this – I wonder how many people have NOT twigged to this – well, if not – this could be your lucky day. The reconnect policy set to 1 will ensure that within a few minutes, the IP will reconnect.. and of course you can CHECK this!!!

So the next step was to see if the IP had been reconnected and call the MQTT reconnect routine – after all, you’ve lost all your MQTT subscribes at that point.

Then it occurred to me – there might be other circumstances – the NODE-RED might have gone off for a while – could I be sure I’d still have a connection – so finally we set Node-Red off sending a “heartbeat” message to all of the units (by missing off the unit name and just having a topic of “toesp” on our boards, you send to all) every minute – and that resets a timer – so then in the above routines – if the WIFI is active and the timer has timed out – once again reconnect to MQTT.  I checked the stack and this does not suffer – so fingers crossed that will be just fine for the odd occasion that this is needed.

Hence reconnect without rebooting and all the horrible relay flicking results of that!!!  I’m quite happy – a beer, I think. The repository is updated and I have boards testing now.

If you are using MQTT and C on your ESP8266 boards, you might just want to ponder the above and if you have an answer for my query at the top, please do let me know.

Facebooktwitterpinterestlinkedin

Hackitt and Bodgitt discover Healthy Lighting

Hackitt and BodgittThere has been a lot of talk in the press recently about the colour of lighting and it’s relevance to health.

As far back as 2012, the BBC reported that NASA were to test “space-sleep colour-changing lights” on the international space station and since then there have been a number of articles in the press suggesting that the colour of light at certain times of the day can affect everything from sleep to prostate cancer.

Of course newspapers have also claimed at one time or another that aliens landed on the moon but there is a certain amount of obvious logic in selecting the right colour for the right time of day. Everyone knows that due to atmospheric filtering, the sun appears shifted toward red at night – and it is quite feasible that our bodies respond to those colour changes. No, I don’t follow my star signs!!

KelvinRecently the papers were full of the news (as it there’s nothing more important going on in the world) that our lighting and our various devices such as tablets can affect our sleep and that you should avoid blue light in the evening and that light shifted toward blue in the morning can aid waking up etc. I subsequently found, thanks to readers, a boatload of APPs that do this colour shifting on phones – not a lot of use when you’re trying to take a photo and you’re mobile has gone all red, but probably a good idea when you’re trying to read yourself to sleep.

And with that in mind I set off trawling the web for more information and finally ended up with a set of RGB values which match “colour temperature” in degrees Kelvin. Now I would not be one to claim 100% accuracy here because for that to work with modern LEDs you’d have to be assured that the RGB values you poked into the LEDs would render accurate colours and I doubt very much that this is the case.  However, I’m going to suggest that what I’ve done here is “near enough”.

In our “Hackitt and Bodgitt” board described in the blog article “Home Control 2015” I’ve added a new command to provide white light from RGB LEDs which can be “shifted” by providing a value in degrees Kelvin from 1,000K (very orange-ish) to 40,000K (very blue-ish).  At 6400K you have a perfect representation of the more garish compact Fluorescent lighting and at 1,100K you have a pretty good match for dim candle-light – with all the subtle variations in between.

Hence with a simple command to alter the hue of white lighting, in our case initiated no doubt in a node-red command, we gain the ability to alter the lighting to the time of day.  Now, WHY would you use more expensive RGB lighting as against simple WHITE LED strip in your home of the future? I have a theory about white LEDs and it’s a theory increasingly backed up by anecdotal evidence that white LEDs don’t last as long as some manufacturers might have you believe. RGB LEDs on the other hand don’t seem to have that problem and have the benefit (we’re talking about modern integrated LED, not separate red, green and blue LEDs) of allowing just about any shade of any colour and in this case, any shade of “white”.

I doubt very much that due to this new lighting interest you’ll read “Peter Scargill becomes the first person to live to 150” but you never know, it might just be an aid to better sleeping and that has to be a good thing.

Facebooktwitterpinterestlinkedin

Accessing ESP8266 Arrays in FLASH

A new challenge – the answer to which I will post in here.

Accessing an ESP8266 C array in FLASH – i.e. never touching RAM until you actually access something.  One suggestion was to ensure you use 4-byte variables.. so I tried this – it compiled – the array is in FLASH – but the access IMMEDIATELY reboots the ESP8266. iprintf is just a macro for printf – no issues there..

static const uint32_t petes[] ICACHE_RODATA_ATTR = {
55,45,66,77,88,12,76,23,45,67,34,65,25,74,234,67,3,643,646,
55,45,66,77,88,12,76,23,45,67,34,65,25,74,234,67,3,643,646,
55,45,66,77,88,12,76,23,45,67,34,65,25,74,234,67,3,643,646};

iprintf is just a macro for a normal printf function…

iprintf(“Data= %ld”,petes[37]);

Result: Immediate reboot….

Thoughts anyone? Why do we need this? Because FLASH is in plentiful supply on these boards, RAM is not.  Ok, you could use tricks from the web page lookup and make functions – but that involves knowing exact addresses etc.. If possible I’d rather let the compiler worry about that.

I’ve posted this on the Espressif forum – I’ll post a working solution in here – but I’m out of ideas….

Facebooktwitterpinterestlinkedin

Lua Revisited

Back in the dark ages when the ESP8266 was something new, I had a go at the nodeMCU software, essentially implementing the Lua language (or a subset of it) on the ESP8266.  At the time I was not familiar with Lua but thanks to some of the excellent resources out there on the web, I quickly caught up.

Sadly, my expectations exceeded the ability of the implementation to match and every time I went past flashing a few lights – CRASH. I gave up in disgust.  I’m not complaining as that gave me the impetus to learn the hard way how best to program these chips – which I maintain is using the C language – and in my case via the unofficial development kit which is just an excellent piece of work by Mikhail Grivorev, leading to a complete Windows environment with a ton of examples. Between that and TuanPMs excellent MQTT code as a starting point  I’ve been happily programming away and even built up a working relationship with Espressif in the process. My home control project is well under way and now just waiting for some new boards – and a function that Espressif have promised to shut down PWM.

LuaMeanwhile this morning, I can’t remember what I was reading that triggered me off, I decided to have a quick look at the node-MCU code again.  I had it sitting in the development environment but figured it would be out of date and so went off to the repository to study any changes – which I duly put into the code. The GIT Makefile is useless for Windows but fortunately there was one in the environment – and as it happens, a good one. I wasn’t about to go backward so I made sure I was linking to the very latest SDK which at this time is 1.1.2 with at least one patch – all available from the Espressif forum.

I checked the settings in the Makefile, adjusted the SPI speed up to 80Mhz, set the FLASH size to 4Mb to suit the sparkly new ESP-210 that is sitting here looking for a job – and started the compile process. Within a minute and without any issues, the code was flashed. I have to say I was expecting at least one or two issues – but no.

I set up a 9600 baud terminal, in the process discovering for the first time that you can have multiple terminals at once in the Eclipse environment – handy (it would be more handy if it always reported the right location of bugs but you can’t have everything). Sure enough – a working Lua board.

I told it about my WIFI setup and sure enough it grabbed that too.  The project has come a long way since the early days and now (apparently) supports json, a file system, timers, pwm, i2c, spi, 1-wire, net, mqtt, coap, gpiio, wifi, adc, uart and more. I’ll believe all of that when I see it.

I was delighted to see that both the integer and float versions are available – that’s a plus! I also noted support for the WS2812b chips – I noted that as I had to make a change to the source code and I’m delighted to note that they’ve made use of a local compiler directive that I was not even aware of to ensure accurate timing. Wish I’d seen that a month ago when I started work on my own WS2812b support. 

WS2812B LEDs on nodeMCU LuaI plugged a (short) length of WS2812b strip (a custom board we had made) into the ESP-210, fired the instruction and… worked first time out of the box. Impressive.

I’m pleased to see the nodeMCU docs have come on a long way – sadly the website was running like a DOG at the time but here’s a few stats I managed to get off the board.

print(node.heap()) returned 20kbytes which is more than when I tried it – but then it used to die when the heap got down to 5K so we’ll have to wait and see how reliable that is.

3 Channels of PWM are available – at 10 bit resolution. Clearly some work to be done here as Espressif have just released a library handling more outputs than that at nearer to 14 bit resolution – and it works as I’ve been using it in my own research and projects. However – handy enough.

There are libraries for sending to displays complete with fonts – now that I’m interested in – if this will do reliably MQTT and report results to a display I have a use for this already – wall thermostats.

So, overall, a very brief test – it is possible with the right environment to get interactive and easy to use nodeMCU up and running in minutes – you don’t need special boards and the software is free. Can’t be bad – how complex a program you can make withou running out of RAM remains to be seen. Here is some more info on nodeMCU.

Facebooktwitterpinterestlinkedin

ESP-210

esp210Getting something new in the post is always fun (unless it’s a tax bill) and today was no exception.  A little parcel arrived from Sweden this morning – an ESP-210.

After carefully removing from the box… I plugged it in to my PC via it’s micro-USB connector. The right noises appeared, no lights…

As it happens I had a fairly complex project on the go in front of me so I changed the port number to the device at hand and pressed the programming button on my PC..immediately a green light came on on the board along with 2 yellow communication lights.

After the usual programming time I was left with a fully programmed board – no problem with a BLUE light on!.  It is nice to get something in the post that just works first time – and looks pretty.

So what’s so special about this – for one thing – it has 0.1” connectors – which is always a plus. Unlike the ESP-12 it runs on 5v. It also has 4Mbyte of FLASH (most of the other boards have 512K Flash). I just cannot imagine filling up that amount of room – but of course, with the ability to store web pages in FLASH you never know what someone might get up to!

esp210[5]There is a user-definable LED on-board attached to GPIO5 (that’s 4 LEDs in total up to now) and the Silabs CP2014 USB to serial device lets you program up to 921600 baud (rather handy if you wanted to use up that 4Mbyte).

As well as USB you can also power the board by either 5v or 3v3 – which is nice. Other features include pull-ups on GPIO16 and GPIO2 so you could use either for temperature sensing without adding anything. TOUT is actually the ADC – so you get that coming out along with the 2 pins for serial I/O which of course can be used for general purpose.

Armed with on-board antenna there is no facility for an external antenna but to be honest I’ve never seen the need for one – the internal ones seem to work just fine.

LEDsSo – just for a bit of fun I dragged out the nodemcu-firmware in my Eclipse environment (important for Windows users because the make file that comes with the original is for Linux) – applied just about the only update that was missing (a couple of lines change for WS2812b LEDs) – set the SPI speed to 80Mhz, set the size of FLASH to 4Mbytes and pressed the FLASH button – lo and behold it compiled first time, dropped into the ESP-210 without issue and after strapping a strip of serial WS2812b LEDs to the board, entered the right LUA instruction…. and VOILA – a strip of brightly coloured WS2812b LEDs. What could be easier.

 

So there it is – another board to ponder! Invector Embedded Systems AB.  Lots of info here. http://wiki.sweetpeas.se/index.php?title=ESP-210 including instructions for putting NodeMCU on it if that’s your thing.

Facebooktwitterpinterestlinkedin