Post topics, source code that relate to the Arduino Platform

User avatar
By tao13
#2047 Hi all
I use arduino nano with esp module but not working. after AT+RST i don't received any message on serial port
Please give me your advices.Many many thanks.
I connected them like this (left nano , right esp)
3.3 v - vcc
gnd - gnd
tx - rx
rx - tx
3.3v - ch_pd (tried with and without this connection)


i use next sketch
#include <SoftwareSerial.h>
#define SSID "xxxxxxxx"
#define PASS "xxxxxxxx"
#define DST_IP "220.181.111.85" //baidu.com
SoftwareSerial dbgSerial(0, 1); // RX, TX // here i tried with 10,11 and 2,3
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(57600);
Serial.setTimeout(5000);
dbgSerial.begin(9600); //can't be faster than 19200 for softserial
dbgSerial.println("ESP8266 Demo");
//test if the module is ready
Serial.println("AT+RST");
delay(1000);
if(Serial.find("ready"))
{
dbgSerial.println("Module is ready");
}
else
{
dbgSerial.println("Module have no response.");
while(1);
}
delay(1000);
//connect to the wifi
boolean connected=false;
for(int i=0;i<5;i++)
{
if(connectWiFi())
{
connected = true;
break;
}
}
if (!connected){while(1);}
delay(5000);
//print the ip addr
/*Serial.println("AT+CIFSR");
dbgSerial.println("ip address:");
while (Serial.available())
dbgSerial.write(Serial.read());*/
//set the single connection mode
Serial.println("AT+CIPMUX=0");
}
void loop()
{
String cmd = "AT+CIPSTART=\"TCP\",\"";
cmd += DST_IP;
cmd += "\",80";
Serial.println(cmd);
dbgSerial.println(cmd);
if(Serial.find("Error")) return;
cmd = "GET / HTTP/1.0\r\n\r\n";
Serial.print("AT+CIPSEND=");
Serial.println(cmd.length());
if(Serial.find(">"))
{
dbgSerial.print(">");
}else
{
Serial.println("AT+CIPCLOSE");
dbgSerial.println("connect timeout");
delay(1000);
return;
}
Serial.print(cmd);
delay(2000);
//Serial.find("+IPD");
while (Serial.available())
{
char c = Serial.read();
dbgSerial.write(c);
if(c=='\r') dbgSerial.print('\n');
}
dbgSerial.println("====");
delay(1000);
}
boolean connectWiFi()
{
Serial.println("AT+CWMODE=1");
String cmd="AT+CWJAP=\"";
cmd+=SSID;
cmd+="\",\"";
cmd+=PASS;
cmd+="\"";
dbgSerial.println(cmd);
Serial.println(cmd);
delay(2000);
if(Serial.find("OK"))
{
dbgSerial.println("OK, Connected to WiFi.");
return true;
}else
{
dbgSerial.println("Can not connect to the WiFi.");
return false;
}
}
User avatar
By picstart1
#2050 First CH_PD needs to be pulled high or direct wired high (3.3v)
Next if the esp8266 module is out of the box ( not yet flashed by you) it can be either 57600 baud or 115200 baud.
The newer ones are 115200 and the blue led is near the antenna. Next cycle the power the esp8266 blue LED should flash briefly then go dark.
( CH_PD has to be high to have this happen)....GPIO 00 must float or be pulled high since if it is low ( gnd) at power up the esp8266 will expect it is to be flashed.
User avatar
By kyote00
#2055 I cant see a few things which might help....

There a two serial connections used, one to talk to the esp and the other to print debug to.

a) Debug serial should be something other than 0,1. Then you will need to connect a ftdi to whatever pins you specify.
SoftwareSerial dbgSerial(11, 12);

b) esp serial
The esp8266 should be connected to the TX/RX (D0,D1) on the nano.

I also found the esp need fairly large current (135mA) which the 3.3v regulator on the nano may struggle with.

I have successfully got it to work with a nano, using external 3.3v regulator (common ground)
User avatar
By Wbvreeuwijk
#2147 Hi,

I'm also new to the ESP8266 and I'm trying to get the serial connection to it going.

I'm using a Nano and a seperate 3.3V power source. I'm also using a TTL level converter.

So my setup is as follows

Nano TXI --> Levelconverter TXO
Nano RXO --> Levelconverter RXI
Nano GND --> Levelconverter GND

Levelconverter TXI --> URXD ESP8266
Levelconverter RXO --> UTXD ESP8266
Levelconverter GND --> GND
Levelconverter LV --> 3.3V

GND --> GND ESP8266
3.3V --> GND ESP8266
(3.3V --> CH_PD ESP8266)

I have a few questions
- Do I need a levelconverter for this?
- Do I need to supply CH_PD with 3.3V continously?
- Do I need to connect other pins also to 3.3V?

I see the blue led flashing shortly after I supplu CH_PD with VCC

@kyote00: You mentioned you got it to work with the Nano. Can you explain how you hooked the ESP8266 up?

Thanks for any hints on getting this to work?