-
Notifications
You must be signed in to change notification settings - Fork 0
/
STM32_DHT11.ino
71 lines (33 loc) · 1.16 KB
/
STM32_DHT11.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <Wire.h> //Library for using I2C
#include <LiquidCrystal_I2C.h> //Library for using I2C type LCD display
#include <DHT.h> //Library for using DHT sensor
#define DHTPIN PA1
#define DHTTYPE DHT11
LiquidCrystal_I2C lcd(0x27, 16, 2); //initilize object lcd for class LiquidCrystal_I2C with I2C address of 0x27 and 16x2 type LCD display
DHT dht(DHTPIN, DHTTYPE); //initilize object dht for class DHT with DHT pin with STM32 and DHT type as DHT11
void setup()
{
// initialize the LCD
lcd.begin();
dht.begin(); //Begins to receive Temperature and humidity values.
lcd.backlight(); // Turn on the blacklight and print a welcome message.
lcd.setCursor(0,0);
lcd.print("_______");
lcd.setCursor(0,1);
lcd.print("DHT11 with STM32");
delay(3000);
lcd.clear();
}
void loop()
{
float h = dht.readHumidity(); //Gets Humidity value
float t = dht.readTemperature(); //Gets Temperature value
lcd.setCursor(0,0);
lcd.print("Temp: ");
lcd.print(t);
lcd.print(" C");
lcd.setCursor(0,1);
lcd.print("Humid: ");
lcd.print(h);
lcd.print(" %");
}