ESP8266 LUA and MQTT

After a few days break wherein work got in the way of interests (not a good thing) I got up early this morning, determined to do some work on my ESP-01 boards while I have a clear weekend ahead of me. I checked for updates for MQTT and there are none – which is fine – that indicates that nothing has gone wrong this week.

On a whim I decided to go check the LUA site. I already new that the latest MQTT had been imported from conversations with Minh  who’s been doing the MQTT work but I was delighted to see signs that also some more work had been done on integration with Eclipse.

Every single time I’ve tried to install the nodemcu LUA code into Eclipse there has been a problem – something not found, some path missing, some issue taking hours to resolve.

Yet this morning I downloaded the latest ZIP file (updated yesterday) and imported it into Eclipse. CLEAN – COMPILE – FLASH…  not a hiccup – it worked perfectly. Not only that but when I tried powering Lua up – it came up straight away without any hint of an issue. This is new for me as I’ve always had some trouble or other. Magic.

Though it is possible to debug Lua code using the simple terminal you can install into the Eclipse environment, I did develop my own serial terminal  and then subsequently discovered ESPLorer.

I powered up ESPlorer and checked the available RAM on my newly installed Lua installation on an ESP-01 (I’m still waiting for my new white board to turn up from China with all the pins available – meanwhile I have ESP-01, ESP-03 and ESP-12 boards to play with).

A quick node.heap() call showed that we’re starting off with 22,144 bytes of working RAM which is a good improvement on the earlier versions especially as MQTT is now incorporated.

First things first, I told the unit about my router and then my MQTT broker which regular readers will know is sitting on a Synology DiskStation and has been sitting there working flawlessly for weeks now despite my attempts to bombard it to death with messages.

I noted when using wifi.sta.getip() that the unit remembered my router from previous experiments (I wish someone would produce a nice graphical memory map to show where these various elements are stored and how to tinker with them). So that was easy.

I followed this example – obviously filling in the bits that apply to my installation..

— init mqtt client with keepalive timer 120sec
m = mqtt.Client("clientid", 120, "user", "password")

— setup Last Will and Testament (optional)
— Broker will publish a message with qos = 0, retain = 0, data = "offline"
— to topic "/lwt" if client don’t send keepalive packet
m:lwt("/lwt", "offline", 0, 0)

m:on("connect", function(con) print ("connected") end)
m:on("offline", function(con) print ("offline") end)

— on publish message receive event
m:on("message", function(conn, topic, data)
  print(topic .. ":" )
  if data ~= nil then
    print(data)
  end
end)

— for secure: m:connect("192.168.11.118", 1880, 1)
m:connect("192.168.11.118", 1880, 0, function(conn) print("connected") end)

— subscribe topic with qos = 0
m:subscribe("/topic",0, function(conn) print("subscribe success") end)

— publish a message with data = hello, QoS = 0, retain = 0
m:publish("/topic","hello",0,0, function(conn) print("sent") end)

m:close();
— you can call m:connect again

(again ignore the IP address and port – I filled in my own) – I ran this and… connected no problem. All seemed well.   I had subscribed to “test” rather than “/topic” and had commented out the publish for now.

I tried publishing “test” to see what would happen – nothing. But then I guessed as the last line was “m:close()” I figured it reasonable that the ESP-01 would not be listening and so called the connect line again – after all – there is a comment in there “you can call m:connect again”.

The result (passwords have been changed to protect the innocent):

> m = mqtt.Client("peteluatestid", 120, "xxxxxx", "yyyyyyy")

NodeMCU 0.9.5 build 20150123  powered by Lua 5.1.4
lua: cannot open init.lua
>

Yes that’s a crash. Oh dear, this is not the first time I’ve seen Lua just die. I can handle error messages but this tendency to just simply reboot…

Meanwhile, my experiments with programming in C, using MQTT directly have, thanks to Minh Tuan’s constant vigilance in fixing things, produced rock-solid results. Indeed I’ve been away since last weekend and I turned off a perfectly working MQTT temperature sensor in order to give Lua another go. I thought the one-wire library in Lua might make the transition to a Dallas DS18B20 a little easier but I’m not going to start another round of failed experiments while Lua so easily crashes.

Incidentally, I had several attempts with this Lua installation – rebooting several times along the way. When I finally managed to get the whole thing to work and in commenting out the CLOSE – as you need the connection open to receive anything, I noted my wonderful 22k of RAM had dropped down to 17.2K.  I really do wish they’d put a little more RAM on that chip.

Having checked that the compilation had included all the modules (app/include/user_config.h) which as far as I can tell the default combination SHOULD do… I thought I’d try the DS18B20 module – the idea being to send an MQTT request – and get an MQTT message back with the temperature in it.

I thought I would avoid experiment and merely check the temperature first.  I duly attached a working SD18B20 unit and pull up resistor to GPIO2 (that’s input 4 according to the table).

The code looked simple enough..

t=require("ds18b20")
t.setup(4)
addrs=t.addrs()   
print(t.read(nil,t.C))
t = nil
ds18b20 = nil
package.loaded["ds18b20"]=nil 

But no..

> t=require("ds18b20")
stdin:1: module ‘ds18b20’ not found:
    no field package.preload[‘ds18b20’]
    no file ‘ds18b20.lua’
    no file ‘ds18b20.lc’

Oh dear….

Thoughts? Am I missing the point here?

Advertisements

The Battle of the ESP-201 Giants

ESP-201This is a relatively new one – the ESP-201 – larger than other game-changing miniature WIFI boards (or miniature powerful programmable devices with WIFI as you prefer)  but with one big advantage – unless I’m mistaken this new WIFI board (which will be functionally identical to others as it has the same parts) appears to have 0.1” spacing which means for the first time other than the pin-challenged ESP-01 we’ll be able to experiment with this board on normal breadboard or with normal prototyping wire – and that has to be a good thing.

The only question is – do you want to pay £3.29 or £2.58 (that’s Pounds Sterling as I am UK based)

Here they are – if anyone has any CHEAPER links do let me know…

http://www.banggood.com/ESP8266-ESP-201-Remote-Serial-Port-WIFI-Transceiver-Wireless-Module-p-964288.html

http://www.aliexpress.com/item/ESP8266-Serial-Port-WIFI-Wireless-Transceiver-Send-Receive-Module-IO-Lead-Out/32254810086.html

These boards like the others run on 3v3 and like some of the others have an on-board antenna – but there is also an option for an external antenna (I’ve not found the need for one myself).

The point is – unless SIZE is a big issue, these almost compete on cost-price alone with the ESP-01 but without the pin restrictions – let’s see what we get – and if anyone has done some work with one of these could they please let us know how these pin-mappings compare to somewhat more conventional pin names for these devices.  I expect I’ll have mine soon and am looking forward to taking the opportunity, perhaps even at the weekend, to mess with second UART debugging, I2C and a host of other features denied to ESP-01 users (except those with obscenely accurate soldering skills and very fine wire). Mind you, a planned BURNS night on Saturday might slow progress a little.

ESP8266 I2c

There seems to be chatter going around about how the ESP8266 does not have I2c.  So much so that there are implementations of bit-banged I2c out there..  here for example and this one is good for those with ESP-01 boards which only have 2 pins available – but beware that GPIO-0 is also used in hold-low mode on powerup for flashing the chips – and also the developer of this driver states that works needs to be done. I noted that it is NOT done under interrupts.

If you want to see the official line on i2c it is that it IS supported – here it is in the SDK documentation. http://www.esp8266.com/viewtopic.php?f=5&t=449  – available in both WORD and PDF versions…  granted this is early documentation 0.9.1– there is later (around December 0.9.4) but as far as I am AWARE you have to sign an NDA to get the newer information – I may be wrong.. you could check with Espressif themselves.

According to the documentation you have full I2c master control (it would have been nice had it specified which pins to use!)

It would be nice if someone would submit a really trivial I2c example using the above, stating which pins needs to do what.

What I don’t understand is – when ESPRESSIF distribute the various SDKs there’s a directory in there called document that is always empty – you would think they’d take the opportunity to include the documents in there!!

Of interest if you have the pins available there is also a dual UART (ie 2 lots of serial lines) and PWM control of some of the pins.

MQTT for ESP8266 not QUITE but nearly

Minh Tuan is doing an excellent job with MQTT – he has it working stand alone – and in the LUA code (not yet brought into the main code)… but..

Before you go off getting annoyed if things don’t go quite to plan, there still seems to be a tiny but important bug  -I’ve reported it today and Minh will look at it tomorrow. I’m working on code from just an hour ago here (late after noon UK)

I set up a demo, subscribing to 7 short topics. With the exception of the first, all the topic names are short… and all responses are short…. I’ve changed the broker name below to protect the innocent (that would be me).

MQTT: subscribe, topic"home/openHAB/out/Light_FF_Bath_Ceiling/command" at broker xxx.yyy.zzz:1884
MQTT: subscribe, topic"myleds" at broker  xxx.yyy.zzz:1884
MQTT: subscribe, topic"mytime" at broker home.scargill.org:1884
MQTT: subscribe, topic"time" at broker xxx.yyy.zzz:1884
MQTT: subscribe, topic"dusk" at broker xxx.yyy.zzz:1884
MQTT: subscribe, topic"dawn" at broker hoxxx.yyy.zzz:1884
MQTT: subscribe, topic"timestring" at broker xxx.yyy.zzz:1884

As you can see all of them subscribed successfully or so it would seem.

Ah, but…

4 of them are broadcast every minute from a page I demonstrated in a previous blog or it’s notes and over on another computer I have MQTT spy watching… time, dawn, dusk and timestring are send out by the same page once per minute.

But what is being seen by the little ESP8266 program is….

TCP: data received
MQTT topic: time, data: {1484956800}
TCP: data received
MQTT topic: timestring, data: {15:15 Saturday 17-01-15}
TCP: data received
MQTT topic: time, data: {1484956800}
TCP: data received
MQTT topic: timestring, data: {15:16 Saturday 17-01-15}

As you can see, dawn and dusk have “disappeared into the dusk”.

Similar happens with the Lua/MQTT code – I thought at first that might be due to the callback not being done before being called again but seeing this I’m thinking… no.

As soon as this one is resolved I’ll report back. It is important that the system can handle several simultaneous incoming messages and that it it reaches it’s limit, something obvious tells us that.   The info above is the minimum I would be sending to any module –ok of course I could merge them into one – but that’s not the point – I could not do that if they were coming from different sources.

Suggest looking in again tomorrow for any fixes…

If I go quiet, I’m off to Brussels for a couple of days for some EU business.

And there’s more… I reduced the number of subscriptions to 3..

MQTT: subscribe, topic"dusk" at broker xxx.yyy.zzz:1884
MQTT: subscribe, topic"dawn" at broker xxx.yyy.zzz:1884
MQTT: subscribe, topic"timestring" at broker xxx.yyy.zzz.org:1884
MQTT: Sending..type: 8,qos: 4
TCP: Sent
TCP: data received
MQTT: Sending..type: 8,qos: 4
TCP: Sent
TCP: data received
MQTT: Sending..type: 8,qos: 4
TCP: Sent
TCP: data received
TCP: data received
deliver_publish
MQTT topic: timestring, data: {16:43 Saturday 17-01-15}
TCP: data received
deliver_publish
MQTT topic: dawn, data: {27208}
TCP: data received
deliver_publish
MQTT topic: timestring, data: {16:44 Saturday 17-01-15}
TCP: data received

 

Couple of things of concern – firstly again it’s SAYING it has subscribed to 3 but it only taking two of them – the last 2 (that’s not a clue, wasn’t last 2 last time) but the messages are also a concern… “Sending..type:8 qos:4”   there ISN’T a qos 4 !!! Don’t know what that is about…

ESP8266 the unstoppable March of Progress

esp01I’ve been following the progress of this little chipset as you know since day one – having spend a year more developing skills at using horrible little NRF24L01 radios with as much indoor range as my legs – and Arduino Ethernet cards (which to be fair are WONDERFUL other than their need for a marriage-endangering WIRE), out of the blue came a little Chinese board with the potential to change everything. The ESP-01 showed much promise but very little reality at first. The instructions were in Chinese, the documentation was in Chinese or missing, people told me “there are these other boards for only a tenner that do so much more”.

And yet here we are today with much of that about to change. The new so called white ESP8266 board with it’s development “kit” for less than a tenner is winging it’s way to me now – and the ESP-12 boards are neat and even have approval stickers to keep people happy not to mention a health range of I/O.

There are now a range of boards, all cheap  (there is a question mark over the ESP-07 – not for the first time I’ve heard there are 2 versions one of which is “suspect”) – and the ESP-01 remaining, I think true to my original statement – the title of one of my blogs “the cheapest computer in the world”. At under £2 tell me I’m wrong. 1 plug in the wall power supply , one ESP-01, one cheap solid state relay and you have a functioning WIFI-controlled device – with the right software that is.

But like all such devices, software makes or breaks this dream and in recent weeks we’ve seen the emergence of the ECLIPSE environment for Windows – I’m sure there are many such environments for Linux – and others will blog about them – I’m not interested in the command line and haven’t been for a long time. Eclipse and the tremendous work by the fellow who set this all up for us – means everyone from expert to complete beginner can “have a go”.

This week however is a bit special – we have in one corner TUAN and his MQTT code – on the other corner we have ZERODAY and his LUA interpreter – ( I really should find out everyone’s proper names) and this weekend – they look like merging.  I’m hoping that the MQTT code will continue to be developed independently of LUA as I think there are uses for both. I DO have code that WORKS – it’s not just a promise. We have some great tools such as Esplorer for testing Lua and the AT command set.

I can’t tell you what is possible with the software and hardware out there – all I can tell you is what I’m doing and why – I hope my blogs up to date have given you all the links you need. For days now I’ve been testing the MQTT software – and as far as I can tell there is only one “bug” left of note and it’s not even a bug – it’s an inconvenience – something to “wrapped up” – essentially the code works – but it’ not too happy about empty messages. I expect right now that is being fixed and I am so grateful to so many authors who have communicated, helped, changed things – in the main for no commercial gain – because they love it.. it’s almost like the days of the first 8-bit micros – the rush of learning.  Meanwhile I got an email this morning to say that MQTT and LUA were merging and a test set of .BIN files was available.

So, despite a head that is spinning like a TOP due to flu, this afternoon I set up a test rig…  let me take you through that quickly… erm… it works but read on as you need the bits that come before it.

The plot so far:

In order to use MQTT as the base of your control system (in my humble version of this vastly diverse Internet of Things) you need an “MQTT broker” running somewhere and it needs to be reliable – ROCK SOLID. In my case I have a Synology Diskstation (the link is an example – mine is not white) and with a little help I got the free MOSQUITTO running on it – you could put this on an old PC, a Linux box – just about anything with a brain – but it needs to be reliable. There are services out there – the free ones they generally warn you not to rely on them – so I’m not going to – I’ll have my own thanks – I’ve talked about several variations elsewhere – at the end of it I went with Mosquitto.  My disk backup DISKSTATION is on 24-7 so it seemed the ideal place for this. As for testing Mosquitto on a PC – you are not going to beat the EXCELLENT MQTT-SPY.

So now a place to fire messages to – and a place to receive them from… and the software tools for ESP8266 to send and receive those messages – the sky is the limit. But what about issues people have had – swapping modes – you might need the time from a time server for your little board or some other info. Well, I found a way around that.   MOSQUITTO is on all the time – what is needed is for it to make available info to the little boards, be it time, lighting up time, perhaps other information.  I found a PHP library – the nice kind – the type you don’t actually have to understand to use.  Some time ago I documented a web page I was using to fire back time and other information – I used it as I found NTP time servers to be slow at times.  I have cheap web space with a provider much as many of you will – with CPANEL – which means I get all the benefits of using a reliable Linux based web service while staying within my pretty coloured boxes visual interface comfort zone (I’m sure there’s an abbreviation for that).

With such a setup you can write PHP pages like one that will send time messages for example and with the ability to run those pages on demand using CRON (doddle) you can make the time and over information available to your toys.

Here’s the deal.

<?php
require("../phpMQTT.php");

$mqtt = new phpMQTT("xxx.xxxx.org", 1884, "somenamePub");
if ($mqtt->connect(TRUE,NULL,"mymqttuser","mymqttpass")) {
            $locn="Europe/London";
            $lon=55;
            $lat=-2;
            date_default_timezone_set($locn);
            if ($_GET[‘loc’]!="") $locn= $_GET[‘loc’];
            if ($_GET[‘lat’]!="") $lat= $_GET[‘lat’];
            if ($_GET[‘lon’]!="") $lon= $_GET[‘lon’];
            $dateTimeZoneLocal = new DateTimeZone($locn);
            $dateTimeLocal = new DateTime("now", $dateTimeZoneLocal);
            $localDateTime = date("H:i l d-m-y", time());
            $localTime=strtotime($localDateTime);
           
            $mqtt->publish("time",$localTime,0);
            $mqtt->publish("timestring",$localDateTime,0);
            $sun_info = date_sun_info($localTime, $lon, $lat);
            foreach ($sun_info as $key => $val) {
                if ($key==’civil_twilight_end’) $mqtt->publish("dusk",$val %86400),0);
                if ($key==’civil_twilight_begin’) $mqtt->publish("dawn",$val %86400,0);
            }
    $mqtt->close();
}
?>

No knocking my coding please – I do not profess to be a PHP expert – indeed – can you think of decent extra publications this page could produce for the little gadgets? If so lets have those ideas! 

This web page connects to your MOSQUITTO or other MQTT broker and every minute (every week if you want – my choice of every minute – gadget turns on – worse case it waits a minute to know the time) I am here publishing 4 items – the TIME in standard seconds-since-1970 format, British lighting up time (DUSK) in seconds since midnight, DAWN in seconds since midnight and TIMESTRING for those with no space in their project to format the time. ANY of my gadgets can choose to subscribe to these  publications – or not. And as you can imagine I’m planning more publications – timed an otherwise. The server load of the above is irrelevant – I don’t see anyone’s provider griping about this.

So – the people I’ve been with keep my web pages up and running 24-7 and and have done for as long as I can remember – why would I not trust this info.

And all of this brings us around to LUA+MQTT – possible only since this morning!!!

Check this out. Sorry it’s not formatted.

mqtt = net.createConnection(net.TCP, 0)
— init mqtt client with keepalive timer 30sec
mqtt:mqtt("myid", 30, "mymqttuser", "Tmqttpassmakeitagoodone")

— on publish message receive event
mqtt:on("receive", function(conn, topic, data) print(topic .. ":" .. data) end)
— on connection event (all event inherit from net module)
mqtt:on("connection", function(con) print("connected") end)
mqtt:connect(1884,"mymqttserver.address")
— subscribe topic with qos = 0
mqtt:subscribe("time",0, function(conn) print("subscribe success") end)
— publish a message
— mqtt:send("/topic","hello",0,0, function(conn) print("sent") end)

print (node.heap())

mqtt:subscribe("temperature",0, function(conn) print("subscribe success") end)

mqtt:send("dusk","hmm",0,0, function(conn) print("sent") end)

THAT which you see above and the code to log into your access point (which, once entered should stay there) is it – that code is all I had to put in – to have the little board be subscribing to time, dusk, dawn and temperature from another device (oh – a pair of minuses means comment – you need to see how to publish).

The REST is what you do with such info – Lua has timers (to keep that time going if you lose the internet connection) and GPIO control – to do things – already discussed previously – I’ve had a solid state relay running directly off the board and powering a mains lamp.

And that is it for now – the information isn’t here – it’s out there – check out the links here and in my previous blogs and bear in mind that before Christmas I knew NOTHING about compiling this stuff and I was determined determined not to get into Linux (and still successfully avoiding it)  – I’m now just about ready to openhabproperly embark on some real projects with real control in the comfort of my pretty-coloured Windows environment…  I hope that by putting all of this in one place gives you a head start.

For my next challenge – OpenHab but I think I’ll wait until the flu has gone – this one’s not going to be easy.

Return to the land of ESP LUA

As I’d just installed the latest update to the ECLIPSE environment.. I thought I might take a look again at LUA to see what version was on there.

Sure enough – the latest.. but look what happened when failing to connect to an access point – I asked for a list of access points..

image

Hmm. Best go to the site and get a fresh copy I think and hope it compiles.

 

So:

I went to the NODEMCU site … https://github.com/nodemcu/nodemcu-firmware

Grabbed the ZIP file – and after ensuring all files had been removed from the ECLIPSE setup, unzipped then renamed (to exclude –master) the package into the EXAMPLES folder in ESPRESSIF..

I imported the project – changed the PORT number to the port number of my FTDI (does anyone know how we can specify that ONCE somewhere and have all the projects take notice).. and

 

17:50:03 **** Build of configuration Default for project nodemcu-firmware ****
make clean
Cannot run program "make": Launching failed

Error: Program "make" not found in PATH
PATH=[C:\Windows\system32;C:/Program Files (x86)/Java/jre1.8.0_25/bin/client;C:/Program Files (x86)/Java/jre1.8.0_25/bin;C:/Program Files (x86)/Java/jre1.8.0_25/lib/i386;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\ProgramData\Oracle\Java\javapath;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\adb;C:\Program Files\nodejs\;C:\Users\Peter\AppData\Roaming\npm;C:\Espressif\xtensa-lx106-elf\bin]

17:50:03 Build Finished (took 47ms)

 

On advice from a friend I added this to the PATH variable (don’t understand why it’s not in there)

C:\MinGW\bin;C:\MinGW\msys\1.0\bin; C:\Python27;

 

I added this here… right click the project – properties – C/C++ Build – Environment – PATH.

 

C:\Windows\system32;C:/Program Files (x86)/Java/jre1.8.0_25/bin/client;C:/Program Files (x86)/Java/jre1.8.0_25/bin;C:/Program Files (x86)/Java/jre1.8.0_25/lib/i386;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\ProgramData\Oracle\Java\javapath;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\adb;C:\Program Files\nodejs\;C:\Users\Peter\AppData\Roaming\npm;C:\Espressif\xtensa-lx106-elf\bin;C:\MinGW\bin;C:\MinGW\msys\1.0\bin; C:\Python27

I must tidy this up as I don’t have some of those directories but everything else compiles ok…

CLEAN  -WORKS

ALL – WORKS right to the end and then…

 

make[2]: Leaving directory `/c/Espressif/examples/nodemcu-firmware/app/spiffs’
xtensa-lx106-elf-gcc  -L../lib -nostdlib -T../ld/eagle.app.v6.ld -Wl,–no-check-sections -u call_user_start -Wl,-static -Wl,–start-group -lc -lgcc -lhal -lphy -lpp -lnet80211 -lwpa -lmain -ljson user/.output/eagle/debug/lib/libuser.a driver/.output/eagle/debug/lib/libdriver.a lwip/.output/eagle/debug/lib/liblwip.a json/.output/eagle/debug/lib/libjson.a ssl/.output/eagle/debug/lib/libssl.a upgrade/.output/eagle/debug/lib/libupgrade.a platform/.output/eagle/debug/lib/libplatform.a libc/.output/eagle/debug/lib/liblibc.a lua/.output/eagle/debug/lib/liblua.a smart/.output/eagle/debug/lib/smart.a wofs/.output/eagle/debug/lib/wofs.a spiffs/.output/eagle/debug/lib/spiffs.a modules/.output/eagle/debug/lib/libmodules.a -Wl,–end-group -o .output/eagle/debug/image/eagle.app.v6.out
../tools/esptool.py elf2image .output/eagle/debug/image/eagle.app.v6.out -o ..\\bin\\
/usr/bin/env: python: No such file or directory
make[1]: *** [.output/eagle/debug/bin/eagle.app.v6.bin] Error 127
make[1]: Leaving directory `/c/Espressif/examples/nodemcu-firmware/app’
make: *** [.subdirs] Error 2

17:55:02 Build Finished (took 44s.245ms)

Ideas anyone?

ESP8266 Temporary RGB Solution

LEDS

Not exactly ideal (especially if one has already bought a load of WS2812b strip) but some time ago we had some little boards made to house 10 of the WS2812B chips – and while we were on we put a surface mount 328 chip on the back along with crystal and serial connector for an FTDI.  With the current issues getting accurate high speed timing out of the ESP8266 I bodged some code in the display board to look for {rgbdevice;red=x;blue=y;green=z} type messages.

I’ve modified the MQTT code already to stick {} around any message shown on the serial so it’s quite easy to pick out. The “rgbdevice” starter just gives it that much less chance of flicking lights for the wrong reason.

I implemented red, green, blue, bright, cycle, power, LEDs

The last one redefines the number of LEDs in we wanted to put several of these boards in series (obviously the others would not have the 328 mounted).  It’ll do until someone comes up with an assembly block for the displays in which case it should be possible to connect GPIO0 directly to the first display input.

The software for Arduino incidentally is simply the FASTLED library  – I stuck an infra-red sensor on for remote control but again the timing of the LED displays is such that if you’re doing a soft sequence as you see in the photo, the IR sensor interrupts get in the way. So maybe I’ll just stick to controlling the lot from my phone. Next challenge – get that OpenHab colour wheel working!!

ESP8266 LUA and the ongoing issues with Windows

I just grabbed the latest Windows-compatible Lua software and tried to import it into Eclipse on Windows…   followed the usual -  put it in examples after renaming to “nodemcu-firmware”.  Imported, tried CLEAN and..

09:22:43 **** Build of configuration Default for project nodemcu-firmware ****
make clean
Cannot run program "make": Launching failed

Error: Program "make" not found in PATH
PATH=[C:\Windows\system32;C:/Program Files (x86)/Java/jre1.8.0_25/bin/client;C:/Program Files (x86)/Java/jre1.8.0_25/bin;C:/Program Files (x86)/Java/jre1.8.0_25/lib/i386;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\ProgramData\Oracle\Java\javapath;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\adb;C:\Program Files\nodejs\;C:\Users\Peter\AppData\Roaming\npm;C:\Espressif\xtensa-lx106-elf\bin]

09:22:43 Build Finished (took 47ms)

Oh dear.

ESP8266 UART

SerialIn the MQTT implementation, the UART is used for status only – in other words the input is not used.

I’m a little vague on how to use the serial input. I am assuming there is an empty function in which you have to implement your own queue   – but it’s not at all clear. Can anyone who has looked into this give a simple (C language, not LUA) example of the use of the serial input (ignoring speed setup as that’s done for the serial monitoring already).