somewhere you can read
...attempt to call field 'alarm'. (a nil value ...
followed by some stack trace
that could be the reason of all the garbage on the serial interface
remove that file and try this, it's a trivial led blink every 5 secs
-- init.lua
led_on = false
gpio.mode(4, gpio.OUTPUT)
gpio.write(4, gpio.HIGH)
periodic_task = function()
if (led_on) then
-- turn off the led
print("led off")
gpio.write(4, gpio.HIGH)
led_on = false
else
-- turn on the led
print("led on")
gpio.write(4, gpio.LOW)
led_on = true
end
tmr.create():alarm(5000, tmr.ALARM_SINGLE, periodic_task)
end
print("now running the application")
tmr.create():alarm(5000, tmr.ALARM_SINGLE, periodic_task)