Post topics, source code that relate to the Arduino Platform

User avatar
By ricg
#22655 Actually i was interested in seeing the arduino source you are using to setup your AP and Wifi.
When sending the esp a cmd it's important to allow it to complete before sending it another. I call a routine that looks for a string returned by the esp to indicate it is in a state ready for the next cmd. It times out if it doesn't see the expected string. See waitcmd().
Here is the code i'm using to setup an AP and also to connect to wifi and setup as a server:

int waitcmd(char *s, unsigned short timeout) {
unsigned long tm=millis();
while( 1 ) {
if( millis() - tm >= timeout ) {
Serial.println(F("Timed Out"));
return 0;
}
if (espSerial.find(s)) {
Serial.println(s);
return 1;
}
}
}

void access_point() {
Serial.println(F("SETUP ACCESS POINT"));
Serial.println(F("AT+RST"));
espSerial.println(F("AT+RST"));
waitcmd("thinker.com",10000);

Serial.println(F("AT+CWMODE=2"));
espSerial.println(F("AT+CWMODE=2"));
waitcmd("OK",1000);

Serial.println(F("AT+CIPMUX=1"));
espSerial.println(F("AT+CIPMUX=1"));
waitcmd("OK",1000);

Serial.println(F("AT+CWSAP=\"esp826605\",\"12345678\",1,0"));
espSerial.println(F("AT+CWSAP=\"esp826605\",\"12346785\",1,0"));
waitcmd("OK",1000);

Serial.println(F("AT+CIFSR"));
espSerial.println(F("AT+CIFSR"));

}

int server() {
int cnt=0;
Serial.println(F("SETUP SERVER"));
Serial.println(F("AT+RST"));
espSerial.println(F("AT+RST"));
cnt+=waitcmd("thinker.com",10000);

Serial.println(F("AT+CWMODE=1"));
espSerial.println(F("AT+CWMODE=1"));
cnt+=waitcmd("OK",500);

Serial.println(F("AT+CWJAP=\"xxxxx\",\"xxxxxx\""));
espSerial.println(F("AT+CWJAP=\"xxxxx\",\"xxxxxx\""));
cnt+=waitcmd("OK",10000);
Serial.println(F("AT+CIPMUX=1"));
espSerial.println(F("AT+CIPMUX=1"));
cnt+=waitcmd("OK",500);
Serial.println(F("AT+CIPSERVER=1,8000"));
espSerial.println(F("AT+CIPSERVER=1,8000"));
cnt+=waitcmd("OK",500);
Serial.println(F("AT+CIPSTO=15"));
espSerial.println(F("AT+CIPSTO=15"));
cnt+=waitcmd("OK",500);
Serial.println(F("AT+CIFSR"));
espSerial.println(F("AT+CIFSR"));
return cnt;
}
User avatar
By Kreativessinness
#66056 hello ! Recently i am working with esp-05 and I am encountering some issues . i have connected my module as exactly mentioned in the code and the post but i donot receive any output on my serial monitor . I am using an external power supply and converting it down to 3.3V . the gnd pin goes to external ground . The Rx pin of esp is connected to TX of arduino uno through a level divider and the TX of the esp is connected directly to the Rx of arduino uno. It would be really nice if someone could help me out with this. I want to test my module to know its firmware version. Also the Rx pin since is active low i have shifted it to rail using a pull up resistor