Seeed-Studio / Grove_Temperature_And_Humidity_Sensor

Arduino library for the DHT series temperature&humidity sensors
http://www.seeedstudio.com/depot/grove-temperaturehumidity-sensor-pro-p-838.html
MIT License
64 stars 61 forks source link

DHT22 Sensor doesn’t work with Arduino Nano 33 BLE with Base Shield #20

Closed oiueei closed 1 year ago

oiueei commented 1 year ago

If I try that lib with an Arduino UNO I can access the data from the temperature and humidity sensor, but the same sample code does not work on my Arduino Nano 33 BLE...

Could it be because one board is based on the ATmega328P, and the other is based on the nRF52840 microcontroller?

Is there something we can do to redress this?

oiueei commented 1 year ago

It is running now! I installed the SensorKit_Arduino lib and dependencies, and with the below code, it runs :grinning:

#include "DHT.h"

#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);
  Serial.println(F("DHTxx test!"));

  dht.begin();
}

void loop() {
  delay(2000);

  float h = dht.readHumidity();
  float t = dht.readTemperature();

  if (isnan(h) || isnan(t)) {
    Serial.println(F("Failed to read from DHT sensor!"));
    return;
  }

  float hic = dht.computeHeatIndex(t, h, false);

  Serial.print(F("Humidity: "));
  Serial.println(h);

  Serial.print(F("Temperature: "));
  Serial.print(t);
  Serial.println(F("°C "));

  Serial.print(F("HIC: "));
  Serial.print(hic);
  Serial.println(F("°C "));

  Serial.println("--------------------");
  delay(1000);

}