0

I am trying to develop an Home automation system using Arduino and ESP8266 Module. But stuck at the very first step while checking is esp8266.available() available or not. This function always returns FALSE. Looking for solution. Thanks in advance.

CONNECTION

Vcc -----> 3.3
CH_PD ---> Vcc
RX ------> 2 (Arduino pin)
TX ------> 3 (Arduino pin)
GND -----> GND (Arduino)

CODE

#include <SoftwareSerial.h>
#define DEBUG true
SoftwareSerial esp8266(2,3);

void setup(){
    Serial.begin(9600);   // Setting the baudrate to 9600
    esp8266.begin(9600);  // Set it according to your esp’s baudrate. Different esp’s have different baud rates.
    pinMode(11,OUTPUT);   // Setting the pin 11 as the output pin.
    digitalWrite(11,LOW); // Making it low.
    pinMode(12,OUTPUT);   // Setting the pin 12 as the output pin..
    digitalWrite(12,LOW); // Making pin 12 low.
    pinMode(13,OUTPUT);   // Setting the pin 13 as the output pin.
    digitalWrite(13,LOW); // Making pin 13 low.
    sendData("AT+RST\r\n",2000,DEBUG);            //This command will reset module to default
    sendData("AT+CWMODE=2\r\n",1000,DEBUG);       // This will configure the mode as access point
    sendData("AT+CIFSR\r\n",1000,DEBUG);          // This will get ip address and will show it
    sendData("AT+CIPMUX=1\r\n",1000,DEBUG);       // This will configure the ESP8266 for multiple connections
    sendData("AT+CIPSERVER=1,80\r\n",1000,DEBUG); // This will set the server on port 80
}


void loop(){
    if(esp8266.available()){  // ALWAYS FALSE
        // My codes 
    }
}

UPDATE

At the very first run time, the function is returning TRUE and showing an error

deprecated conversion from string constant to char wwrite strings arduino esp8266.find("+IPD,")

for line number

  • 1
    Also asked at: stackoverflow.com/q/49093800 If you're going to do that then at least be considerate enough to add links to the other places you cross posted. This will let us avoid wasting time due to duplicate effort and also help others who have the same questions and find your post to discover all the relevant information. – per1234 Mar 4 '18 at 9:46
  • 2
    connect RX to TX and TX to RX. pin 2 is RX in your SoftwareSerial. did you set the AT firmware to 9600 baud? available() returns the count of available bytes. – Juraj Mar 4 '18 at 10:02
  • @per1234 I am really sorry for that. During post on Arduino community suddenly I lost my internet connection and thought question was not publish. Then I directly posted id on Stackoverflow with arduino tag. – WebDevRon Mar 4 '18 at 10:23
  • @Juraj Please look at the line number 3 "SoftwareSerial esp8266(2,3);". Should I still connect RX to TX and TX to RX? – WebDevRon Mar 4 '18 at 10:25
  • if you want two devices to communicate over Serial, then always one must listen on receive pin what the other transmits on transmit pin. in your SoftwareSerial setup pin 2 is RX and pin 3 TX. – Juraj Mar 4 '18 at 10:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.