#include <DHT.h>
#define DHTPIN 11
#define DHTTYPE DHT22
DHT dht(DHTPIN,DHTTYPE);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, STM32!");
dht.begin();
}
void loop() {
// put your main code here, to run repeatedly:
float h = dht.readHumidity();
float tc = dht.readTemperature();
if (isnan(h) || isnan(tc) ) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
delay(2000); // this speeds up the simulation
Serial.print("Humidity is ");
Serial.println(h);
Serial.print("Temperature is ");
Serial.println(tc);
}
Loading
st-nucleo-l031k6
st-nucleo-l031k6