HEPTA-Sat Training 2022
/
Lab7-sample_temp-humid-sensor
HeptaSat
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "Dht11.h" 00003 00004 Serial pc(USBTX, USBRX); 00005 Dht11 sensor(p15); 00006 int temp,humid; 00007 00008 int main() { 00009 while(1){ 00010 sensor.read(); 00011 temp = sensor.getFahrenheit(); 00012 humid = sensor.getHumidity(); 00013 temp = (temp - 32.0)/1.80; // Fahrenheit --> Celsius 00014 pc.printf("T: %d, H: %d\r\n", temp, humid); 00015 wait(1.0); 00016 } 00017 }
Generated on Sun Aug 7 2022 04:44:19 by 1.7.2