ESP8266 on Arduino Nano

Trying to get Arduino Nano to work with ESP8266 (ESP-01). The Nano won’t power the ESP8266 from it’s onboard 3.3V power like the Uno does. The red power light and blue comm light on the ESP board blink for a split second, then it goes dark. Many sources say you need a dedicated power supply or you risk damaging both the Arduino and ESP boards. These boards are cheap, so I’m trying everything. Even more sources say to be careful not to connect 5V to the ESP board. Well, this is what I’m doing. It is working so far, but I noticed the ESP board is pretty hot to the touch. It has been running my test program, which makes repeated HTTP requests as fast as the board can execute them, for about 30 minutes. In other words, it is taxing the ESP board pretty hard. That said, I’ve seen zero errors. While this is probably bad for the board, 5V could work for some applications. At least this way there are fewer components. I guess I’ll leave it running a while and see if it gets fried.

IMG_7100[1]

Connections:
ESP8266 <--> Nano
GND <--> GND
VCC <--> 5V
CH_PD <--> 5V
RX <--> D10
TX <--> D11

Using SoftwareSerial on pins 10/11.

/* SETUP WIFI - ESP8266 (ESP-01)

http://www.ebay.com/itm/221589414331?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

http://www.ebay.com/usr/worldchips?_trksid=p2047675.l2559

1
#include
SoftwareSerial softSerial(10, 11); // RX, TX
String WSSID = "xxxxxxxxxxxx";
String WPASS = "xxxxxxxxxxxx";
bool r;

void setup() {
/* SETUP SERIAL COMMUNICATION */
espSerialSetup();
delay(2000); // Without this delay, sometimes, the program will not start until Serial Monitor is connected
r = espSendCommand( "AT+CIFSR" , "OK" , 5000 );
if( !r ) {
r = espSendCommand( "AT+CWMODE=1" , "OK" , 5000 );
r = espSendCommand( "AT+CWJAP=\""+WSSID+"\",\""+WPASS+"\"" , "OK" , 15000 );
}
}

void loop(){

r = espSendCommand( "AT+CIPSTART=\"TCP\",\"108.59.11.102\",80" , "OK" , 5000 );
String getRequest = "GET /shiznic/ HTTP/1.1\r\nHost: www.rootpower.com\r\n";
int getRequestLength = getRequest.length() + 2; // add 2 because \r\n will be appended by SoftwareSerial.println().
r = espSendCommand( "AT+CIPSEND=" + String(getRequestLength) , "OK" , 5000 );
r = espSendCommand( getRequest , "+IPD" , 15000 );
//r = espSendCommand( getRequest , "world" , 15000 ); // page should respond with Hello, world.
if( !r ) {
Serial.println( "Something wrong...Attempting reset...");
espSendCommand( "AT+RST" , "ready" , 20000);
espSendCommand( "AT+CWMODE=1" , "OK" , 5000 );
espSendCommand( "AT+CWJAP=\""+WSSID+"\",\""+WPASS+"\"" , "OK" , 15000 );
}

delay(3000);

}

void espSerialSetup() {

// change baud rate so SoftwareSerial works better -- need a certain version of ESP for this to work and be retained after power cycle
// make sure Serial Monitor port speed is set to 9600
softSerial.begin(115200); // default baud rate for ESP8266
delay(1000);
softSerial.println("AT+CIOBAUD=9600");
delay(1000);
softSerial.begin(9600);
Serial.begin(9600);

}

bool espSendCommand(String cmd, String goodResponse, unsigned long timeout) {
Serial.println("espSendCommand( " + cmd + " , " + goodResponse + " , " + String(timeout) + " )" );
softSerial.println(cmd);
unsigned long tnow = millis();
unsigned long tstart = millis();
unsigned long execTime = 0;
String response = "";
char c;
while( true ) {
if( tnow > tstart + timeout ) {
Serial.println("espSendCommand: FAILED - Timeout exceeded " + String(timeout) + " seconds" );
if( response.length() > 0 ) {
Serial.println("espSendCommand: RESPONSE:");
Serial.println( response );
} else {
Serial.println("espSendCommand: NO RESPONSE");
}
return false;
}
c = softSerial.read();
if( c >= 0 ) {
response += String(c);
if( response.indexOf(goodResponse) >= 0 ) {

execTime = ( millis() - tstart );
Serial.println("espSendCommand: SUCCESS - Response time: " + String(execTime) + "ms");
Serial.println("espSendCommand: RESPONSE:");
Serial.println(response);
while(softSerial.available() > 0) {
Serial.write(softSerial.read());
}
return true;
}
}
tnow = millis();
}
}

Published by

Leave a Reply

Your email address will not be published. Required fields are marked *

* Copy This Password *

* Type Or Paste Password Here *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>