Fixing ESP8266/CH340 `a device attached to the system is not functioning` error

I have my own ESP8266-based solution that handles for example

  • measuring temperatures using ds18b20 sensor,
  • measuring temperatures using thermocouples (SPI bus),
  • measuring temperature, barometric pressure and RH (I2C bus) and
  • reading values from Victron solar systems.

Data is sent using MQTT or HTTP to configured endpoint. It also has a web-based configuration panel. It’s built with PlatformIO which is super useful extension for vscode.

CH340 and Windows 11 issue

Lately I updated my laptop to a newer one and it has Windows 11.

I installed vscode, PlatformIO and built the existing project succesfully. After connecting the ESP8266 to the compressor using USB, Windows automatically installed drivers for it (or actually for the USB/serial adapter CH340).

When trying to upload the project to the ESP8266 the process fails to an error:

serial.serialutil.SerialException: Cannot configure port, something went wrong. Original message: PermissionError(13, 'A device attached to the system is not functioning.', None, 31)

No matter what I do, the error still persist. When trying the same ESP and project with older PC, everything works fine.

The fix

After searching around, I found a StackOverflow question with similar problem. The user had issues with some driver version.

There was an useful answer that indeed mentions Windows 11 and driver problems. The solution was to install older drivers for CH340.

The drivers Windows 11 had automatically installed were quite recent, from 2023. I searched around and downloaded the drivers from 2011, installed them and everything started working!


The drivers are also available here on my Github repository:

Written on September 9, 2023