Hello to everyone,
i have recently bought an esp8266 module from dfrobot. It comes with xbee design.
I cannot communicate with it when connected to arduino.
I tested the module with an USB adapter and AT commands, and it connect to my home network with no issues.
The module description is here --> this
For the moment i am just trying to connect to the access point using arduino.
The module is on the USB adapter, which has an FTDI connector. As in the wiki page of dfrobot (link above) i have connected RX-TX-GND of the adapter to the arduino pins 11-10-GND.
Here is the code:
#include "esp8266.h"
#include "SoftwareSerial.h"
#define ssid "this is my ssid"
#define password "this is my pwd"
Esp8266 wifi;
bool flag=false;
SoftwareSerial mySerial(10,11); // RX, TX
void setup() {
delay(2000);
pinMode(13, OUTPUT);
mySerial.begin(9600);
Serial.begin(9600);
wifi.begin(&Serial, &mySerial);
if (wifi.connectAP(ssid, password)) {
flag = true;
wifi.debugPrintln("connected to AP");
} else {
wifi.debugPrintln("connect Fail");
}
}
void loop() {
if (flag) {
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(500);
}
}
OF COURSE i have set my real ssid and password
What i get, on the debug serial, is "connect fail".
I wrote to dfrobot, they suggested me to update the firmware, and thats what i did. I'm using v0.9.2.2 AT Firmware. Baudrate changed from 115200 to 9600 (tested on the usb adapter and succesfully connected with AT commands). No way to make it connect to a network (tryied 3 different router with different security settings) using a sketch on arduino.
So, reading around the net i have found out a sketch to use AT commands sending them from arduino, but i dont get any answer from the esp. Here is the code:
#include <SoftwareSerial.h>
SoftwareSerial esp8266(10,11);
void setup()
{
Serial.begin(9600);
esp8266.begin(9600);
}
void loop()
{
if(esp8266.available())
{
while(esp8266.available())
{
char c = esp8266.read(); // read the next character.
Serial.write(c);
}
}
if(Serial.available())
{
delay(1000);
String command="";
while(Serial.available()) // read the command character by character
{
command+=(char)Serial.read();
}
esp8266.println(command); // send the read character to the esp8266
}
}
Can someone help me please?
Thanks in advance, and sorry for the long post and my bad english!
ps: i forgot to say i used same wiring/sketch on uno rev3 (original) and mega2560 (compatible) with same results... also on this shield removing software serial from the sketch and trying to connect directly.