Running DHT11 on Wemos

Salam Semua..

Fuad sedang coba running DHT11/ sensor suhu pada board wemos nih, dan setelah mencari cari source nya dapat lah kodingan sebagai berikut

// – Adafruit Unified Sensor Library: https://github.com/adafruit/Adafruit_Sensor
// – DHT Sensor Library: https://github.com/adafruit/DHT-sensor-library

#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>

#define DHTPIN D5 // Pin which is connected to the DHT sensor.

// Uncomment the type of sensor in use:
#define DHTTYPE DHT11 // DHT 11

DHT_Unified dht(DHTPIN, DHTTYPE);

uint32_t delayMS;

void setup() {
Serial.begin(9600);
// Initialize device.
dht.begin();
Serial.println(“DHTxx Unified Sensor Example”);
// Print temperature sensor details.
sensor_t sensor;
dht.temperature().getSensor(&sensor);
Serial.println(“————————————“);
Serial.println(“Temperature”);
Serial.print (“Sensor: “); Serial.println(sensor.name);
Serial.print (“Driver Ver: “); Serial.println(sensor.version);
Serial.print (“Unique ID: “); Serial.println(sensor.sensor_id);
Serial.print (“Max Value: “); Serial.print(sensor.max_value); Serial.println(” *C”);
Serial.print (“Min Value: “); Serial.print(sensor.min_value); Serial.println(” *C”);
Serial.print (“Resolution: “); Serial.print(sensor.resolution); Serial.println(” *C”);
Serial.println(“————————————“);
// Print humidity sensor details.
dht.humidity().getSensor(&sensor);
Serial.println(“————————————“);
Serial.println(“Humidity”);
Serial.print (“Sensor: “); Serial.println(sensor.name);
Serial.print (“Driver Ver: “); Serial.println(sensor.version);
Serial.print (“Unique ID: “); Serial.println(sensor.sensor_id);
Serial.print (“Max Value: “); Serial.print(sensor.max_value); Serial.println(“%”);
Serial.print (“Min Value: “); Serial.print(sensor.min_value); Serial.println(“%”);
Serial.print (“Resolution: “); Serial.print(sensor.resolution); Serial.println(“%”);
Serial.println(“————————————“);
// Set delay between sensor readings based on sensor details.
delayMS = sensor.min_delay / 1000;
}

void loop() {
// Delay between measurements.
delay(delayMS);
// Get temperature event and print its value.
sensors_event_t event;
dht.temperature().getEvent(&event);
if (isnan(event.temperature)) {
Serial.println(“Error reading temperature!”);
}
else {
Serial.print(“Temperature: “);
Serial.print(event.temperature);
Serial.println(” *C”);
}
// Get humidity event and print its value.
dht.humidity().getEvent(&event);
if (isnan(event.relative_humidity)) {
Serial.println(“Error reading humidity!”);
}
else {
Serial.print(“Humidity: “);
Serial.print(event.relative_humidity);
Serial.println(“%”);
}
}

 

Dari syntak nya pasti sudah pada tau yah ini bahasa apa..
Yupss… Bahasa C
Dan Fuad menggunakan aplikasi Arduino untuk menjalankan nya,

Dannn.. berhasil..
tampilan yang dikanan itu adalah serial monitor dari si program yang dikiri
dan data tersebut lah yang Fuad butuhkan .. hehe

Tunggu cermi Fuad selanjut nya ya .. ^^

117 Total Views 1 Views Today
Views All Time
Views All Time
116
Views Today
Views Today
1

Article written by

Success is not the key to happiness. Happiness is the key to success. If you love what you are doing, you will be Successful ^^

19 Responses

  1. Tetap semangat ya Fuad untuk Projectnya, selalu di tunggu kedepannya seperti apa. Awalnya bingung ni codding mau seperti apa soalnya kan belum sempurna 😀
    Lanjutkan Bos 🙂 😉

Leave a Reply

You must be logged in to post a comment.