#22 NodeMCU: Begin with Lua Programming (LED Blinking) | APDaga Tech

IoT Tutorial #22 [ NodeMCU Tutorials #7 ]

NodeMCU ESP8266 comes with Lua firmware by default.

and if not, then you can change the firmware of NodeMCU ESP8266, steps are given in the previous post.


Here, I will demonstrate, how to run Lua program on NodeMCU ESP8266 for the first time.

Problem Statement:  

Blink LED connected to the NodeMCU using Lua programming.

Requirement:

1. NodeMCU ESP8266 Board
2. micro USB cable
3. LED
4. Resistor - 1k
5. Female to male relimate - 2 Nos.
6. Internet connection

NOTE: LED+ is Connected to D5 of NodeMCU ESP8266




Steps:

    1. Flash Fresh Lua firmware using NodeMCU Flasher (Click here to Check how) > Close Flasher

    2. Make below mentioned connections:
      LED       NodeMCU (ESP8266)
      LED+ to D5
      LED- to gnd

    3. Keep NodeMCU connected > Open ESPlorer > A new ESPlorer window will open.
      "Port" must be automatically detected there. Set Baud_rate = 9600

      NOTE: If PORT is not getting detected then you need to install drivers:
      https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers

      Click on "Open" to Check the firmware version of nodemcu.
      then click "RST" button on NodeMCU.

      It will show the Firmware version...

      Eg.
      NodeMCU 0.9.5 build 20150318 powered by Lua 5.1.4

      NOTE: If some program is already uploaded on the nodeMCU then It won't detect the firmware version.

      In that case, 
      Flash Lua (default) firmware (shown in step 3) of previous post and then try to detect it using above steps.

    4. Copy following code and Place it in the left black window of ESPlorer and save it with .lua extension:
      gpio.mode(5, gpio.OUTPUT)
      while true do
      gpio.write(5, gpio.HIGH)
      tmr.delay(1000000)
      gpio.write(5, gpio.LOW)
      tmr.delay(1000000)
      end

    5. Then Click on "Send to ESP"

    6. LED Connected to D5 pin of NodeMCU should Blink with 1 sec delay....




For Better understanding, you can watch the demonstration video
given below:

Downloads:

Download link is given in the Description of the YouTube video shown below.

Demonstration:







--------------------------------------------------------------------------------

Click here to see more codes for Raspberry Pi 3 and similar Family.
&
Click here to see more codes for NodeMCU ESP8266 and similar Family.
&
Click here to see more codes for Arduino Mega (ATMega 2560) and similar Family.

Feel free to ask doubts in the comment section. I will try my best to solve it.
If you find this helpful by any mean like, comment and share the post.
This is the simplest way to encourage me to keep doing such work.

Thanks and Regards,
-Akshay P. Daga

إرسال تعليق (0)
أحدث أقدم