Hello everybody,
Recently i bought myself an ESP8266 Wi-Fi module, which i connected to my Arduino nano. I hooked up everything like some guys did on the tutorials, RX ----- RX, TX ----- TX, GND --- GND, 3.3V --- VCC, 3.3V --- CH_PD. When sending commands to the module, with the basic AT command, i get a normal OK response, but with everything else i get an ERROR or INVALID. I also tried different connections, for example i connected the two remaining pins on VCC, no luck, I reversed the RX and TX pins, still no luck. And some struggling later i found out that the module can run by itself, and you can program it with the USB TTL directly from your computer, so i downloaded the arduino IDE, and installed the plugins tor my Wi-Fi module. But the computer can’t connect with it, because i can’t change the programmer. I will add pictures below so you can see my problems.
Thanks
If you get an "OK" response, it is not likely that you have the incorrect hardware connections.
This is the code I was using,
#include <SoftwareSerial.h>
SoftwareSerial esp8266(2,3); // make RX Arduino line is pin 2, make TX Arduino line is pin 3.
// This means that you need to connect the TX line from the esp to the Arduino's pin 2
// and the RX line from the esp to the Arduino's pin 3
void setup()
{
Serial.begin(9600);
esp8266.begin(9600); // your esp's baud rate might be different
}
void loop()
{
if(esp8266.available()) // check if the esp is sending a message
{
while(esp8266.available())
{
// The esp has data so display its output to the serial window
char c = esp8266.read(); // read the next character.
Serial.write(c);
}
}
if(Serial.available())
{
// the following delay is required because otherwise the arduino will read the first letter of the command but not the rest
// In other words without the delay if you use AT+RST, for example, the Arduino will read the letter A send it, then read the rest and send it
// but we want to send everything at the same time.
delay(1000);
String command="";
while(Serial.available()) // read the command character by character
{
// read one character
command+=(char)Serial.read();
}
esp8266.println(command); // send the read character to the esp8266
}
}
Maybe the 1000ms delay is garbling your serial input. Maybe. In other words, it is twiddling its thumbs while you are typing.
I tried to delete the delay, and the Arduino doesn’t read the whole command, I also increased the delay but it is always the same – ERROR.
String command="";
while(Serial.available()) // read the command character by character
{
// read one character
command+=(char)Serial.read();
}
// you are sending a cr/lf here
esp8266.println(command); // send the read character to the esp8266
You are probably sending a cr/lf at the wrong place. I recommend putting your serial input into a character array until it gets a cr/lf (or your terminating character) from your terminal, then send the whole string to the esp8266.
edit: or use print instead of println.
I’m sorry but I don’t understand, I should put the quoted code higher, so it will be read before? I’m quite a lousy programmer as you can see
I would use this:
while(Serial.available()) // read the command character by character
{
// read one character from serial terminal
char ch = Serial.read();
// send that one character to the esp8266
esp8266.print(ch); // send the read character to the esp8266
}
Note I dropped the String data type.
Wow, i actually got some further, the busy sign is gone, and I could see the version that I am running. But when I typed AT+RST, the ESP kind of froze, there was just an OK response, and nothing else, I tried to type AT again but nothing came to the screen so I unplugged it an restart it…
Here is the response:
AT
OK
AT+GMR
AT vession:0.21.0/0
SDK vershon:0.9.5
OK
AT+RST
OK
ţ
I don't know that.
Is there a reason you must reset the esp8266?
Well, i am trying to do the basic startup since only two commands actually work. If I type any other command beside from AT, or AT+GMR, i get an ERROR, that’s why i would like to reset the module, get the READY response and later search for networks and so on...
The nano is a 5 volt device. The esp8266 is a 3.3 volt device. The Sparkfun page on its esp8266 module says this:
"Note: The ESP8266 Module is not capable of 5-3V logic shifting and will require an external Logic Level Converter."
Are you using a module with a logic level converter?
No, I connected it directly to the arduino pins, like this: https://techwithabhi.files.wordpress.com/2015/03/untitled-1.jpg (except i have an arduino nano).
Is it possible to use a voltage regulator for this? Or should I just order one logic level converter from Ebay, because I live in the middle of nowhere and it will take forever to come to me.
Do you have any resistors? You can probably make do with a voltage divider on the tx line from the nano to the esp8266. The rx line on the nano will probably do ok. I would use a 1K and 2K resistor divider to start.
Yes, I tried to do a voltage divider and also used an voltage regulator but nothing helped, it still sends me an error Could it be that the module is broken or something?
What AT commands are you entering that causes the ERROR message?
You program the esp with USB TTL adapter then you hook it up to the uno or nauno.
Most board use a diode to drop the tx line but I don't see that being a problem but I use a diode just in case.
The esp is never been programed will run code sent to it serially. It running firmware that waits for AT commands.
ESP8266 happily accepts data at 5 V (datasheet says inputs are 5V tolerant).
The ESP8266 datasheet from Espressive Systems (the manufacturer) states very clearly the maximum voltage on any input pin is 3.6.volts. It won't be happy with 5 volts on an input pin.
Page 15 here.
Maybe they made a mistake but I would use 3.3 on the gpio but the rx and tx can just use a diode drop which get's way below what the datasheet said here.
ESP8266 happily accepts data at 5 V (datasheet says inputs are 5V tolerant). ESP8266 power supply remains at 3.3 Volts. All digital IO pins are protected from over-voltage with a snap-back circuit connected between the pad and ground. The snap back voltage is typically about 6V, and the holding voltage is 5.8V. This provides protection from over-voltages and ESD. The output devices are also protected from reversed voltages with diodes.
But this is not the OP problem there problem sounds like they haven't programed the esp2866
And to make this clear do not run at 5 volts and do not use gpio at 5 volts and don't put more then 1.8 in the adc pin. But the tx and rx use a diode for drop and you'll be good