DHT11 Sensor not reading anything

I've tried multiple iterations of code, changed different signal pins, attempted to use example sketches for testing purposes and even went out and bought a second DHT11 sensor to try and get this thing to work but cannot, for the life of me, figure out why I'm not getting any readings.

I'm using an Arduino Nano 33 IoT with either DHT11 sensors and everytime there is a failed reading.

Here's the code that I am attempting to get running, note that the 'example' sections are filled out with relative information on my behalf (blocked for obvious reasons in this example)

#include <SPI.h>
#include <WiFiNINA.h>
#include <DHT.h>
#include <ThingSpeak.h>

// WiFi credentials
char ssid[] = "Example";
char password[] = "Example";

// ThingSpeak credentials
unsigned long myChannelNumber = Example;  // Replace with your ThingSpeak channel number
const char* myWriteAPIKey = "Example";    // Replace with your ThingSpeak API Key

WiFiClient client;

#define DHTPIN 2         // Pin connected to DHT11 data pin
#define DHTTYPE DHT11    // Sensor type
DHT dht(DHTPIN, DHTTYPE);

void setup() {
    Serial.begin(115200);
    while (!Serial);

    // Initialize DHT sensor
    dht.begin();

    // Connect to WiFi
    Serial.print("Connecting to WiFi...");
    WiFi.begin(ssid, password);
    while (WiFi.status() != WL_CONNECTED) {
        Serial.print(".");
        delay(1000);
    }
    Serial.println("\nConnected to WiFi!");

    // Initialize ThingSpeak
    ThingSpeak.begin(client);
}

void loop() {
    float humidity = dht.readHumidity();
    float temperature = dht.readTemperature(); // Celsius

    // Check if reading is valid
    if (isnan(humidity) || isnan(temperature)) {
        Serial.println("Failed to read from DHT sensor!");
        delay(5000);
        return;
    }

    // Print data
    Serial.print("Temperature: ");
    Serial.print(temperature);
    Serial.print("°C  Humidity: ");
    Serial.print(humidity);
    Serial.println("%");

    // Upload data to ThingSpeak
    ThingSpeak.setField(1, temperature);
    ThingSpeak.setField(2, humidity);
    int response = ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);

    if (response == 200) {
        Serial.println("Data sent to ThingSpeak successfully.");
    } else {
        Serial.print("Failed to send data. Error code: ");
        Serial.println(response);
    }

    // Wait 15 seconds before next update (ThingSpeak limit)
    delay(15000);
}

Welcome to the forum

How is the DHT11 connected to the Arduino ?

What voltage does the sensor run at, bearing in mind that the Nano 33 IOT runs at 3.3V ?

Have you tried a simple sketch that outputs the data to the Serial monitor rather than the complicated one using ThingSpeak ?

That's the way.
Do you have bare sensor or module (sensor on pcb)?

Is there any error message that you are seeing?

Hi! Welcome to the Forum.

Are you trying to feed the sensor through the 5V (VUSB) pin?

The Nano 33 IoT is a tricky board regarding this pin. It's disconnected off the shelf and will only work if you solder the pads:

Use the 3.3V pin or, just as a test, set pin D3 as OUTPUT, HIGH and use it as the DHT11 VCC (don't make a habit of it tho).

My secret of powering 25KG servos is revealed... :sob:

:rofl:

Hi

I've connected to DHT11 directly through jumper wires. I have the left pin connected to D2 or any data pin, I have the middle pin connected to either the 3.3V or VUSB pin (neither seem to work) and the right pin connected to GND.

From my understanding the sensor is capable of running at 3.3V, but I have experimented with a variety of pins to see if that is the issue, of which it is not.

And yes, I have tried the tester sketch for DHT to try and gather outputs in the serial monitor, to which I have had zero success

Also worth noting that I have two different sensors, the second of which I purchased to see if it was a hardware issue.

This is the first:

And this is the second:

Could if potentially be worth removing the solder on the second and swapping onto the first?

Is one of the two working on your Nano?

This is a module. On the page it states clearly that the working voltage is 5V.

This is a "shield" made to be used with the Duinotech Wi-Fi Mini Main Board. You can try to use it, but the page says the data pin that is connected to the DHT11 is pin 4. In this case you need to change it in your sketch (you're assigning pin 2 to the sensor).

This is my Nano 33 IoT working with a DHT11 module:

The module is fed by the Nano 3.3V pin. Connections done directly with jumpers as you stated you did.
Data = brown ; VCC = red ; GND = black