tutorial
Introduction to Nodemcu (ESP8266) on Arduino IDE
NodeMCU is a development board featuring the popular ESP8266 WiFi chip. As it turns out, you can program the ESP8266 just like any other microcontroller. Its obvious advantage over the Arduino or PIC is that it can readily connect to the Internet via WiFi. However, the ESP8266 breakout board has limited pins although the chip itself has a lot of output ports. The NodeMCU solves this problem by featuring 10 GPIO pins each capable of using PWM, I2C and 1-wire interface.
This ESP8266 development board really looks like an Arduino Nano. Speaking of Arduino, another advantage of this board is that you can connect it directly to your PC or Mac and program it like an Arduino.
Connecting NODEMCU to the Computer:
You need a USB micro B cable to connect the board. Once you plugged it in, a blue LED will start flashing. If your computer is not able to detect the NodeMCU board, you may need to download the driver on
LINK:
NOTE:
“Download the Universal Version”.
In Arduino IDE:
You need to have at least Arduino IDE version 1.6.4 to proceed with this.
Go to File > Preferences. In the "Additional Boards Manager URLs" field, type (or copy-paste) http://arduino.esp8266.com/stable/package_esp8266com_index.json. Don't forget to click OK!
Then go to Tools > Board > Board Manager. Type "esp8266" in the search field. The entry "esp8266 by ESP8266 Community" should appear. Click that entry and look for the install button on the lower right.
Once the download is complete, you can start coding!
Setup ESP8266 Support:
When you’ve restarted, select NodeMCU 1.0 (or NodeMCU 0.9) from the Tools->Board dropdown Config the Board menu and choose the right Port for your device. CPU Frequency:80MHz, Flash Size:4M(3M SPIFFS), Upload Speed:115200 Now just proceed as the Arduino: Start your sketching! Note: 115200 baud upload speed is a good place to start – later on, you can try higher speeds but 115200 is a good safe place to start.
LED Blinking using NODEMCU:
First, we'll blink a LED connected to one of the digital pins of the board. But before that, you need to know that the pin names printed on the board are not the pin names we'll be using for our program. Here I'm using NodeMCU V1.0.
In this example, I'll connect the LED to D1 as it is printed on the board. D1 is GPIO5 according to the image above. And so here's my code (which is basically the example Blink code in Arduino):
Connection Diagram:
Code:
void setup() {
// initialize digital pin 5 as an output.
pinMode(5, OUTPUT);
}
void loop() {
digitalWrite(5, HIGH); // turn the LED on
delay(1000); // wait for a second
digitalWrite(5, LOW); // turn the LED off
delay(1000); // wait for a second
}
OUTPUT:
The LED will go on and off.
No comments:
Post a Comment