Last active
September 24, 2020 03:22
-
-
Save Jamesits/a3c128d050e6d3a16e9a to your computer and use it in GitHub Desktop.
Blink for ESP8266 ESP-12E NodeMCU 1.0 Board, Arduino IDE: Hello world and function tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See the comment for flashing instruction. | |
#include <ESP8266WiFi.h> | |
#define ONBOARD_LED 16 | |
#define ESP8266_LED 2 | |
// ADC_MODE(ADC_VCC); will result in compile error. use this instead. | |
int __get_adc_mode(void) { return (int) (ADC_VCC); } | |
void setup() | |
{ | |
pinMode(ONBOARD_LED, OUTPUT); | |
pinMode(ESP8266_LED, OUTPUT); | |
Serial.begin(115200); | |
// Print Wi-Fi Information | |
WiFi.printDiag(Serial); | |
// Print VCC voltage | |
Serial.print("Current VCC: "); | |
Serial.println(ESP.getVcc()); | |
} | |
void loop() | |
{ | |
digitalWrite(ONBOARD_LED, HIGH); | |
digitalWrite(ESP8266_LED, HIGH); | |
Serial.println("LED on"); | |
delay(500); | |
digitalWrite(ONBOARD_LED, LOW); | |
digitalWrite(ESP8266_LED, LOW); | |
Serial.println("LED off"); | |
delay(500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tested on Arduino IDE 1.6.7 or later.
Install Driver
USB to UART driver: http://cn.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx
Config
File - Preferences - Additional Boards Managers URLs:
http://arduino.esp8266.com/stable/package_esp8266com_index.json
Tools -> Board -> Boards Manager -> search
ESP8266
and installTools - Board: NodeMCU 1.0 (ESP-12E Module)
Tools - CPU Freq: 80MHz
Tools - Flash size: 4M (3M SPIFFS)
Tools - Upload speed: 921600 (115200 is also OK)
Tools - Port: select the port it is connected to.
Flashing
Now try to upload this code.
In most cases, it can be flashed directly. However, if you see the following error:
Try press and hold FLASH, press RESET, release RESET, release FLASH, then click Upload from Arduino IDE.
Result
2 LEDs (on both ESP module and the extension board) should flash 2 times per second.
Check Tools -> Serial Monitor (Set baudrate to the same value as in line 14 of the code), you should see Wi-Fi status, current voltage and LED switch status.