Using nodeMCU ESP2866 Boards with Arduino IDE

What we want to achieve

We love the nodeMCU ESP8266 boards, especially with Lua.

But Lua is not everyone's cup of tea and we want to use NodeMCU straight out of the box with the Arduino IDE to upload sketches.

Using a nodeMCU ESP8266 development board and Arduino IDE we will upload a small sketch which will flash the Built-in LED as well as output the available WiFi Access Points. This is the same sketch to test our boards before sending them out to you.

Requirements

    Restrictions

    How to

     

    1. Connect your NodeMCU to your computer and fire up Arduino IDE
    2. In the Arduino IDE - under "Preferences" add as "Additional Boards Manager URL" the URL http://arduino.esp8266.com/stable/package_esp8266com_index.json
      Selecting ESP8266 in Arduino IDE
      and press OK (twice)
    3. Go to Tools -> Board -> Boards Manager
      Select Board Manager in Arduino IDE
    4. Type "ESP8266" in the search field and then install
      Select ESP8266 Support for ArduinoIDE
    5. Go To Tools -> Boards and select NodeMCU 1.0
      Selecting NodeMCU ESP8266 in Arduino IDE
    6. Upload the sketch below
      Upload Arduino IDE Sketch to NodeMCU ESP8266
    7. Open Serial Monitor to see the WiFi APs found.
    8. Observe the Built-in LED Flash


    Code
     

    /*
     *  Test sketch to validate NodeMCU ESP8266 is working
     *  
     *  Server On The Move
     */
    #include "ESP8266WiFi.h"
     
    void setup() {
      Serial.begin(115200);
     
      // Enable station mode and - just in case - disconnect from previous Wifi
      WiFi.mode(WIFI_STA);
      WiFi.disconnect();
      delay(100);
     
      Serial.println("Setup complete");
    
      // Set Built-in LED to output
      pinMode(LED_BUILTIN, OUTPUT);
    }
     
    void loop() {
      Serial.println("Start Scanning - please stand-by");
     
      int n = WiFi.scanNetworks(); // how many did we find ?
      
      Serial.println("Scanning complete");
    
      // nothing found :-(
      if (n == 0)
        Serial.println("No Networks found.");
      else
      // found something
      {
        Serial.print("Networks found: ");
        Serial.println(n);
        for (int i = 0; i < n; ++i)
        {
          // Show each SSID and its RSSI (quality of network).
          // Mark encrypted networks with a "*"
          Serial.print(i + 1);
          Serial.print(": ");
          Serial.print(WiFi.SSID(i));
          Serial.print(" (");
          Serial.print(WiFi.RSSI(i));
          Serial.print(")");
          Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE)?" ":"*");
          delay(10);
        }
      }
      Serial.println("Performing Flash of BUILTIN LED");
    
      // Do LED blink
      digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
      delay(250);                       // wait for a second
      digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
      delay(150);                       // wait for a second
      digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
      delay(250);                       // wait for a second
      digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
      delay(150);                       // wait for a second
      digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
      delay(500);                       // wait for a second
      digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
      
      // Wait a bit before scanning again
      delay(5000);
    }

    Leave a Reply

    All blog comments are checked prior to publishing