Please help, ESP8266 won't upload sketches anymore!

Someone please help me figure this out im so frustrated. My sketch was working just fine, and now it won’t upload at all.

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>

//My auth token to connect to the Blynk app.
char auth[] = "ac5db357d3bb404893bdd2cdd1e49c4f";

//My Wifi SSID and password.
char ssid[] = "BHNTG1682G85ED";
char pass[] = "9bef4b7a";

 // These 3 define what Digital pin we're connected to. (NodeMCU Esp8266 was a weird pin layout
#define DHTPIN 14 
#define DHTPIN2 12 
#define DHTPIN3 13 

//Defines which DHT type I have.
#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321

DHT dht(DHTPIN, DHTTYPE);
DHT dht2(DHTPIN2, DHTTYPE);
DHT dht3(DHTPIN3, DHTTYPE);
BlynkTimer timer;
const int sensorPin = 15; 
int sensorState = 0;
int lastState = 0;
const int sensorPin2 = 2; 
int sensorState2 = 0;
int lastState2 = 0;
const int sensorPin3 = 0; 
int sensorState3 = 0;
int lastState3 = 0;

// This function sends Arduino's up time every second to Virtual Pins.
void sendSensor()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
  float h2 = dht2.readHumidity();
  float t2 = dht2.readTemperature();
  float h3 = dht3.readHumidity();
  float t3 = dht3.readTemperature();  
  if (isnan(h) || isnan(t) || isnan(h2) || isnan(t2) || isnan(h3) || isnan(t3)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);
  Blynk.virtualWrite(V1, h2);
  Blynk.virtualWrite(V2, t2);  
  Blynk.virtualWrite(V3, h3);
  Blynk.virtualWrite(V4, t3);  
}

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  dht.begin();
  pinMode(sensorPin, INPUT);
  pinMode(sensorPin2, INPUT);
    pinMode(sensorPin3, INPUT);
  // Setup a function to be called every second
  timer.setInterval(1000L, sendSensor);
}

void loop()
{
  Blynk.run();
  timer.run();
  sensorState = digitalRead(sensorPin);
  Serial.println(sensorState);
  sensorState2 = digitalRead(sensorPin2);
  Serial.println(sensorState2);
    sensorState3 = digitalRead(sensorPin2);
  Serial.println(sensorState3);
  
  if (sensorState == 1 && lastState == 0) {
  Serial.println("1 needs water, send notification");
  Blynk.notify("Water plant 1");
  lastState = 1;
  delay(500);
//send notification

} 
  else if (sensorState == 1 && lastState == 1) {
    //do nothing, has not been watered yet
  Serial.println("1 has not been watered yet");
  delay(500);
  }

  else {
    //st
    Serial.println("1 does not need water");
    lastState = 0;
    delay(500);
  }
  if (sensorState2 == 1 && lastState2 == 0) {
  Serial.println("2 needs water, send notification");
  Blynk.notify("Water plant 2");
  lastState2 = 1;
  delay(500);
//send notification

}

  else if (sensorState2 == 1 && lastState2 == 1) {
    //do nothing, has not been watered yet
  Serial.println("2 has not been watered yet");
  delay(500);
  }
  
  else {
    //st
    Serial.println("2 does not need water");
    lastState2 = 0;
    delay(500);
  } 

  if (sensorState3 == 1 && lastState3 == 0) {
  Serial.println("3 needs water, send notification");
  Blynk.notify("Water plant 3");
  lastState3 = 1;
  delay(500);
//send notification

} 
  else if (sensorState3 == 1 && lastState3 == 1) {
    //do nothing, has not been watered yet
  Serial.println("3 has not been watered yet");
  delay(500);
  }

  else {
    //st
    Serial.println("3 does not need water");
    lastState3 = 0;
    delay(500);
  }
}

I get this error

esptool v0.4.13 - (c) 2014 Ch. Klippel <ck@atelier-klippel.de>
	setting board to nodemcu
	setting baudrate from 115200 to 115200
	setting port from COM1 to COM3
	setting address from 0x00000000 to 0x00000000
	espcomm_upload_file
	espcomm_upload_mem
	setting serial port timeouts to 1000 ms
opening bootloader
resetting board
trying to connect
	flush start
	setting serial port timeouts to 1 ms
	setting serial port timeouts to 1000 ms
	flush complete
	espcomm_send_command: sending command header
	espcomm_send_command: sending command payload
	read 0, requested 1
trying to connect
	flush start
	setting serial port timeouts to 1 ms
	setting serial port timeouts to 1000 ms
	flush complete
	espcomm_send_command: sending command header
	espcomm_send_command: sending command payload
	serialport_receive_C0: 80 instead of C0
trying to connect
	flush start
	setting serial port timeouts to 1 ms
	setting serial port timeouts to 1000 ms
	flush complete
	espcomm_send_command: sending command header
	espcomm_send_command: sending command payload
	serialport_receive_C0: 80 instead of C0
resetting board
trying to connect
	flush start
	setting serial port timeouts to 1 ms
	setting serial port timeouts to 1000 ms
	flush complete
	espcomm_send_command: sending command header
	espcomm_send_command: sending command payload
	read 0, requested 1
trying to connect
	flush start
	setting serial port timeouts to 1 ms
	setting serial port timeouts to 1000 ms
	flush complete
	espcomm_send_command: sending command header
	espcomm_send_command: sending command payload
	serialport_receive_C0: 80 instead of C0
trying to connect
	flush start
	setting serial port timeouts to 1 ms
	setting serial port timeouts to 1000 ms
	flush complete
	espcomm_send_command: sending command header
	espcomm_send_command: sending command payload
	serialport_receive_C0: 80 instead of C0
resetting board
trying to connect
	flush start
	setting serial port timeouts to 1 ms
	setting serial port timeouts to 1000 ms
	flush complete
	espcomm_send_command: sending command header
	espcomm_send_command: sending command payload
	read 0, requested 1
trying to connect
	flush start
	setting serial port timeouts to 1 ms
	setting serial port timeouts to 1000 ms
	flush complete
	espcomm_send_command: sending command header
	espcomm_send_command: sending command payload
	serialport_receive_C0: 80 instead of C0
trying to connect
	flush start
	setting serial port timeouts to 1 ms
	setting serial port timeouts to 1000 ms
	flush complete
	espcomm_send_command: sending command header
	espcomm_send_command: sending command payload
	serialport_receive_C0: 80 instead of C0
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed

IT WONT EVEN UPLOAD THE NULL SKETCH

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

I get this error!

Uploading 250256 bytes from C:\Users\Laurel\AppData\Local\Temp\arduino_build_484144/sketch_apr02a.ino.bin to flash at 0x00000000
warning: espcomm_send_command: didn't receive command response
warning: espcomm_send_command(FLASH_DOWNLOAD_BEGIN) failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed

Someone please help me with this, this is for a project.

How is it wired? I see you may be using some of the “special” pins on the ESP.
Take a look at this, and see if it helps shine some light on your issue.

https://www.forward.com.au/pfod/ESP8266/GPIOpins/index.html

I removed all the wires, and tried uploading the null sketch with the board on its own. Nothing.

Is it broken? Because the sketch was running perfectly a second before this happened.

Try the following, in this order:

  • Restart the Arduino IDE
  • Unplug the USB cable and plug it in again
  • Try a different USB socket (will give a different USB port in the IDE)
  • Try a different USB cable
  • Reboot your PC
  • Re-install the USB driver for your NodeMCU board.
  • Re-install the Arduino IDE

Pete.

I used the IDE on a laptop with no libraries and it worked. could it be that?

No, the error messages were about a communication error between the IDE and the NodeMCU.

These can happen from time to time and are usually fixed by restarting the IDE or plugging the ModeMCU back in.

Pete.

Still not working. It uploads on the laptop but I don’t get a connection or any outputs on the serial monitor.

PC still has the uploading error.

I reinstalled everything… I think my board is broken.

I thought you said that the board worked when you programmed it using a laptop. If that’s the case then it can’t be broken.

Pete.

Well, you did not specify how you connected ESP-01 to serial port (USB-serial bridge). I guess you are properly switching the ESP to flash mode??

one thing I haven’t seen addressed here (and which was the solution for my case when i had similar issues like you) is that you can try to compile the sketch for a different board (menu --> tools --> board).

Another thing you can try is pulling D3 to the ground (0V) while flashing

Hey all! So I just woke up this morning and tried flashing it again and whaddya know? It just decided to work again! I haven’t done anything differently either! Well this is a blessing so, thanks for trying to help me.

But it does seem like D8 is not working anymore, so i moved to D2. And now the uploads go from 30% 60% 90% 100% to 29% 59% 89% 100%

Should I be worried?

D8 (GPIO15) is one of those pins that can interfere with the board being flashed. See this post:

D2 (GPIO4) is a much better choice.

Can you post a screenshot of the Tools menu in the Arduino IDE showing the settings you used to flash the board last time?

Pete.

Like this?

1 Like

Only worry if it doesn’t make it to 100% or doesn’t transfer the sketch :stuck_out_tongue_winking_eye:

2 Likes

Looks fine - thanks.
I have no idea what the best IwIP Variant is for version 2.4.1 of the Arduino Core, but it win’t make any difference to the uploading of the code.

Pete.