Testing the sensor
We are now going to use the sensor. Again, remember that we are using the Arduino IDE, so we can code just like we would do using an Arduino board. Here, we will simply print the value of the temperature inside the Serial monitor of the Arduino IDE. If it has not been done yet, install the Adafruit DHT sensor library using the Arduino IDE library manager.
This is the complete code for this part:
// Libraries #include "DHT.h" // Pin #define DHTPIN 5 // Use DHT11 sensor #define DHTTYPE DHT11 // Initialize DHT sensor DHT dht(DHTPIN, DHTTYPE, 15); void setup() { // Start Serial Serial.begin(115200); // Init DHT dht.begin(); } void loop() { // Reading temperature and humidity float h = dht.readHumidity(); // Read temperature as Celsius float t = dht.readTemperature(); // Display data Serial.print("Humidity: "); Serial.print(h); Serial.print(" %\t"); Serial.print("Temperature: "); Serial.print(t); Serial.println(" *C "...