Arduino uno wifi rev2 can not upload any sketch

Although they have similar names, the Arduino Uno WiFi and the Arduino Uno WiFi Rev2 are very different things. You have an Arduino Uno WiFi Rev2, but you have selected Tools > Board > Arduino Uno WiFi. That is the cause of the error. Please do this:

  • Tools > Board > Boards Manager
  • Wait for downloads to finish.
  • Click on "Arduino megaAVR Boards by Arduino".
  • Click "Install".
  • Wait for installation to finish.
  • Click "Close".
  • Tools > Board > Arduino Uno WiFi Rev2
  • Try uploading again.