serial monitor showing no out put

#include <SoftwareSerial.h> // Library for software serial
#define DEBUG true

/* This will make the pin 10 of arduino as RX pin and pin 11 of arduino as the TX pin Which means that you have to connect the TX from the esp8266 to the pin 10 of arduino and the Rx from the esp to the pin 11 of the arduino*/

SoftwareSerial esp8266(10,11); // Pins for ESP8266

const int trigPin = 8; // Making the arduino’s pin 8 as the trig pin of ultrasonic sensor
const int echoPin = 9; // Making the arduino’s pin 9 as the echo pin of the ultrasonic sensor
// defining two variable for measuring the distance
long duration;
int distance;

/* The setup() function is called when a sketch starts. It is used to initialize variables, pin modes, start using libraries, etc. This function will only run once, after each power up or reset of the Arduino board. */

void setup()
Serial.begin(115200); // Setting the baudrate

/* Set the baudrate according to you ESP’s baudrate. Your ESP’s baudrate might be different from mine */

pinMode(trigPin, OUTPUT); // Setting the trigPin as Output pin
pinMode(echoPin, INPUT); // Setting the echoPin as Input pin

sendData(“AT+RST\r\n”,2000,DEBUG); // command to reset the module
sendData(“AT+CWMODE=2\r\n”,1000,DEBUG); // This will configure the mode as access point
sendData(“AT+CIFSR\r\n”,1000,DEBUG); // This command will get the ip address
sendData(“AT+CIPMUX=1\r\n”,1000,DEBUG); // This will configure the esp for multiple connections
sendData(“AT+CIPSERVER=1,80\r\n”,1000,DEBUG); // This command will turn on the server on port 80

/* This Particular Function is used for Repeated Execution of the Circuit until Specified. */

void loop()
digitalWrite(trigPin, LOW); // Making the trigpin as low
delayMicroseconds(2); // delay of 2us
digitalWrite(trigPin, HIGH); // making the trigpin high for 10us to send the signal
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH); // reading the echopin which will tell us that how much time the signal takes to come back

distance= duration*0.034/2; // Calculating the distance and storing in the distance variable

if(esp8266.available()) // This command will that check if the esp is sending a message

/* We are subtracting 48 from the output because the read() function returns the ASCII
decimal value and the first decimal number which is 0 starts at 48*/

int connectionId =;
String webpage = “

IOT Garbage Monitoring System

webpage += “

”; // Print the Message on the webpage

if (distance<5)
webpage+= " Trash can is Full"; // Print the Message on webpage
webpage+= " Trash can is Empty"; // Print the Message on webpage
webpage += “

”; // Construct webpage
String cipSend = “AT+CIPSEND=”;
cipSend += connectionId;
cipSend += “,”;
cipSend +=webpage.length();
cipSend +="\r\n";

sendData(cipSend,1000,DEBUG); // Send Data
sendData(webpage,1000,DEBUG); // Send Data to webpage
String closeCommand = “AT+CIPCLOSE=”;
closeCommand+=connectionId; // Close connection
sendData(closeCommand,3000,DEBUG); // Send Data to close the command

String sendData(String command, const int timeout, boolean debug)
String response = “”; // Initialize response
esp8266.print(command); // Print the command
long int time = millis();
while( (time+timeout) > millis())
while(esp8266.available()) // Check if ESP is available
char c =; // Read the values of ESP in c variable
response+=c; // Increase the value of c variable

Serial.print(response); // Print the Response
return response; // Return response

SoftwareSerial does not work very well, if at all, at 115200.

In addition, it is best that the ESP8266 has its own power supply and does not use Arduino’s 3.3V output.