IoT Bytes

Bits and Bytes of IoT

NodeMCU

Pradeep Singh | 28th March 2016

nodemcu

NodeMCU is an open source IoT platform. It uses the Lua scripting language. It is based on the eLua project, and built on the ESP8266 SDK 1.4. It uses many open source projects, such as lua-cjson, and spiffs. It includes firmware which runs on the ESP8266 Wi-Fi SoC, and hardware which is based on the ESP-12 module.

Resources:

Following are some of the important links for NodeMCU –

NodeMCU Home Page

GitHub Repository for NodeMCU Firmware

NodeMCU API Guide

NodeMCU Documentation

Tools:

Following are some of the important tools for NodeMCU module –

ESPlorer IDE for NodeMCU

NodeMCU Flasher

Termite RS232 Terminal

LuaLoader

2 thoughts on “NodeMCU

  1. Hi sir,
    I tried communicating Node MCU with RFID EM 18 module and Im facing power issue please help me to troubleshoot the issue by suggesting the power supply mode

    Like

  2. Hi sir,
    I have tried using the below program but after execution im getting compiler error please i request you to correct my mistake in the code

    ESP 8266 Node MCU and RFID EM 18 Module

    #include
    #include

    const char* ssid = “info”;
    const char* pwd = “infotech”;

    const char* base_host = “10.0.1.66”;

    void setup() {
    Serial.begin(115200);
    delay(10);

    Serial.println();
    Serial.println();
    Serial.print(“Connecting to “);
    Serial.println(ssid);

    WiFi.begin(ssid, pwd);

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

    sEventsReceived[WIFI_EVENT_STAMODE_CONNECTED] = 0;
    sEventsReceived[WIFI_EVENT_STAMODE_DISCONNECTED] = 0;
    sEventsReceived[WIFI_EVENT_STAMODE_GOT_IP] = 0;

    WiFi.onEvent(onWiFiEvent, WIFI_EVENT_STAMODE_CONNECTED);
    WiFi.onEvent(onWiFiEvent, WIFI_EVENT_STAMODE_DISCONNECTED);
    WiFi.onEvent(onWiFiEvent, WIFI_EVENT_STAMODE_GOT_IP);
    WiFi.onEvent(onWiFiEvent, WIFI_EVENT_ANY);

    delay(500);
    Serial.print(“.”);
    }

    Serial.println(“”);
    Serial.println(“WiFi connected”);
    Serial.println(“IP address: “);
    Serial.println(WiFi.localIP());
    REQUIRE(sEventsReceived[WIFI_EVENT_STAMODE_CONNECTED] == 2);
    REQUIRE(sEventsReceived[WIFI_EVENT_STAMODE_DISCONNECTED] >= 2 && sEventsReceived[WIFI_EVENT_STAMODE_DISCONNECTED] % 2 == 0);
    REQUIRE(sEventsReceived[WIFI_EVENT_STAMODE_GOT_IP] == 2);

    String events;

    auto handler1 = WiFi.onStationModeConnected([&](const WiFiEventStationModeConnected& evt){
    events += “connected,”;
    });
    auto handler2 = WiFi.onStationModeDisconnected([&](const WiFiEventStationModeDisconnected& evt){
    if (events.length()) {
    events += “disconnected,”;
    }
    });
    auto handler3 = WiFi.onStationModeGotIP([&](const WiFiEventStationModeGotIP& evt){
    events += “got_ip,”;
    });

    }

    char hanger_data[12];

    void loop() {
    delay(50);

    if(Serial.available() >= 1)
    {

    if (server.hasClient()){
    for(i = 0; i 2)
    {
    Serial.read();
    Serial.read();
    char data = Serial.read();
    hanger_name[i++] = data;
    }

    while(Serial.read() != -1); // Clear data in queue
    hanger_name[i] = ‘\0’;

    Serial.print(“connecting to “);
    Serial.println(base_host);

    WiFiClient client;
    const int httpPort = 80;
    if (!client.connect(base_host, httpPort)) {
    Serial.println(“connection failed”);
    return;
    }

    String url = “/rfid_iot/piecelogs.php”;
    url += “?id=1&linename=1&linelocation=sewing1&tablename=1&hanger_name=”;
    url += hanger_name;

    Serial.print(“Requesting URL: “);
    Serial.println(url);

    client.print(String(“GET “) + url + ” HTTP/1.1\r\n” +
    “base_host: ” + base_host + “\r\n” +
    “Connection: close\r\n\r\n”);
    unsigned long timeout = millis();
    while (client.available() == 0) {
    if (millis() – timeout > 22000) {
    client.stop();
    return;
    }
    }

    while(client.available()){
    String line = client.readStringUntil(‘\r’);
    Serial.print(line);
    }

    Serial.println();
    Serial.println(“closing connection”);

    while(Serial.read() != -1); // Clear data in queue
    }
    }

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: