I have tried to create web server with esp8266. Below is my code to be uploaded into esp8266. After uploading the code, I press Reset button and get unwritten characters like r$$?? … with baud rate of 115200 in serial monitor. What is wrong with that?
#include <ESP8266WiFi.h>
/* Put your SSID & Password */
const char* ssid = “MyNodeMCU”; // Enter SSID here
const char* password = “12345678”; //Enter Password here
WiFiServer server(80);
String header;
// Auxiliar variables to store the current output state
String output5State = “off”;
String output4State = “off”;
// Assign output variables to GPIO pins
const int output5 = 5;
const int output4 = 4;
// Current time
unsigned long currentTime = millis();
// Previous time
unsigned long previousTime = 0;
// Define timeout time in milliseconds (example: 2000ms = 2s)
const long timeoutTime = 2000;
void setup() {
Serial.begin(115200);
// Initialize the output variables as outputs
pinMode(output5, OUTPUT);
pinMode(output4, OUTPUT);
// Set outputs to LOW
digitalWrite(output5, LOW);
digitalWrite(output4, LOW);
// Connect to Wi-Fi network with SSID and password
Serial.print(“Connecting to “);
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(“.”);
}
// Print local IP address and start web server
Serial.println(“”);
Serial.println(“WiFi connected.”);
Serial.println(“IP address: “);
Serial.println(WiFi.localIP());
server.begin();
}
void loop()
{
}