# DHT22 stops working after unplugging from computer

**URL:** <https://forum.arduino.cc/t/dht22-stops-working-after-unplugging-from-computer/1442093>\
**Category:** General Guidance\
**Created:** [April 30, 2026, 8:49am UTC](https://forum.arduino.cc/t/dht22-stops-working-after-unplugging-from-computer/1442093 "2026-04-30T08:49:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![picwaeim](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/picwaeim/32/1099501_2.png) [@picwaeim](https://forum.arduino.cc/u/picwaeim)\
**Post date:** [April 30, 2026, 8:49am UTC](https://forum.arduino.cc/t/dht22-stops-working-after-unplugging-from-computer/1442093/1 "2026-04-30T08:49:06Z")

</div>

I am working on a few temperature sensors for my house. Two of the three are working just fine. But for some reason the third is giving me issues. The code for all 3 was downloaded from Sinric Pro using their zero code option. The DHT22 is connected to an ESP-12E and the sensor has a built in resistor.

After uploading the code to the board and it is powered through the USB port on my computer, everything works just fine and return the temperature and humidity. I had this running for a few days to make sure. However, when I unplug and power the board through any other power source, the DHT22 returns 0 for temperature and 1 or 2 for humidity initially and does not update anymore (it's set to update every minute).

When I plug the board back into my laptop, after trying with an external power supply, the DHT22 returns 0 degrees and 1% humidity but doesn't update. If I upload the code to the board again, everything works fine but as soon as I unplug the board and try with an external power source again, the problem returns.

I don't think it is a power supply problem. If it was a power supply problem, the device would function properly if I plugged it back into the computer. But, after removing it from the computer, plugging it into my USB adapter and then back into the computer, it doesn't work.

The power supply/USB adapter I have is 5V, 2.4A and the exact same one is powering the other two sensors just fine. I've tried switching power supplies to the other ones I have with zero success.  
[CNC Machining Service](https://www.gazfull.com/)  
I've tried different cables, different power supplies (I bought 3 of everything and the other two function perfectly fine with those plugs) and just can't figure it out. My code is below. Thank you for any insight in advance.

UPDATE: I tried 3 different DHT22s and 2 different ESP-12E boards and the result was the same.

/\*

- Example for how to use SinricPro Temperaturesensor device:
- 
  - setup a temperature sensor device

- 
  - send temperature event to SinricPro server when temperature has changed

- 
- 
- DHT Library used in this example: [GitHub - markruys/arduino-DHT: Efficient DHT library for Arduino · GitHub](https://github.com/markruys/arduino-DHT)
- 
- If you encounter any issues:
- 
  - check the readme.md at [esp8266-esp32-sdk/README.md at master · sinricpro/esp8266-esp32-sdk · GitHub](https://github.com/sinricpro/esp8266-esp32-sdk/blob/master/README.md)

- 
  - ensure all dependent libraries are installed

- 
  - see [esp8266-esp32-sdk/README.md at master · sinricpro/esp8266-esp32-sdk · GitHub](https://github.com/sinricpro/esp8266-esp32-sdk/blob/master/README.md#arduinoide)

- 
  - see [esp8266-esp32-sdk/README.md at master · sinricpro/esp8266-esp32-sdk · GitHub](https://github.com/sinricpro/esp8266-esp32-sdk/blob/master/README.md#dependencies)

- 
  - open serial monitor and check whats happening

- 
  - check full user documentation at [https://sinricpro.github.io/esp8266-esp32-sdk](https://sinricpro.github.io/esp8266-esp32-sdk)

- 
  - visit [Issues · sinricpro/esp8266-esp32-sdk · GitHub](https://github.com/sinricpro/esp8266-esp32-sdk/issues) and check for existing issues or open a new one  
\*/

#define ENABLE\_DEBUG

#ifdef ENABLE\_DEBUG  
#define DEBUG\_ESP\_PORT Serial  
#define NODEBUG\_WEBSOCKETS  
#define NDEBUG  
#endif

#include \<Arduino.h\>  
#if defined(ESP8266)  
#include \<ESP8266WiFi.h\>  
#elif defined(ESP32) || defined(ARDUINO\_ARCH\_RP2040)  
#include \<WiFi.h\>  
#endif

#include "SinricPro.h"  
#include "SinricProTemperaturesensor.h"  
#include "DHT.h" // [GitHub - markruys/arduino-DHT: Efficient DHT library for Arduino · GitHub](https://github.com/markruys/arduino-DHT)

#define WIFI\_SSID "my wifi"  
#define WIFI\_PASS "my password"  
#define APP\_KEY "from sinric pro"  
#define APP\_SECRET "from sinric pro"  
#define TEMP\_SENSOR\_ID "from sinric pro"  
#define BAUD\_RATE 115200 // Change baudrate to your need (used for serial monitor)  
#define EVENT\_WAIT\_TIME 60000 // send event every 60 seconds

#define DHT\_PIN 14

DHT dht; // DHT sensor

float temperature; // actual temperature  
float humidity; // actual humidity  
float lastTemperature; // last known temperature (for compare)  
float lastHumidity; // last known humidity (for compare)  
unsigned long lastEvent = (-EVENT\_WAIT\_TIME); // last time event has been sent

/\* handleTemperatatureSensor()

- 
  - Checks if Temperaturesensor is turned on

- 
  - Checks if time since last event \> EVENT\_WAIT\_TIME to prevent sending too much events

- 
  - Get actual temperature and humidity and check if these values are valid

- 
  - Compares actual temperature and humidity to last known temperature and humidity

- 
  - Send event to SinricPro Server if temperature or humidity changed  
\*/  
void handleTemperaturesensor() {  
unsigned long actualMillis = millis();  
if (actualMillis - lastEvent \< EVENT\_WAIT\_TIME) return; //only check every EVENT\_WAIT\_TIME milliseconds

if (SinricPro.isConnected() == false) {  
Serial.printf("Not connected to Sinric Pro...!\r\n");  
return;  
}

// temperature = dht.getTemperature(); // get actual temperature in °C  
temperature = dht.getTemperature() \* 1.8f + 29.9; // get actual temperature in °F  
humidity = dht.getHumidity(); // get actual humidity

if (isnan(temperature) || isnan(humidity)) { // reading failed...  
Serial.printf("DHT reading failed!\r\n"); // print error message  
return; // try again next time  
}

if (temperature == lastTemperature || humidity == lastHumidity) return; // if no values changed do nothing...

SinricProTemperaturesensor &mySensor = SinricPro[TEMP\_SENSOR\_ID]; // get temperaturesensor device  
bool success = mySensor.sendTemperatureEvent(temperature, humidity); // send event  
if (success) { // if event was sent successfuly, print temperature and humidity to serial  
Serial.printf("Temperature: %2.1f Celsius\tHumidity: %2.1f%%\r\n", temperature, humidity);  
} else { // if sending event failed, print error message  
Serial.printf("Something went wrong...could not send Event to server!\r\n");  
}

lastTemperature = temperature; // save actual temperature for next compare  
lastHumidity = humidity; // save actual humidity for next compare  
lastEvent = actualMillis; // save actual time for next compare  
}

// setup function for WiFi connection  
void setupWiFi() {  
Serial.printf("\r\n[Wifi]: Connecting");

#if defined(ESP8266)  
WiFi.setSleepMode(WIFI\_NONE\_SLEEP);  
WiFi.setAutoReconnect(true);  
#elif defined(ESP32)  
WiFi.setSleep(false);  
WiFi.setAutoReconnect(true);  
#endif

WiFi.begin(WIFI\_SSID, WIFI\_PASS);

while (WiFi.status() != WL\_CONNECTED) {  
Serial.printf(".");  
delay(250);  
}  
IPAddress localIP = WiFi.localIP();  
Serial.printf("connected!\r\n[WiFi]: IP-Address is %d.%d.%d.%d\r\n", localIP[0], localIP[1], localIP[2], localIP[3]);  
}

// setup function for SinricPro  
void setupSinricPro() {  
// add device to SinricPro  
SinricProTemperaturesensor &mySensor = SinricPro[TEMP\_SENSOR\_ID];

// setup SinricPro  
SinricPro.onConnected({ Serial.printf("Connected to SinricPro\r\n"); });  
SinricPro.onDisconnected({ Serial.printf("Disconnected from SinricPro\r\n"); });  
SinricPro.begin(APP\_KEY, APP\_SECRET);  
}

// main setup function  
void setup() {  
Serial.begin(BAUD\_RATE); Serial.printf("\r\n\r\n");  
dht.setup(DHT\_PIN);

setupWiFi();  
setupSinricPro();  
}

void loop() {  
SinricPro.handle();  
handleTemperaturesensor();  
}

---

<div class="post-metadata">

**Author:** ![pert](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/pert/32/217111_2.png) [@pert](https://forum.arduino.cc/u/pert)\
**Post date:** [April 30, 2026, 9:52am UTC](https://forum.arduino.cc/t/dht22-stops-working-after-unplugging-from-computer/1442093/4 "2026-04-30T09:52:54Z")

</div>

I moved your topic to a more appropriate forum category @picwaeim.

The #Nano Family > Nano ESP32 category you chose is only used for discussions directly related to the [**Arduino Nano ESP32**](https://docs.arduino.cc/hardware/nano-esp32) board.

In the future, when creating a topic please take the time to pick the [forum category](https://forum.arduino.cc/categories) that best suits the subject of your question. There is an " **About the \_\_\_\_\_ category**" topic at the top of each category that explains its purpose.

Thanks in advance for your cooperation.

---

<div class="post-metadata">

**Author:** ![Railroader](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/railroader/32/274550_2.png) [@Railroader](https://forum.arduino.cc/u/Railroader)\
**Post date:** [April 30, 2026, 10:12am UTC](https://forum.arduino.cc/t/dht22-stops-working-after-unplugging-from-computer/1442093/5 "2026-04-30T10:12:21Z")

</div>

Can You translate all the words about plugging into schematics showing the different attempts?

Also please use code tags. Don't post code in the novel text format.

---

<div class="post-metadata">

**Author:** ![robtillaart](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/robtillaart/32/1098811_2.png) [@robtillaart](https://forum.arduino.cc/u/robtillaart)\
**Post date:** [April 30, 2026, 11:53am UTC](https://forum.arduino.cc/t/dht22-stops-working-after-unplugging-from-computer/1442093/6 "2026-04-30T11:53:00Z")

</div>

> [@picwaeim](#):
>
> temperature = dht.getTemperature() \* 1.8f + 29.9; // get actual temperature in °F

A new Fahrenheit formula, where did you get that?

---

<div class="post-metadata">

**Author:** ![TomGeorge](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tomgeorge/32/215261_2.png) [@TomGeorge](https://forum.arduino.cc/u/TomGeorge)\
**Post date:** [April 30, 2026, 12:51pm UTC](https://forum.arduino.cc/t/dht22-stops-working-after-unplugging-from-computer/1442093/7 "2026-04-30T12:51:40Z")

</div>

Hi, @picwaeim  
Welcome to the forum.

Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?  
Hand drawn and photographed is perfectly acceptable.  
Please include ALL hardware, power supplies, component names and pin labels.

Can you post some images of your project?  
So we can see your component layout.

Thanks.. Tom.... 😃 👍 ☕ 🇦🇺

---

<div class="post-metadata">

**Author:** ![sonofcy](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sonofcy/32/1283617_2.png) [@sonofcy](https://forum.arduino.cc/u/sonofcy)\
**Post date:** [April 30, 2026, 1:16pm UTC](https://forum.arduino.cc/t/dht22-stops-working-after-unplugging-from-computer/1442093/8 "2026-04-30T13:16:16Z")

</div>

If I read your OP correctly you have 3 MCU's (ESP-12E) and 3 DHT22 running the same code. Two work a third does not.

Unless there is a rip in the fabric of reason, either the MCU, DHT22 or PSU is defective. You say you have swapped DHT22 and the problem did NOT move, and also changed the ESP-12E and the problem did not move. That only leaves the PSU.  
If swapping the PSU does NOT solve the problem, then as is often the case you are not telling us something. For instance, did you do any soldering?

---

<div class="post-metadata">

**Author:** ![xfpd](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/xfpd/32/1120236_2.png) [@xfpd](https://forum.arduino.cc/u/xfpd)\
**Post date:** [April 30, 2026, 1:23pm UTC](https://forum.arduino.cc/t/dht22-stops-working-after-unplugging-from-computer/1442093/9 "2026-04-30T13:23:52Z")

</div>

And please, format your code...

 ![paste](https://europe1.discourse-cdn.com/arduino/original/4X/c/b/4/cb40e1987fa5e6f7f7cc8197b07ef618b42f4a73.png)

---

<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:** [October 27, 2026, 1:24pm UTC](https://forum.arduino.cc/t/dht22-stops-working-after-unplugging-from-computer/1442093/10 "2026-10-27T13:24:22Z")

</div>

Closed on October 27, 2026, 1:24pm UTC

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