Sunday, 16 June 2019


ESP 8266 interfacing with Arduino uno




Pin diagram of ESP8266:
Specification :
  • 802.11 b / g / n wireless standards;
  • STA / AP modes support ;
  • TCP / IP protocol stack, One socket;
  • Supports standard TCP / UDP Server and Client;
  • Supports serial port baud rate configuration: 1200/2400/4800/9600/19200/38400/57600/74800/115200 bps;
  • Supports serial data bits: 5/6/7/8 bits;
  • Supports serial parity: none;
  • Supports serial stop bits: 1/2 bit;
  • Pin-compatible with Arduino UNO, Mega;
  • Arduino Pinout 2/3/4/5/6/7/8/9/10/11/12/13;
  • ESP8266 GPIO Pinout 0/2/4/5/9/10/12/13/14/15/16 / ADC / EN / * UART TX / UART RX;
  • KEY button: modes configuration;
  • Dual-Ports DIP switches: switching Arduino and ESP8266;
  • WiFi operation current: continuous transmission operation: ≈70mA (200mA MAX), idle mode: <200uA;
  • Serial WiFi transmission rate: 110-460800bps;
  • Temperature: -40℃ ~ + 125 ℃;
  • Humidity: 10%-90% non-condensing;
  • Weight: about 20g (0.7oz);

Code: ESP 8266 interfacing with Arduino uno


/**********************************************************
Expt. ***: ESP8266 interfacing with Arduino uno
Platform:  Arduino IDE & ESP8266.
College: PICT
**********************************************************/       
#include <SoftwareSerial.h>

SoftwareSerial esp8266(2, 3); 2-> Rx, 3-> Tx

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  Serial.println("Started");

  // set the data rate for the SoftwareSerial port
  esp8266.begin(115200);
  esp8266.write("AT\r\n");
}

void loop() {
  if (esp8266.available()) {
    Serial.write(esp8266.read());
  }
  if (Serial.available()) {
    esp8266.write(Serial.read());
  }
}





/**********************************************************
Expt. ***: ESP8266 interfacing with Arduino uno
Platform:  Arduino IDE & ESP8266.
College: PICT
**********************************************************/       
#include <SoftwareSerial.h>

const byte rxPin = 2; // Wire this to Tx Pin of ESP8266
const byte txPin = 3; // 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
}

void loop() {
  Serial.println("Sending an AT command...");
  ESP8266.println("AT");
  delay(30);
  while (ESP8266.available()){
     String inData = ESP8266.readStringUntil('\n');
     Serial.println("Got reponse from ESP8266: " + inData);
  }  
}

No comments:

Post a Comment