Post topics, source code that relate to the Arduino Platform

User avatar
By Black3rror
#65134 Hi all.
I have "arduino Mega2560" and "esp8266 lolin nodemcu v3" and I've connected:
esp -> arduino
3v -> 3.3v
G -> Gnd
Tx -> digital port 2
Rx -> digital port 3
https://www.photobox.co.uk/my/photo/ful ... 1663183097
And below u can see the code that I've uploaded on arduino:
Code: Select all#include <SoftwareSerial.h>
SoftwareSerial esp8266(2,3);

void setup()
{
  Serial.begin(115200);
  esp8266.begin(115200);
}

void loop()
{delay(1000);
 esp8266.println("AT");
 if(esp8266.available()) // check if the esp is sending a message
 {Serial.print("lool");
 while(esp8266.available())
  {
    // The esp has data so display its output to the serial window
    char c = esp8266.read(); // read the next character.
    Serial.write(c);
  } 
 }
}


But I can't see anything in serial monitor of arduino.
Whats the problem?!
Any help appreciated.
User avatar
By martinayotte
#65212 You are trying to check if response came with esp8266.available() and expecting the response to be already present. You either need to add a delay after sending the AT, or even better add a while() loop with timeout check that will wait the response been received.