Node MCU:

fullsizerender

Pin Diagram:

ntd4t

Advantages of Arduino:

  • Inexpensive – Arduino boards are relatively inexpensive compared to other microcontroller platforms. The least expensive version of the Arduino module can be assembled by hand, and even the pre-assembled Arduino modules cost less than $50
  • Cross-platform – The Arduino Software (IDE) runs on Windows, Macintosh OSX, and Linux operating systems. Most microcontroller systems are limited to Windows.
  • Simple, clear programming environment – The Arduino Software (IDE) is easy-to-use for beginners, yet flexible enough for advanced users to take advantage of as well. For teachers, it’s conveniently based on the Processing programming environment, so students learning to program in that environment will be familiar with how the Arduino IDE works.
  • Open source and extensible software – The Arduino software is published as open source tools, available for extension by experienced programmers. The language can be expanded through C++ libraries, and people wanting to understand the technical details can make the leap from Arduino to the AVR C programming language on which it’s based. Similarly, you can add AVR-C code directly into your Arduino programs if you want to.
  • Open source and extensible hardware – The plans of the Arduino boards are published under a Creative Commons license, so experienced circuit designers can make their own version of the module, extending it and improving it. Even relatively inexperienced users can build the breadboard version of the module in order to understand how it works and save money.

References

Install 1.6.5 IDE:

There are many versions of IDE’s but it not specific to use a particular one. I preferred 1.6.5.

Install IDE

USB Driver:

While installing IDE, a prompt containing an option to install a driver that is necessary for USB compatibility with the device and Arduino.

preferences

When you’ve restarted, select Adafruit HUZZAH ESP8266 from the Tools->Board dropdown.

80 MHz as the CPU frequency (you can try 160 MHz overclock later).

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.

The matching COM/serial port for your FTDI or USB-Serial cable.We’ll begin with the simple blink test. Enter this into the sketch window (and save since you’ll have to)

void setup() {
pinMode(0, OUTPUT);
}
void loop() {
digitalWrite(0, HIGH);
delay(500);
digitalWrite(0, LOW);
delay(500);
}

 

Now you’ll need to put the board into bootload mode. You’ll have to do this before each upload. There is no timeout for bootload mode, so you don’t have to rush!

  1. Hold down the GPIO0 button, the red LED will be lit
  2. While holding down GPIO0, click the RESET button
  3. Release RESET, then release GPIO0
  4. When you release the RESET button, the red LED will be lit dimly, this means it is ready to bootload

Once the ESP board is in bootload mode, upload the sketch via the IDE

references

Experiments:

Requirements:

  • DHT sensor
  • LED
  • Resistors
  • Breadboard
  • NODEMCU
  • Arduino 1.6.4 IDE

Blinking a LED: 

blink

TEMP & HUMIDITY by using NodeMCU:
#include <SimpleDHT.h>
int pinDHT11 = 0;
SimpleDHT11 dht11;
void setup() {
  Serial.begin(115200);
}
void loop() {
  Serial.println(“=================================”);
  Serial.println(“Sample DHT11…”);
  byte temperature = 0;
  byte humidity = 0;
  if (dht11.read(pinDHT11, &temperature, &humidity, NULL)) {
    Serial.print(“Read DHT11 failed.”);
    return;
  }
  Serial.print(“Sample OK: “);
  Serial.print((int)temperature); Serial.print(” *C, “);
  Serial.print((int)humidity); Serial.println(” %”);
  delay(1000);
}

DHT11.PNG

LED indication of temperature:

Circuit:

DHT’s 3v pin and GND has to be connected to 3v and GND of Arduino respectively.

DHT’s data pin to the I/O pin of Arduino and add a resistor for the data and 3v pins.

Connect the each LEDs anode to one I/O pin of Arduino.

FullSizeRender (1)

Yellow light indicates temperature less than 20 celsius

White light indicates temperature between 20 and 30 celsius

Red light indicates temperature  greater than 30 celsius

if((int)temperature >= 30){
digitalWrite(4, HIGH);
delay(500);
digitalWrite(4, LOW);
delay(500);
}
if((int)temperature < 30 && (int)temperature > 20){
digitalWrite(5, HIGH);
delay(500);
digitalWrite(5, LOW);
delay(500);
}
if((int)temperature <= 20){
digitalWrite(16, HIGH);
delay(500);
digitalWrite(16, LOW);
delay(500);
}

Insert the above conditional statements in the loop function of the above experiment.

Depending upon the temperature different LED glows.

Advertisements