-->
Page 1 of 1

Problem with Arduino and AT commands

PostPosted: Thu Jul 06, 2017 3:35 pm
by DigitalMeth
First of all, hello to everybody. This is my first experience with the ESP8266 ESP-12 Module.

I have it connected to Arduino Uno R3, and I want to use it to send data from a sensor to server. Here is the thing. First I uploaded a blinking code to the ESP8266 using the Arudino IDE and the Arduino board as an UART, and it worked fine (I did this just to prove there is an initial communication between the Arduino and the Module).

After this, I flashed the ESP8266 with this flasher: Image

but with the v0.9.2.2 AT Firmware, and it was completed succesfuly.

Next, I upload a simple code (I will write it at the end of the post) to the Arduino, just to send "AT" through the serial monitor, and I'm expecting to receive "OK", so that I can continue with my project. But all I get is an upside-down question mark, in other words garbage. I try with different baud-rates and I get different garbages. Important to say, if I remove both RX and TX lines from the Arduino, I still get the same garbage, so in my opinion the problem is not with the module itself, but with the configuration of the Arduino, most possibly the code.

The hardware connection of the ESP8266 module is the following:

(I am using external 3,3V power source)
RST --> through 1k resistor to VCC
CH_PD --> through 1k resistor to VCC
GPIO0 --> open or to VCC (I know that GND is for flashing mode, that worked just fine)
GPIO15 --> GND
GPIO2 --> VCC (for the last two I'm not sure why, I read it somewhere but I dont think it even matters).
RX to the RX of Arduino (Pin 0)
TX to the TX of Arduino (Pin 1)
GND of the Module with the GND of the Arduino with the GND of the power supply.

In addition the TX of the Arduino is going through a 180R/330R voltage divider to the ESP8266 pin, so a 5V logic signal will be lowered to 3,3V.

What might be the problem? I suspect something with the code. First thing that comes to my mind is the baud-rate. I read that the default baud-rate of the firmware I uploaded is either 9600, 57600, or 115200 (that is the mySerial.begin(); part), but I tried with ALL the baud rates and I still dont get proper response. Also, as far as I can see the serial pins on the Arduino are 0 and 1 (RX and TX), but in the example I found, softwareSerial pins were designated to pins 10 and 11. On these pins I dont get no response at all, and on the Rx and Tx I get the garbage responses.

Does anyone have any experience with this? I am working alone and I am having tough time figuring this out. Any kind of suggestion will be useful. Thanks in advance!

Here's the code:

Code: Select all#include <SoftwareSerial.h>

SoftwareSerial mySerial(0, 1);  //RX,TX

void setup()
{
   
   Serial.begin(9600);     // communication with the host computer
 
    // Start the software serial for communication with the ESP8266
    mySerial.begin(9600); 
 
    Serial.println("");
    Serial.println("Remember to to set Both NL & CR in the serial monitor.");
    Serial.println("Ready");
    Serial.println("");   
}
 
void loop()
{
    // listen for communication from the ESP8266 and then write it to the serial monitor
    if ( mySerial.available() )   {  Serial.write( mySerial.read() );  }
 
    // listen for user input and send it to the ESP8266
    if ( Serial.available() )       {  mySerial.write( Serial.read() );  }
}

Re: Problem with Arduino and AT commands

PostPosted: Thu Aug 16, 2018 10:47 am
by sdingman@charter.net
DigitalMeth, I read your post with interest. I also am a beginner with the ESP8266. In my case, I have the ESP8266-01 version. I have been watching youtube videos and reading just about everything that I could find. As I read your post, there were two things that jumped out at me. The first is:

RX to the RX of Arduino (Pin 0)
TX to the TX of Arduino (Pin 1)

I read this as the Rx of the ESP8266 to the Rx of the Arduino.
I believe this is incorrect and should be:

Tx of the ESP8266 to the RX of Arduino (Pin 0)
Rx of the ESP8266 to the TX of Arduino (Pin 1)

However, I see in your Arduino software, that you have:

#include <SoftwareSerial.h>
SoftwareSerial mySerial(0, 1); //RX,TX

If I'm not mistaken pin 0 and 1 are the Arduino's default hardware serial Rx and Tx pins, so software serial doesn't need to be called upon to use those default pins. However If you use those two pins, you can't at the same time use the USB connection to your computer and terminal program.

Instead don't use pins 0 and 1 at all. Use Software Serial on pins 2 and 3, leaving pins 0 and 1 empty, so that you can use the USB connection to your computer to send and receive the AT commands to the ESP8266. I hope this is clear.
Steve

Re: Problem with Arduino and AT commands

PostPosted: Tue Sep 04, 2018 4:54 pm
by bobgardner
An Excellent Plan B is to use a computer with two hw uarts. One to go to the development compuyer, one to go to the wifi chip. The ATmega328PB has 2 uarts and is the size of an arduino pro mini, about 2" by 1". If you get the Seeed Grove WiFi Uart V2, it is 5V tolerant, has an esp8265 on it. The ATmega328PB is sold by Leonerd on Tindie. I think the idea is to use the rx interrupt on the mega with a buffer big enough to catch the payload sent back from the wifi. Both seials on the mega can run at 115200bps, as well as the serial on the wifi. Thanks for reading. Does anyone reading know what the max size of the wifi payload is? Is it 1500 bytes like ethernet? 512 bytes? Question was sort of on topic.

Re: Problem with Arduino and AT commands

PostPosted: Wed Sep 05, 2018 6:27 am
by btidey
I think the other piece of common advice is to consider your overall application requirements and whether you want to use the AT command set on the ESP8266 at all which is treating it as a wifi shield.

Many applications can be built entirely on the esp8266 module; reducing cost and complexity. Those that can't are either using special capabilities of the Arduino module like the timer facilities or ADC capabilities, or are using one of the high end ARM Arduinos. In some cases it is worth thinking about reversing the logic and making the Arduino just a slave IO processor to the ESP8266 as in https://tech.scargill.net/nano-peripheral/