The Assignment for this week was the following:
For this Assignment I used a Humidity and temperature sensor. With a help of a library for the arduino IDE you can read and output the values of the sensor. The sensor has three pins.
To use the sensor you have to download the DHT-sensor library. You can find it here: DHT-sensor-library. You also have to download this library so the DHT-sensor-library will work properly Adafruit_Sensor. The code for this Assignment looks like this:
#include "DHT.h"
#define DHT_PIN 10
#define DHTTYPE DHT11
DHT dht(DHT_PIN, DHTTYPE);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Humidity and temperature monitor started!");
dht.begin();
}
void loop() {
// put your main code here, to run repeatedly:
delay(3000);
float h = dht.readHumidity();
float t = dht.readTemperature();
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" \t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.println("");
}
After installing the libraries and writing the code i uploaded it on my microcontroller board. After uploading the code I started the serial monitor screen so i can see if the code works properly. Below you can see the board connected to my computer through a ftdi-cable.
The output looks like this