Simple DHT Error 3856 - using DHT22

Hi, I am having a problem with my DHT22. Everything else is working except my DHT22. Here is my Serial Monitor Output:

07:53:09.063 -> [8016] Connecting to (mynetworkname)
07:53:09.097 -> [8017] Connected to WiFi
07:53:09.097 -> [8017] IP: 192.168.1.14
07:53:09.131 -> [8017] 
07:53:09.131 ->     ___  __          __
07:53:09.165 ->    / _ )/ /_ _____  / /__
07:53:09.200 ->   / _  / / // / _ \/  '_/
07:53:09.234 ->  /____/_/\_, /_//_/_/\_\
07:53:09.268 ->         /___/ v0.6.1 on NodeMCU
07:53:09.303 -> 
07:53:09.303 -> [8126] Connecting to blynk-cloud.com:80
07:53:09.508 -> [8473] Ready (ping: 263ms).
07:53:09.576 -> Connecting.
07:53:09.576 -> ERROR: 3856

As you can see, everything seems to be fine except the DHT. From what I have managed to decode from google, I think it needs a higher voltage? But I am not sure and don’t want to fry my DHT22.

PS - (mynetworkname) is usually my network name, I just changed it for privacy and etc

Code:

#include <SimpleDHT.h>
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Arduino_JSON.h>


#define DHTTYPE DHT22

char auth[] = "my auth code usually goes here";
char ssid[] = "My internet ssid is usually here";
char pass[] = "My internet password is usually here";

String data;

const int dht_pin = 2;
SimpleDHT22 dht22(dht_pin);
float humidity = 0;
float temperature = 0;

BlynkTimer timer;

void wait() {
  Serial.println("delay");
}

void setup() {
  Serial.begin(9600);
  timer.setInterval(5000L, wait);
}

void loop() {

  Blynk.begin(auth, ssid, pass);
  Serial.println("Connecting.");

  int err = SimpleDHTErrSuccess;
  if((err = dht22.read2(&temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
    Serial.print("ERROR: ");
    Serial.println(err);
    delay(2000);
    return;
  }
    
  Blynk.virtualWrite(V5, float(humidity));
  Blynk.virtualWrite(V6, float(temperature));
  Serial.println(float(temperature));
  Serial.println(float(humidity));
  Blynk.run();
  Serial.println("Sent data");

  //ESP.deepSleep(600e6);
  //ESP.deepSleep(1e6);
  timer.run();
}

Thanks in advance!

Does the DHT work with a simple "read the values and print them to Serial" sketch ?

Are there examples with the library ?
Where did you get the library from ?

Hi Bob,
Thanks for replying.

I got the library from github (GitHub - winlinvip/SimpleDHT: Simple, Stable and Fast Arduino Temp & Humidity Sensors for DHT11 and DHT22. http://learn.adafruit.com/dht)
Yes, there are examples (SimpleDHT/examples at master · winlinvip/SimpleDHT · GitHub)
When I run DHT22 Default I get this serial output

18:11:20.094 -> $ܟ<

I don’t actually get that output. I get a long string of unrecognised characters and question/exclamation marks and brackets that keeps on getting longer (not downwards, but right)

I also ran some examples from the default dht library, specifically DHT_ESP8266 and I get:

18:15:46.273 -> ⸮⸮⸮⸮⸮⸮

I tired unplugging the esp and plugging it in again and I get

18:17:22.051 -> ⸮⸮⸮,⸮׹1⸮⸮)!⸮׹⸮⸮

I am now running my code again to see if there is a problem with the board (which is. by the way, a NODEMCU ESP-12E)

And it has the same output as in my original post.
Now I am trying to run DHT22Integer example from SimpleDHT:

 ׹1⸮)!ь)!ь)⸮⸮⸮)!

More corruption :confused:

Now DHT22RawBits example:

18:21:52.756 -> ⸮⸮⸮⸮⸮0⸮1⸮⸮⸮⸮⸮

I am now trying installing the Simple DHT library from the arduino IDE library menu to the latest version, which shouldn’t do much since I got the library from github literally this week.

Restarted Arduino IDE, unplugged and plugged back in esp, ran my code:

ERROR: 3856

again

DHT22Default example:

18:26:20.972 -> ׹1⸮⸮⸮⸮⸮׹1⸮⸮WH⸮

I’m really confused

I just changed baud rate to 115200 and now I get:

18:29:53.156 -> Sample DHT22...
18:29:53.156 -> Read DHT22 failed, err=4880

I read this and it says a lot about power - I'll try some solutions

Oh dear me. It turns out pin 2 is GPIO 2, which is d4. I had it connected to d2. Now it works :confused:

Update: it was working, tried uploading my code - now it doesn't work, and the example doesn't work either

what have I done

Right here is the situation straight:
After figuring out why the error messages were corrupted, fixing that, and then finding the right pin to plug the dht22 in, I finally got it work, and then for some reason it stopped working. So now it just prints error message 4880 and occasionally 5136. Here is a printout:

9:40:03.880 -> Read DHT22 failed, err=4880
19:40:05.909 -> =================================
19:40:05.909 -> Sample DHT22...
19:40:05.909 -> Read DHT22 failed, err=4880
19:40:07.904 -> =================================
19:40:07.904 -> Sample DHT22...
19:40:07.904 -> Read DHT22 failed, err=4880
19:40:09.887 -> =================================
19:40:09.887 -> Sample DHT22...
19:40:09.887 -> Read DHT22 failed, err=4880
19:40:11.884 -> =================================
19:40:11.917 -> Sample DHT22...
19:40:11.917 -> Read DHT22 failed, err=4880
19:40:13.914 -> =================================
19:40:13.914 -> Sample DHT22...
19:40:13.914 -> Read DHT22 failed, err=4880
19:40:15.918 -> =================================
19:40:15.918 -> Sample DHT22...
19:40:15.918 -> Read DHT22 failed, err=4880
19:40:17.890 -> =================================
19:40:17.925 -> Sample DHT22...
19:40:17.925 -> Read DHT22 failed, err=4880
19:40:19.894 -> =================================
19:40:19.894 -> Sample DHT22...
19:40:19.894 -> Read DHT22 failed, err=4880
19:40:21.924 -> =================================
19:40:21.924 -> Sample DHT22...
19:40:21.924 -> Read DHT22 failed, err=5136
19:40:23.916 -> =================================
19:40:23.916 -> Sample DHT22...
19:40:23.916 -> Read DHT22 failed, err=5136
19:40:25.917 -> =================================
19:40:25.917 -> Sample DHT22...
19:40:25.917 -> Read DHT22 failed, err=5136
19:40:27.909 -> =================================
19:40:27.909 -> Sample DHT22...
19:40:27.909 -> Read DHT22 failed, err=5136
19:40:29.908 -> =================================
19:40:29.908 -> Sample DHT22...
19:40:29.908 -> Read DHT22 failed, err=5136
19:40:31.898 -> =================================
19:40:31.933 -> Sample DHT22...
19:40:31.933 -> Read DHT22 failed, err=5136

Example code I am running:

#include <SimpleDHT.h>

// for DHT22, 
//      VCC: 5V or 3V
//      GND: GND
//      DATA: 2
int pinDHT22 = 2;
SimpleDHT22 dht22(pinDHT22);

void setup() {
  Serial.begin(115200);
}

void loop() {
  // start working...
  Serial.println("=================================");
  Serial.println("Sample DHT22...");
  
  // read without samples.
  // @remark We use read2 to get a float data, such as 10.1*C
  //    if user doesn't care about the accurate data, use read to get a byte data, such as 10*C.
  float temperature = 0;
  float humidity = 0;
  int err = SimpleDHTErrSuccess;
  if ((err = dht22.read2(&temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
    Serial.print("Read DHT22 failed, err="); Serial.println(err);delay(2000);
    return;
  }
  
  Serial.print("Sample OK: ");
  Serial.print((float)temperature); Serial.print(" *C, ");
  Serial.print((float)humidity); Serial.println(" RH%");
  
  // DHT22 sampling rate is 0.5HZ.
  delay(2500);
}

Which Arduino board are you using ?

robtherobot:
I am now running my code again to see if there is a problem with the board (which is. by the way, a NODEMCU ESP-12E)

Here ^

Have you tried other DHT libraries ?

I will do that once I get home, I did, and I think I write about them, but I had that Serial Problem which is now fixed, so we'll see.

Maybe try using another GPIO pin. Not all GPIOs can be used for in-/output, see

This is very useful too #363 Which ESP32 pins are safe to use? - YouTube

Oh my god, thanks so much

It was the pin - the example works every time now.
My code still doesn't work, but I'll just compare it to the example and send an update soon.

Thanks a lot !