I need guideline connecting & testing Esp8266 wifi module. I have connected and programmed like below . I have attached output Serial
Let me know how to send command for basic operation.
I am using Arduino Uno
i have connected
3.3v from Externally using DS1117 IC.
GND connected
TX ESP -> TX of Arduino
RX esp -> connected to rx of arduino
enable pin/CH_PD connected to arduino 5 using 2K resistor
Remaining Pin Kept Idle.
Even try remove enable pin it didnt worked.
Kindly share me link for testing basic esp working and send command & receive data
#include <SoftwareSerial.h>
#include <SerialESP8266wifi.h>
#define sw_serial_rx_pin 4 // Connect this pin to TX on the esp8266
#define sw_serial_tx_pin 6 // Connect this pin to RX on the esp8266
#define esp8266_reset_pin 5 // Connect this pin to CH_PD on the esp8266, not reset. (let reset be unconnected)
SoftwareSerial swSerial(sw_serial_rx_pin, sw_serial_tx_pin);
// the last parameter sets the local echo option for the ESP8266 module..
SerialESP8266wifi wifi(swSerial, swSerial, esp8266_reset_pin, Serial);//adding Serial enabled local echo and wifi debug
String inputString;
boolean stringComplete = false;
unsigned long nextPing = 0;
void setup() {
inputString.reserve(20);
swSerial.begin(9600);
Serial.begin(9600);
while (!Serial)
;
Serial.println("Starting wifi");
wifi.setTransportToTCP();// this is also default
// wifi.setTransportToUDP();//Will use UDP when connecting to server, default is TCP
wifi.endSendWithNewline(true); // Will end all transmissions with a newline and carrage return ie println.. default is true
wifi.begin();
//Turn on local ap and server (TCP)
wifi.startLocalAPAndServer("MY_CONFIG_AP", "password", "5", "2121");
wifi.connectToAP("wifissid", "wifipass");
wifi.connectToServer("192.168.0.28", "2121");
wifi.send(SERVER, "ESP8266 test app started");
}
void loop() {
//Make sure the esp8266 is started..
if (!wifi.isStarted())
wifi.begin();
//Send what you typed in the arduino console to the server
static char buf[20];
if (stringComplete) {
inputString.toCharArray(buf, sizeof buf);
wifi.send(SERVER, buf);
inputString = "";
stringComplete = false;
}
//Send a ping once in a while..
if (millis() > nextPing) {
wifi.send(SERVER, "Ping ping..");
nextPing = millis() + 10000;
}
//Listen for incoming messages and echo back, will wait until a message is received, or max 6000ms..
WifiMessage in = wifi.listenForIncomingMessage(6000);
if (in.hasData) {
if (in.channel == SERVER)
Serial.println("Message from the server:");
else
Serial.println("Message a local client:");
Serial.println(in.message);
//Echo back;
wifi.send(in.channel, "Echo:", false);
wifi.send(in.channel, in.message);
nextPing = millis() + 10000;
}
//If you want do disconnect from the server use:
// wifi.disconnectFromServer();
}
//Listen for serial input from the console
void serialEvent() {
while (Serial.available()) {
char inChar = (char)Serial.read();
inputString += inChar;
if (inChar == '\n') {
stringComplete = true;
}
}
}
I have tried Interchanging. The communication hangs if port are intercahnge.
I need sample working code where i make ensure the Esp8266-12E version is working.
Command should send serially and data to be received if connected.
#include <SoftwareSerial.h>
SoftwareSerial ESPSerial(2, 3); // RX, TX
void setup() {
// Open serial communications
Serial.begin(9600);
// set the data rate for the SoftwareSerial port
// if this doesnt work you for you then try different baud rate
ESPSerial.begin(9600);
ESPSerial.println("Ready to take AT commands");
}
void loop() { // run over and over
if (ESPSerial.available()) {
// reads input from serial console and writes to esp8266
Serial.write(ESPSerial.read());
}
if (Serial.available()) {
// reads input from esp8266 and writes to serial console
ESPSerial.write(Serial.read());
}
}
I have connected in this way. Regulator out put is 3.3V.
When i used code The Welcome printing properly. But it wont print
"Ready to take AT commands" It start printing ????? reverse pasion . output attached in first thread. Led of Esp8266 will flicker for while then it stop
#include <SoftwareSerial.h>
SoftwareSerial ESPSerial(2, 3); // RX, TX
void setup() {
// Open serial communications
Serial.begin(9600);
Serial.println("welcome");
// set the data rate for the SoftwareSerial port
// if this doesnt work you for you then try different baud rate
ESPSerial.begin(9600);
ESPSerial.println("Ready to take AT commands");
}
void loop() { // run over and over
if (ESPSerial.available()) {
// reads input from serial console and writes to esp8266
Serial.write(ESPSerial.read());
}
if (Serial.available()) {
// reads input from esp8266 and writes to serial console
ESPSerial.write(Serial.read());
}
}
Instead of red board connected to arduino. That red board is USB to TTl converter mentioned in thread.
are all grounds from schema connected together?
yes all grounds are same.
Are you sure esp is at 9600? May be its at 115200.
I have tried as per other thread both baudarate kept 115200, if kept both baudarate Uno wont reply . So Serial tried with 9600.
But not tried with 115200.
I am suspecting on SoftwareSerial library . In Setup function it has to print
"Ready to take AT commands" . But it wont print all.
In order to test software Serial library i have connected USB to TTL out , through USB to ttl converter using DOCKlight Sending data "welcome" every 1s . Even it send data COM of arduino wont print anything. I am using arduino 1.8.4 on window 8 OS. Previous i used library on windows XP with 1.0.1 arduino version where Software serial library working well.
ESPSerial.begin(9600);
ESPSerial.println("Ready to take AT commands");
AJITnayak:
Instead of red board connected to arduino. That red board is USB to TTl converter mentioned in thread.
Please just make a simple pencil drawing showing clearly exactly how YOU have everything connected and post a photo of the drawing and then we can start to make some progress.
At the moment we are no further on than when I wrote Reply #4
I have made below changes in circuit and code as below. Now i could able to read whatever send from Arduino UART
But i could able to get proper response from Esp8266
If i send AT command i should get reply OK
I am using ESP8266 12 E version. But most example are done with ESP8266 ESP-01 version
#include "SoftwareSerial.h"
SoftwareSerial ESPSerial(2, 3); // RX, TX
void setup() {
// Open serial communications
Serial.begin(9600);
Serial.println("Getting started");
// set the data rate for the SoftwareSerial port
// if this doesnt work you for you then try different baud rate
ESPSerial.begin(115200);
ESPSerial.println("Ready to take AT commands");
}
void loop() { // run over and over
if (ESPSerial.available()) {
// reads input from serial console
Serial.write(ESPSerial.read());
}
if (Serial.available()) {
// reads input from esp8266 and writes to serial console
ESPSerial.write(Serial.read());
}
delay(100);
}