In this very simple example, I will setup a NodeMCU to connect to my MQTT broker and light its LED depending on received messages. This gives a very simple IOT device to test the MQTT protocol.
This is the code to blink a LED on a GPIO on an ESP8266-1 loaded with NodeMCU. What is of particular interest is the GPIO0 and GPIO2 values. GPIO0=3 GPIO2=4 pin = GPIO0 gpio.mode(pin, gpio.OUTPUT) lighton=0 tmr.alarm(0,1000,1,function() if lighton==0… Continue Reading →