Chat freely about anything...

User avatar
By miker
#19435 I've had great luck using the ESP-01 with the Arduino IDE but nothing but problems using LUA. If you can offer any help and tell me what i'm doing wrong it would be great.

-using the NodeMCU v0.9 hardware
- using ESP8266Flasher.exe flashed 0.9.5 (nodemcu_20150213.bin)
- in ESP8266Flasher clicked the Config tab, x on the top line & selected nodemcu_20150213.bin
- in ESP8266Flasher clicked the Advanced tab took a guess and set Baudrate to 11520, Flash size to 512kByte, 40Mhz, DIO

- used the latest ESPlorer, connects ok
- tried an LED blink test but see this error
Code: Select allNodeMCU firmware detected.
=node.heap()
22560

lighton=0
tmr.alarm(1,1000,1,function()
if lighton==0 then
lighton=1
led(512,512,512)
else
lighton=0
led(0,0,0)
end
end)
PANIC: unprotected error in call to Lua API (stdin:4: attempt to call global 'led' (a nil value))
H!ˆÈ©�ŽF
¥•ŽDH
ÊôŒ¦¨HøNodeMcu 0.9.5 build 20150213 powered by Lua 5.1.4
lua: cannot open init.lua



Connected an i2c oled to D5 & D6
- opened u8g_graphics_test.lua
- left code as is because SDA = 5 & SCL = 6 are correct as well as address 0x3c
-Clicked Send to ESP button, then Run button but it's blank

Mike
User avatar
By GerryKeely
#19636 Hi
The function LED you are trying to use is not a built-in LUA function(see NodeMCU API) hence the error
To blink a led a on pin2( Nodemcu designation pin4) try
Code: Select all-- Blink using timer alarm --
timerId = 0
dly = 1000
-- use D4
ledPin = 4
-- set mode to output
gpio.mode(ledPin,gpio.OUTPUT)
ledState = 0
-- timer loop
tmr.alarm( timerId, dly, 1, function()
  ledState = 1 - ledState;
  -- write state to D4
  gpio.write(ledPin, ledState)
end)


Sorry can't be of help with 2nd part of your query.

Gerry