DHT11 and UNO Q

I'm attempting to test using the Arduino UNO Q with a DHT11 temperature sensor on Arduino IDE 2.3.6. I am unable to get any humidity and temperature readings when printing to the Monitor Debugging console. When I re-apply this code to my Arduino UNO R3, I am able to get regular values instead of nan ones. Has anyone able to get the DHT11 libraries to work with the UNO Q and have an example code in IDE 2.3.6 that they can share?

#include <DHT.h>
#include "Arduino_RouterBridge.h"
#include <Arduino.h>

#define DHTPIN A2      // Pin where the DHT11 data line is connected
#define DHTTYPE DHT11  // Sensor type

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Monitor.begin(9600);
  dht.begin();
}

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

  // Check if reads failed
  if (isnan(humidity) || isnan(temperature)) {
    Monitor.println("Failed to read from DHT11 sensor!");
    delay(2000);
    return;
  }

  Monitor.print("Humidity: ");
  Monitor.print(humidity);
  Monitor.print(" %  |  Temperature: ");
  Monitor.print(temperature);
  Monitor.print(" °C  /  ");
  Monitor.print(temperatureF);
  Monitor.println(" °F");

  delay(2000); // DHT11 updates ~ every 2 seconds

Here was the code I was attempting to run on the UNO Q.

The Arduino Q is a totally different beast than any other Arduino ever release before.

It does not work in the same way, so you can't treat it like any previous Arduino. It needs a complex setup so look for a document "getting started with the Arduino Q" for details about this unique board.

I remember @apagliari was doing some work with the related DHT22 sensor. Did you ever have any luck with getting readings from the sensor using your UNO Q board @apagliari?

Hi @ptillisch I’m sorry but I temporary gave up since appartently the library working on all others Arduinos (UnoR4, Nano 33 Iot, MKRWifi1010,..you name it) was not working here and I’ve been left without support by the community and by the available documentation. I’m interested if someone else can sort it out, but for the time being I don’t want to waste additional time in “permutational troubleshooting” :wink: , it is definetely not my kettle of fish.

Yes I did some experiments with the motion sensors on the Arduino Q.
I did create a topic on this but so far there have been no replies to it.

Not able to offer a solution here, but maybe some perspective and where to look for help.
The DHT sensor library uses some low level timing at microsecond level to decode the asynchronous incoming serial data stream.
The Uno Q with an underlying Zephyr RTOS presents some of the low level timing a challenge.
The DHT library already has built in variants for different architectures. I guess it just needs a new one for the Uno Q.
I did take a quick look in debug mode and it does indeed appear to be a timing issue in the processing of the serial data stream.
I think maybe your best approach is to the library provider to help fix this. Of course Arduino support and insight to finding a solution would be valuable.

I found a solution to the problem. I was originally using the TinyDHT library, but it did not work properly with the Arduino Q (UNO R4 WiFi). After switching to a different library called DHTesp, everything worked correctly.

Below is my working code using the DHTesp library.

#include <DHTesp.h>
#include <Arduino_RouterBridge.h>

#define DHTPIN 3

DHTesp dht;
unsigned long lastReadTime = 0;
const unsigned long readInterval = 3000; 

void setup() {
  Monitor.begin();
  delay(2000);
  dht.setup(DHTPIN, DHTesp::DHT22);
  Monitor.println("DHTesp stable reading test starting...");
}

void loop() {
  unsigned long currentTime = millis();
  if (currentTime - lastReadTime >= readInterval) {
    lastReadTime = currentTime;

    float tempC = dht.getTemperature();
    float humidity = dht.getHumidity();

    if (isnan(tempC)  isnan(humidity)  tempC < -40  tempC > 80  humidity < 0 || humidity > 100) {
      Monitor.println("Sensor read error, skipping this reading...");
    } else {
      float tempF = tempC * 9.0 / 5.0 + 32.0;

      String output = "TempF: " + String(tempF, 1) + "  Humidity: " + String(humidity, 1);
      Monitor.println(output);
    }
  }
}