# How can i fix this error?

**URL:** <https://forum.arduino.cc/t/how-can-i-fix-this-error/1097467>\
**Category:** Uploading\
**Created:** [March 3, 2023, 9:04pm UTC](https://forum.arduino.cc/t/how-can-i-fix-this-error/1097467 "2023-03-03T21:04:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![crax](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@crax](https://forum.arduino.cc/u/crax)\
**Post date:** [March 3, 2023, 9:04pm UTC](https://forum.arduino.cc/t/how-can-i-fix-this-error/1097467/1 "2023-03-03T21:04:25Z")

</div>

#include \<DHT.h\>

#define Type DHT11  
int sensePin = 2;  
DHT HT(sensePin, Type);  
float humidity;  
float tempC;  
float tempF;  
int dt = 200;

void setup() {  
// put your setup code here, to run once:  
Serial.begin(9600);  
HT.begin();  
delay(dt);  
}

void loop() {  
// put your main code here, to run repeatedly:  
humidity = HT.readHumidity();  
tempC = HT.readTemperature();  
tempF = HT.readTemperature(true);

Serial.print("Humidity: ");  
Serial.print(humidity);

Serial.print(" TempC: ");  
Serial.print(tempC);

Serial.print(" TempF");  
Serial.println(tempF);  
delay(dt);  
}

Im getting this error:  
Sketch uses 5226 bytes (17%) of program storage space. Maximum is 30720 bytes.  
Global variables use 257 bytes (12%) of dynamic memory, leaving 1791 bytes for local variables. Maximum is 2048 bytes.  
avrdude: ser\_open(): can't open device "\.\COM2": Access is denied.

Failed uploading: uploading error: exit status 1

when i restart my laptop and run the program it works for the first time then makes a sound then keeps giving me this error and i tried change the COM. Its telling me COM3 is being used so im not using that COM.

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [March 3, 2023, 9:10pm UTC](https://forum.arduino.cc/t/how-can-i-fix-this-error/1097467/2 "2023-03-03T21:10:21Z")

</div>

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'  
  
Use **code tags** (the \</\> icon above the compose window)&nbsp;to make it easier to read and copy for examination

> [@How to get the best out of this forum](https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966):
>
> See also [FAQ - Arduino Forum](https://forum.arduino.cc/faq) for general rules on forum behaviour and etiquette. Hello, Welcome to the Arduino Forum. This guide explains how to get the best out of this forum. Please read and follow the instructions below. Being new here you might think this is having rules for the sake of rules, but that is not the case. If you don’t follow the guidelines all that happens is there is a long exchange of posts while we try to get you to tell us what we need in order to help you, which is fru…

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [March 3, 2023, 11:17pm UTC](https://forum.arduino.cc/t/how-can-i-fix-this-error/1097467/3 "2023-03-03T23:17:36Z")

</div>

Unplug the Arduino, open the Device Manager and note which COM ports are present.

Plug in the Arduino and note the new port that appears in Device Manager. Select that port in the Arduino IDE and upload.

These instructions assume that you have already installed the com port driver for the programmer you are using.

---

<div class="post-metadata">

**Author:** ![crax](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@crax](https://forum.arduino.cc/u/crax)\
**Post date:** [March 4, 2023, 2:14pm UTC](https://forum.arduino.cc/t/how-can-i-fix-this-error/1097467/5 "2023-03-04T14:14:32Z")

</div>

from where do i install the com port driver, just checking incase i didnt

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [March 4, 2023, 3:37pm UTC](https://forum.arduino.cc/t/how-can-i-fix-this-error/1097467/6 "2023-03-04T15:37:19Z")

</div>

Follow the instructions in post #2, and then for whatever Arduino, programmer or interface you are using.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [August 31, 2023, 3:38pm UTC](https://forum.arduino.cc/t/how-can-i-fix-this-error/1097467/7 "2023-08-31T15:38:15Z")

</div>

Closed on August 31, 2023, 3:38pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
