Day 12: Add NodeMCU Esp8266 to Arduino IDE

  Day 12. Add NodeMCU Esp8266 to Arduino IDE


Task

1) Add board Esp8266 to Arduino IDE
2) Upload first blink Code to NodeMCU
3) Use LED and Push buttons on NodeMCU
4) Upload Code to ESP8266 Chip

Introducing the ESP8266 NodeMCU

What is an ESP8266 NodeMCU? 

The ESP8266 is a low-cost Wi-Fi chip developed by Espressif Systems.

ESP8266 NodeMCU Espressif Systems

It can be used as a standalone device, or as a UART to Wi-Fi adaptor to allow other microcontrollers to connect to a Wi-Fi network. For example, you can connect an ESP8266 to an Arduino to add Wi-Fi capabilities to your Arduino board. The most practical application is using it as a standalone device.

With the ESP8266, you can control inputs and outputs as you would do with an Arduino, but with Wi-Fi capabilities. This means you can bring your projects online, which is great for home automation and internet of things applications. Why is the ESP8266 so popular? Mainly for the following reasons:


Low-cost: you can get ESP8266 boards starting at $3 (or less) depending on the model.

Low-power: the ESP8266 consumes very little power when compared with other microcontrollers and can even go into deep sleep mode to consume less power;

Wi-Fi: the ESP8266 can generate its own Wi-Fi network (access point) or connect to other Wi-Fi networks (station) to get access to the internet. This means the ESP8266 can access online services to make HTTP requests or save data to the cloud, for example. It can also act as a web server so that you can access it using a web browser and be able to control and monitor your boards remotely.

Compatible with the Arduino “programming language”: those that are already familiar with programming the Arduino board, were happy to know that they can program the ESP8266 in the Arduino style.

Compatible with MicroPython: you can program the ESP8266 with MicroPython firmware, which is a re-implementation of Python 3 targeted for microcontrollers and embedded systems.



What can you do with an ESP8266?


Here’s a short list of what you can do with an ESP8266:

Create a web server to control outputs;

Create a web server to display sensor readings;

Send HTTP requests;

Control outputs, read inputs, and set interrupts;

Datalogging projects;

Communicate with third-party services;

Create web applications;

Send emails, notifications, post tweets, etc.

And much more.


ESP8266 Arduino IDE

Installing ESP8266 Board in Arduino IDE (Windows, Mac OS X, Linux)

The ESP8266 community created an add-on for the Arduino IDE that allows you to program the ESP8266 using the Arduino IDE and its programming language.


Download Arduino IDE


Prerequisites: Arduino IDE Installed

Before starting this installation procedure, make sure you have the latest version of the Arduino IDE installed in your computer. If you don’t, uninstall it and install it again. Otherwise, it may not work.

Install ESP8266 Add-on in Arduino IDE

To install the ESP8266 board in your Arduino IDE, follow these next instructions:


In your Arduino IDE, go to File> Preferences


Install ESP8266 Board add-on in Arduino IDE open preferences

Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into the “Additional Boards Manager URLs” field as shown in the figure below. Then, click the “OK” button:


Install ESP8266 Board add-on in Arduino IDE enter URL

Note: if you already have the ESP32 boards URL, you can separate the URLs with a comma as follows:


https://dl.espressif.com/dl/package_esp32_index.json,

 http://arduino.esp8266.com/stable/package_esp8266com_index.json

Open the Boards Manager. Go to Tools > Board > Boards Manager…

Install ESP8266 Board add-on in Arduino IDE Open boards manager

Search for ESP8266 and press install button for the “ESP8266 by ESP8266 Community“:



Install ESP8266 Board add-on in Arduino IDE search ESP8266

That’s it. It should be installed after a few seconds.


ESP8266 Board add-on in Arduino IDE installed


Uploading the Sketch

Uploading the Sketch to the ESP-12E


If you’re using an ESP-12E NodeMCU Kit, uploading the sketch is very simple, since it has built-in programmer. Plug your board to your computer. Make sure you have the right board selected:



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

int pin = 2;

void setup() {
  // initialize GPIO 2 as an output.
  pinMode(pin, OUTPUT);
}

void loop() {

  digitalWrite(pin, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(pin, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}

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

Schematic

If you’re using an ESP8266-12E

Connect an LED to your ESP8266, as shown in the following schematic diagram. The LED should be connected to GPIO 2 (D4).


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

Good Pins and Bad Pins of NodeMCU


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


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


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


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

No comments:

Post a Comment

Arduion Uno pin out