Introduction: IoT - Arduino – NodeMCU ESP-12 ESP8266 - EN

Picture of IoT - Arduino – NodeMCU ESP-12 ESP8266 - EN

By: @IoT_Live

Spanish version:

A few days ago, in the midst of my searches to try to

solve some problems with the ESP8266 module, I found some forums that made mention to the ESP8266 NodemCU based on the LUA programming language. It struck me so much, that I bought some to test its functionality. Really were economic (USD4, 73 on Aliexpress)

Some days I've been working with, and have obtained very good answers that with 11 GPIO and one analog ports availability and integrated WIFI, I have managed very easily programmed features that years ago we needed many hours of work, considerable sizes and expensive hardware.

Step 1:

Picture of

NodeMCU ESP-12 it is possible to program it even from

the Arduino IDE making thus use a tool already for my family was. To achieve this, use the version of Arduino IDE 1.6.7 downloaded from the official URL of Arduino and add in the Preferences option, additional URLs for cards corresponding to ESP8266 Manager.

Step 2:

Picture of

To reset the Arduino IDE, we have at our disposal ESP8266

modules to set them as if it were another Arduino module.

It is important to select other features that are enabled for these modules, in the picture, you can see the values that I'm using with ESP12 plate

To use the PIN, it was necessary to perform some tests, to obtain equivalencies of the pins, depending on how the East using, since the physical distribution and are different.

The basic examples that come with Arduino, operate
without any inconvenience. In the following example, use the following materials.

Placa: NodeMCU ESP-12 ESP8266

Sensor: DHT22

Arduino IDE 1.6.7

Step 3:

Picture of






#include "DHT.h"

#define DHTPIN 4

#define DHTTYPE DHT22


const char* ssid = "UNE_7586";

const char* password = "12345678";

ESP8266WebServer server(80);

const int led = 13;

void handleRoot() {

String message = "ESP8266 Server Nodemcu\n\n";

// Reading temperature or humidity takes about 250 milliseconds!

// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)

float h = dht.readHumidity();

// Read temperature as Celsius (the default)

float t = dht.readTemperature();

// Read temperature as Fahrenheit (isFahrenheit = true)

float f = dht.readTemperature(true);

// Check if any reads failed and exit early (to try again).

if (isnan(h) || isnan(t) || isnan(f)) {

Serial.println("Failed to read from DHT sensor!");



// Compute heat index in Fahrenheit (the default)

float hif = dht.computeHeatIndex(f, h);

// Compute heat index in Celsius (isFahreheit = false)

float hic = dht.computeHeatIndex(t, h, false);

message += "Humidity: ";

message += h;

message += " %\t";

message += "Temperature: ";

message += t;

message += " *C ";

message += f;

message += " *F\t";

message += "Heat index: ";

message += hic;

message += " *C ";

message += hif;

message += " *F \n";

digitalWrite(led, 1);

server.send(200, "text/plain", message);

digitalWrite(led, 0);


void handleNotFound(){

digitalWrite(led, 1);

String message = "File Not Found\n\n";

message += "URI: ";

message += server.uri();

message += "\nMethod: ";

message += (server.method() == HTTP_GET)?"GET":"POST";

message += "\nArguments: ";

message += server.args();

message += "\n";

for (uint8_t i=0; i

message += " " + server.argName(i) + ": " + server.arg(i) + "\n";


server.send(404, "text/plain", message);

digitalWrite(led, 0);


void setup(void){

pinMode(led, OUTPUT);

digitalWrite(led, 0);



WiFi.begin(ssid, password);


// Wait for connection

while (WiFi.status() != WL_CONNECTED) {





Serial.print("Connected to ");


Serial.print("IP address: ");


if (MDNS.begin("esp8266")) {

Serial.println("MDNS responder started");


server.on("/", handleRoot);

server.on("/inline", [](){

server.send(200, "text/plain", "this works as well");




Serial.println("HTTP server started");


void loop(void){



Step 4: The Result.

Picture of The Result.

The result is as follows:




gComunelloJr made it! (author)2016-03-06

Tks for all!

artmez (author)2016-01-08

This looks more like a draft and not the final version. The code is not compilable as it stands. I don't understand the closing remarks.