-->
Page 1 of 1

What a hoot!! (NodeMCU and Lua)

PostPosted: Thu Jan 12, 2017 1:23 am
by alex_g
(Re: NodeMCU v0.9 and Lua)

Hi All!

No, for once, I don't have any questions!
I just wanted to say that after a couple of days of messing around, I now have my little "proof of concept" experiment up and running. I am so impressed...

I have two alarm timer loops going, one runs at a variable speed, polling the ADC each time for the interval. Depending on the results it flashes various LEDs. The other one is running as a pseudo-do-loop doing some quite involved mathematical calculations in the background. I am even computing log() in acceptable time, using the builtin-in math.power() routine, and an inverse Newton iteration. All this is working totally seamlessly with the wifi, with barely any perceptible loss of response speed.

OK, I've used most of my heap, but I can't begin to imagine what this thing is capable of if I drop to C!

Now I'm just waiting for those ADXL accelerometers and the WS2812B LED strip, and it should be party time.

Really remarkable piece of equipment. I've never done anything with any microcontroller before, not PIC, not Arduino, nada (never programmed in Lua before, for that matter), and I am amazed at how easy this all was.

HUGE thanks to everyone who has posted FAQs, tutorials, etc, couldn't have done it otherwise!

Re: What a hoot!! (NodeMCU and Lua)

PostPosted: Thu Jan 12, 2017 4:34 am
by devsaurus
Thanks for posting your experiences! It's a great insight into a start-from-scratch and very motivating for me as a contributor to this project :D

Were there any specific docs, guides, tutorials that you would recommend to other people new to Lua on ESP8266?

Re: What a hoot!! (NodeMCU and Lua)

PostPosted: Thu Jan 12, 2017 11:06 am
by alex_g
Hi devsaurus!

Well, I can't give a definitive list, since I'm sure there's stuff out there that I haven't seen even yet. I can only mention my own experience, so here goes:

  • First off, I think you need one of those basic tutorials: "here, this is a pin, connect it up and turn a LED on with wifi". I used the first one I found, here, but there's plenty more, still, it's quite acceptable and I have bookmarked it, for occasional looks at the pin-outs.
  • The next thing was the NodeMCU Lua API, not going to get too far without that, plus it can give you some ideas...
  • Then you need something to learn Lua with, if you already know Javascript you're more than halfway there, I used the Lua 5.1 reference manual.
  • Finally, and perhaps most critically, I found that the "Unofficial FAQ", was absolutely vital for figuring out async event-based programming. I've already mentioned its on this site, but has suffered a formatting mishap, I got it from here.

With these four, I reckon you are well set up to start, although a simple tutorial on basic event-based programming would be very nice. I have some programming background, so I was able to figure it out (after trying - and failing - with coroutines), but I'm not sure everyone could. I am seriously thinking of writing this up myself.

===

A couple more things:

I see a lot of people complain that the v0.9 NodeMCU breakout unit is too wide to fit on a normal breadboard. Well, maybe it was beginners luck, but when I went out to get my breadboard (I used Maplin UK, a bit like the US Radio Shack) the unit I came back with has four banks of (width) 6 pins each and easily takes the module, straddling one bank and allowing 5 connecting receptacles on each pin! Couldn't be more perfect.
Are these non-standard, and I just got lucky?

I was delighted to see there was a floating-point ROM firmware available. I downloaded that, and though I was initially disappointed to find no trig functions, I still managed to do a lot with it. I'm not sure where I found the docs for it, but they're out there for sure. I guess I'll have to build my own C one eventually.

I'll keep reporting back on any progress, probably on this thread. Hey I think the postman just arrived with those WS2812Bs...