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
- Our nodeMCU ESP8266 development board
- Arduino IDE
Restrictions
- This tip is focused on Arduino IDE and our nodeMCU ESP8266
How to
- Connect your NodeMCU to your computer and fire up Arduino IDE
- In the Arduino IDE - under "Preferences" add as "Additional Boards Manager URL" the URL http://arduino.esp8266.com/stable/package_esp8266com_index.json
and press OK (twice) - Go to Tools -> Board -> Boards Manager
- Type "ESP8266" in the search field and then install
- Go To Tools -> Boards and select NodeMCU 1.0
- Upload the sketch below
- Open Serial Monitor to see the WiFi APs found.
- 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); }