ESP8266

From Review or Discard at Will
Revision as of 18:18, 16 September 2015 by Jeffa (talk | contribs) (add header to baud rate section)
Jump to: navigation, search

ESP8266

Resources

Arduino as serial terminal

/*
jha 9/9/2015

eXperiment with Esp8266
Use the arduino as a terminal to check / program the ESP8266
found the soft serial code here: https://www.arduino.cc/en/Tutorial/SoftwareSerialExample

"Works on my machine"

*/

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {

  Serial.begin(115200);
  mySerial.begin(115200); // the ESP8266 I bough on Amazon defaulted to 115,200 baud rate.

}

// the loop function runs over and over again forever
void loop() {
  
   if (mySerial.available()) {
    Serial.write(mySerial.read());
  }
  if (Serial.available()) {
    mySerial.write(Serial.read());
  }
}

Change and save default baud rate

I want to lower the baud rate because the arduino doesn't keep up with 115200 in the soft serial. I tried to issue the command "AT+UART_DEF=9600,8,1,0,0" to change and SAVE the baud rate but couldn't due to the unreliability of the soft serial at that speed. I was able to change the current baud rate (a shorter string) with "AT+CIOBAUD=9600" Then change baud rate for mySerial in the code, and then write with: "AT+UART_DEF=9600,8,1,0,0" Don't disturb the power while doing this. Then check by disconnecting power and restarting with the terminal set to 9600.