are you sure your arduino serial port is turned off? you need to make sure the arduino's mega328 isn't using the UART or it can be a source of problems... (disable serial comunication in your arduino or make sure the flash is blank (0xff))
It's better if you can use an external UART to USB converter like a CH340 or a FT232 board...
#include <SoftwareSerial.h>
SoftwareSerial esp8266(2,3); //make RX Arduino line is pin 2, make TX Arduino line is pin 3.
void setup()
{
Serial.begin(19200);
esp8266.begin(115200);
}
void loop()
{
if(esp8266.available())
{
while(esp8266.available())
{
char c = esp8266.read();
Serial.write(c);
}
}
if(Serial.available())
{
delay(2000);
String command="";
while(Serial.available())
{
// read one character
command+=(char)Serial.read();
}
esp8266.println(command);
delay(10);
}
}
Recently I bought an esp8266ex from ebay. After setting up everything, i have a strange problem. The 8266 responds to AT commands, but responded with weired characters.
I am using arduino UNO.
Connected the Tx pin of the arduino to Rx pin of esp8266 through a voltage divider (POT). GPI02 and RST pins are floating.
GPI0 is connected to ground trough a 10k resistor.
I have tried both 3.3v arduino pin and zr78L033 regulator to power up the 8266.
But both ended up giving same output.
Also , I have tried all the baud rate, out of which 115200 baud between arduino and esp responded with less garbage ( above picture)
While I've had success programming the 32-bit 80MHz ARM core directly using the Arduino IDE and the ESP8266 add on SDK and utilizing the device as a standalone system without any other microcontroller, however I've not had much experience with the AT Command set firmware. I do know there are several versions of the AT Command set firmware, which have successively improved the serial interface connectivity.
What version of the firmware is currently loaded into the device?
You may want to consider upgrading the current firmware to the latest revision:
ESP8266 AT-command firmware
If I remember correctly, both CH_PD and GPIO0 should be pull high for the device to boot the firmware loaded in flash, of course VCC and GND need to be properly connected as well.
ESP8266 Wiki
If both CH_PD and GPIO0 are not pull high, the device enters its bootloader or flash mode which utilizes an uncommon baud rate, which might explain all the spurious characters you've been seeing. Also, when using a softUART like that of the Software Serial library of the Arduino, you should typically keep the baud rates low, 9600 or lower. Try properly configuring CH_PD and GPIO0 and connecting at 9600 baud.
BigDog
I changed the baud rate and tied the GPIO0 pin to Vcc , but the interesting thing is, the esp didnt responded to AT command. But when I connected the GPIO0 pin to Vcc through a 10K Resistor,
its responds to AT command , with those unwanted characters...:-?
View attachment 121221
Hello,
I changed the baud rate and tied the GPIO0 pin to Vcc , but the interesting thing is, the esp didnt responded to AT command. But when I connected the GPIO0 pin to Vcc through a 10K Resistor,
its responds to AT command , with those unwanted characters...:-?
I suppose your AVR is using 5v supply while ESP8266 is 3V, you need a level translator for that because the ESP8266 Rx line can be damaged with 5V input.
What worked for me is to use a 1K resistor between the AVR Tx line and ESP Rx line and a direct connection between ESP Tx and AVR Rx.
So, I disabled the Atmega chip by connecting the reset pin to ground. Then connected the Tx and Rx pin of the arduino to Tx and Rx pin of esp respectively, and its working fine.
View attachment 121253
It worked with Atmega chip disabled. But I dont know how to make it work Atmega chip enabled.
The esp responded successfully at 115200 baud (ATmega disabled).
As I previously indicated, the primary issue you face, is the Arduino Software Serial Library cannot reliably function at 115,200 baud, as the number of tasks which the AVR (ATmega) microcontroller is performing increases, so to will the number of communication errors. Unfortunately, softUARTs are often relatively processor intensive tasks as the require oversampling of the RX line several times that of the baud rate. For example, hardware UARTs typically oversample the RX line x16 times the baud rate, therefore a baud rate of 115,200, requires an oversampling rate of 1,843,200, while softUARTs typically oversample at a rate of x4 times the baud rate at the very least.
The reason communications become reliable when the AVR is disabled is simply, the Arduino essentially becomes a hardware USB to Serial Bridge BOB.
The solution is also relatively simply, while the AVR is disabled on the Arduino board, the ESP-01 is attached as previously indicated and communications have been established, issue the following command:
AT+CIOBAUD=9600
Communications will be broken at 115,200 baud, however they should be able to be reestablished at 9600 baud.
Once this has been confirmed, power down both the Arduino and ESP-01, enable the AVR, reconnect the ESP-01 to the softUART port pins, modify the Software Serial routines to initial the soft serial port to 9600 baud, rather than 115,200, compile and download the revised application code and then test those modifications.
BigDog
I completely agree with you. I have changed the baud rate to 9600. The output seems to be fine.
View attachment 121346
But for commands that returns lengthy string, its not okay .
View attachment 121347
I am thinking of upgrading my firmware to latest version.
AT+RST
OK
ets Jan 8 2013,rst cause:4, boot mode3,0)
wdt reset
load 0x40100000, len 816, room 16
tail 0
chksum 0x8d
load 0x3ffe8000, len 788, room 8
tail 12
chksum 0xcf
ho 0 tail 12 room 4
load 0x3ffe8314, len 288, room 12
tail 4
chksum 0xcf
csum 0xcf
2nd boot version : 1.2
SPI Speed : 40MHz
SPI Mode : DIO
SPI Flash Size : 32Mbit
jump to run user1
r[18][02]Ž[1B]Ñ
Ai-Thinker Technology Co. Ltd.
ready
The response from the AT+GMR command indicates you have the latest version of AI-Thinker AT Firmware already installed, v0.9.5.0.
The miscellaneous and apparently random characters displayed just before the line with "Ai-Thinker Technology Co. Ltd." after the module has been reset (AT+RST) is absolutely normal and nothing to be concerned about. However, it does appear the softUART, Software Serial Library, is still having issues with sustained communications with relatively long data transfers.
The response from an AT+RST command with the same firmware revision, v0.9.5.0:
v0.9.5.0 - Is the latest version so there is no need at this time to update the firmware and that ESP8266 does not appear to be the issue.
You might try reducing the baud rate of the ESP8266 module further, from 9600 baud down to 4800 baud and make the appropriate changes to your Arduino code.
Another option is to replace the Arduino Uno and its ATmega328P with an AVR with two hardware UARTs, you can download the Arduino bootloader to essentially any AVR and develop code for it using the same Arduino IDE and compiler.
Or do away with the Arduino Uno all together and program the ESP8266 directly, after all it has more horsepower and flash storage than the AVR, the only thing the ESP-01 lacks is I/O.
There are ESP-12E modules available for only a few dollars each with five times the available I/O pins.
BigDog
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?