ESP8266 Arduino

From ElectroDragon
Jump to: navigation, search

Refer to the default github page.

Supported Board

Supported Board

  • Adafruit HUZZAH ESP8266 (ESP-12)
  • NodeMCU 0.9
  • NodeMCU 1.0
  • Olimex MOD-WIFI-ESP8266-DEV
  • Olimex MOD-WIFI-ESP8266
  • SparkFun ESP8266 Thing
  • SweetPea ESP-210
  • Generic ESP8266 modules

How to install

New version can install from board manager (search esp8266)

  • Arduino IDE 1.6.0 or later
  • Installing
  1. Create a folder named hardware in your Sketchbook folder, usually:
  2. Linux: ~/Sketchbook
  3. OS X: ~/Documents/Arduino
  4. Windows: ~/My Document/Arduino
  5. Download a release
  6. Extract release
  7. Place esp8266com folder in hardware folder created in step 1.
  8. Start or restart the Arduino IDE

Quick Start

  • Choose correct board

Esp8266 arduino selection.png

  • Demo code

Blink esp on board io12 by at-commands

#include <SoftwareSerial.h>
 
const byte rxPin = 3; // Wire this to Tx Pin of ESP8266
const byte txPin = 2; // Wire this to Rx Pin of ESP8266
 
// We'll use a software serial interface to connect to ESP8266
SoftwareSerial ESP8266 (rxPin, txPin);
 
void setup() {
  Serial.begin(115200);
  ESP8266.begin(115200); // Change this to the baudrate used by ESP8266
  delay(1000); // Let the module self-initialize
  pinMode(12, OUTPUT);  // set the io pin 16 to output
}
 
void loop() {
  Serial.println("Sending an AT command...");
  ESP8266.println("AT+CIOWRITE=12,1");
  delay(30);
  while (ESP8266.available()){
     String inData = ESP8266.readStringUntil('\n');
     Serial.println("Got reponse from ESP8266: " + inData);
  } 
  delay(1000);
  ESP8266.println("AT+CIOWRITE=12,0");
  delay(30);
  while (ESP8266.available()){
     String inData = ESP8266.readStringUntil('\n');
     Serial.println("Got reponse from ESP8266: " + inData);
  }
  delay(1000); 
}
  • enter into bootloader mode of the board first
  • Click to upload the sketch
  • Now the LED on ESP8266 pin16 will start to blink
  • For more supported function please refer to the github page.

Esp8266 upload.png}