The selected serial port serial.serialutil.SerialTimeoutException: Write timeout

i already change port and the uploud speed but still same.anyone have same problem like me?

#define BLYNK_PRINT Serial   
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>
#define BLYNK_PRINT Serial
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS V2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

char auth[] ="";               //Authentication code sent by Blynk
char ssid[] = "";                       //WiFi SSID
char pass[] = "";                       //WiFi Password

#define sensorPin V3 
int sensorState = 0;
int lastState = 0;
#define DHTPIN 2    
#define DHTTYPE DHT11     
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
void sendSensor()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature();

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
 
  Blynk.virtualWrite(V5, h);  //V5 is for Humidity
  Blynk.virtualWrite(V6, t);  //V6 is for Temperature
}
void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
   pinMode(sensorPin, INPUT);
  dht.begin();

  timer.setInterval(1000L, sendSensor);
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
   sensors.begin();
}
int sensor=0;
void sendTemps()
{
sensor=analogRead(A0);
sensors.requestTemperatures();
float temp = sensors.getTempCByIndex(0); 
Serial.println(temp);
Serial.println(sensor);
Blynk.virtualWrite(V1, temp);
Blynk.virtualWrite(V2,sensor);
delay(1000);
}
void loop()
{
  Blynk.run(); 
  timer.run(); 
  sendTemps();
  sensorState = digitalRead(sensorPin);
Serial.println(sensorState);

if (sensorState == 1 && lastState == 0) {
  Serial.println("needs water, send notification");
  Blynk.notify("Water your plants");
  lastState = 1;
  delay(1000);
//send notification
    
  } 
  else if (sensorState == 1 && lastState == 1) {
    //do nothing, has not been watered yet
  Serial.println("has not been watered yet");
  delay(1000);
  }
  else {
    //st
    Serial.println("does not need water");
    lastState = 0;
    delay(1000);
  }
  
  delay(100);
}

and the bug is

Sketch uses 288797 bytes (27%) of program storage space. Maximum is 1044464 bytes.
Global variables use 30600 bytes (37%) of dynamic memory, leaving 51320 bytes for local variables. Maximum is 81920 bytes.
esptool.py v3.0
Serial port COM6
Connecting...
Traceback (most recent call last):
  File "C:\Users\Asus\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.0/tools/upload.py", line 66, in <module>
    esptool.main(cmdline)
  File "C:/Users/Asus/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/3.0.0/tools/esptool\esptool.py", line 3552, in main
    esp.connect(args.before, args.connect_attempts)
  File "C:/Users/Asus/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/3.0.0/tools/esptool\esptool.py", line 519, in connect
    last_error = self._connect_attempt(mode=mode, esp32r0_delay=False)
  File "C:/Users/Asus/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/3.0.0/tools/esptool\esptool.py", line 499, in _connect_attempt
    self.sync()
  File "C:/Users/Asus/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/3.0.0/tools/esptool\esptool.py", line 438, in sync
    timeout=SYNC_TIMEOUT)
  File "C:/Users/Asus/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/3.0.0/tools/esptool\esptool.py", line 376, in command
    self.write(pkt)
  File "C:/Users/Asus/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/3.0.0/tools/esptool\esptool.py", line 339, in write
    self._port.write(buf)
  File "C:/Users/Asus/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/3.0.0/tools/pyserial\serial\serialwin32.py", line 325, in write
    raise SerialTimeoutException('Write timeout')
serial.serialutil.SerialTimeoutException: Write timeout
the selected serial port serial.serialutil.SerialTimeoutException: Write timeout
 does not exist or your board is not connected

Change the USB cable :face_with_monocle:

1 Like

already change my usb cable and now it came with new problem

Sketch uses 286504 bytes (27%) of program storage space. Maximum is 1044464 bytes.
Global variables use 30348 bytes (37%) of dynamic memory, leaving 51572 bytes for local variables. Maximum is 81920 bytes.
error: failed sending 0xC0
error: failed sending 8 bytes
error: failed sending 36 bytes
error: failed sending 0xC0
error: failed sending 0xC0
error: failed sending 8 bytes
error: failed sending 36 bytes
error: failed sending 0xC0
error: failed sending 0xC0
error: failed sending 8 bytes
error: failed sending 36 bytes
error: failed sending 0xC0
error: failed sending 0xC0
error: failed sending 8 bytes
error: failed sending 36 bytes
error: failed sending 0xC0
error: failed sending 0xC0
error: failed sending 8 bytes
error: failed sending 0xC0

error: failed sending 36 bytes
error: failed sending 0xC0
error: failed sending 0xC0
error: failed sending 8 bytes
error: failed sending 36 bytes
error: failed sending 0xC0
error: failed sending 0xC0
error: failed sending 8 bytes
error: failed sending 36 bytes
error: failed sending 0xC0
error: failed sending 0xC0
error: failed sending 8 bytes
error: failed sending 36 bytes
error: failed sending 0xC0
error: failed sending 0xC0
error: failed sending 8 bytes
error: failed sending 36 bytes
error: failed sending 0xC0
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed

Try an other MCU

Do you have the correct board type selected in the IDE?
If so then try a slower upload speed and/or a different USB port.

Pete.

ya i chose nodemcu and already downgrade it to version 2.5.0 so that this can worked…and right now trying to figure this new problem

i already use slower uploud speed which is 9600 and try other port and the result

error: Failed to open COM4
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed

and dont know what to do know

It sounds like a dodgy USB cable, or a dodgy MicroUSB connector on the NodeMCU.

Pete.

1 Like

i already hold the flash button the the problem become this only

warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed

Your MCU is dead , I’d had the same issue 3 years ago.

is my setup on board was wrong or my nodemcu is broken? so i need to buy new nodemcu?

You need to buy a $3 nodemcu :stuck_out_tongue_winking_eye:

but when i supply power my motor is working…

Yes the USB to serial converter ( CP2102 chipset ) on the MCU board is dead , not the MCU it self.

tq bro so i will buy new one

1 Like