Introduction
In this tutorial, We are going to learn how to use Arduino IDE to program NodeMCU.
What is NodeMCU? NodeMCU is an open source IoT platform. It includes firmware which runs on the ESP8266 Wi-Fi SoC from Espressif Systems, and hardware which is based on the ESP-12 module. The term “NodeMCU” by default refers to the firmware rather than the development kits. The firmware uses the Lua scripting language. Wikipedia
Hardware Required
Developer: ESP8266 Opensource Community
Yes, by default NodeMCU uses Lua scripting language to program NodeMCU, here We are going to learn how to program NodeMCU using Arduino C++ language.
-- Pin definition local pin = 7 -- GPIO 13 local status = gpio.LOW local duration = 1000 -- 1 second duration for timer -- Initialising pin gpio.mode(pin, gpio.OUTPUT) gpio.write(pin, status) -- Create an interval tmr.alarm(0, duration, 1, function () if status == gpio.LOW then status = gpio.HIGH else status = gpio.LOW end gpio.write(pin, status) end) |
The above is a sample Lua script to blink an LED connected to the 7th pin ie GPIO 13 of NodeMCU.As you can see here the physical pin and the GPIO pin numbers are different in NodeMCU, below is a chart of the pin assignments,
NodeMCU V 1.0 Pinout |
NodeMCU v0.9 Pinout |
Coding in Arduino IDE
Testing
Step 3: Select and Board and Port and upload the program, that’s it, now the builtin LED should start blinking.
Troubleshooting
Video Tutorial
To buy electronic components order from UTSOURCE