Linta IqbalSaad Ahmed Waqar
Published © MIT

Remote Temperature Monitoring

Measuring temperature and humidity of environment with dht11 sensor.

IntermediateFull instructions provided2 hours1,007
Remote Temperature Monitoring

Things used in this project

Hardware components

Wemos D1 Mini
Espressif Wemos D1 Mini
×1
DHT11 Temperature & Humidity Sensor (3 pins)
DHT11 Temperature & Humidity Sensor (3 pins)
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Female Header 8 Position 1 Row (0.1")
Female Header 8 Position 1 Row (0.1")
×2
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1

Software apps and online services

Arduino IDE
Arduino IDE
Grandeur
Grandeur

Story

Read more

Schematics

Schematic

Wiring Diagram

Code

Code

C/C++
#include "recipes/WiFi.h"     // Include recipe file to connect to wifi
#include <Grandeur.h>
#include <dht11.h>    //adding dht11 lib
#define DHT11PIN D4
dht11 DHT11;

// Grandeur credentials.
const char* apiKey = "grandeurkyyfbofy146e0rxf9d6xbuei";  
const char* deviceID = "devicekyyfodey146n0rxf8m027aou";
const char* token = "eyJ0b2tlbiI6ImV5SmhiR2NpT2lKSVV6STFOaUlzSW5SNWNDSTZJa3BYVkNKOS5leUpwWkNJNkltUmxkbWxqWld0NWVXWnZaR2MxTVRRMmJ6QnllR1k0YnpWcllqZHNhU0lzSW5SNWNHVWlPaUprWlhacFkyVWlMQ0pwWVhRaU9qRTJORE16TnpZd05qSjkuUWQ2WTZwSU14LVhZYmNudGE0TEc3bDF1SHF3dEtVTW5aLU4yVVZ6VTdTSSJ9";

Grandeur::Project project;
Grandeur::Project::Device device;

void getHum (const char* code,int hum) {   // You can write any type int/double/bool/const char* in place of int and it'll cast humidity to that type.
  // This method prints "humidity" value after it is updated on Grandeur.
  Serial.print("Hum %: ");//Serial.print prints on serial monitor
  Serial.println (hum); 
}

void getTemp (const char* code,int temp) {   // You can write any type int/double/bool/const char* in place of int and it'll cast temperature to that type.
  // This method prints "temperature" value after it is updated on Grandeur.
  Serial.print("Temp (C): ");
  Serial.println (temp); 
}

void setup() {
    Serial.begin(9600); // Start serial on boot
    
   // connectWiFi(WIFI_SSID, WIFI_PASSPHRASE);                                                 
    connectWiFi("S A W", "hahahaha"); // And connect to WiFi with WIFI_SSID and WIFI_PASSPHRASE (Paste your own WiFi SSID and Password here)

     // Initializing.
    project = grandeur.init(apiKey, token);
    device = project.device(deviceID);
}

// Loop function repeats the code in it indefinitely.
void loop() {
    if (project.isConnected()) 
    {
  int readData = DHT11.read(DHT11PIN);   //read data from sensor 
  
  float t = DHT11.temperature ;           //stored value of temperature in variable "t
  device.data().set("tem",t,getTemp);       // This requests to set the "temperature" variable on every loop and calls getTemp() function when the
  // variable is actually updated on Grandeur.
  delay(1000);                            

  float h = DHT11.humidity ;            //stored value of humidity in variable "h"
  device.data().set("hum",h,getHum);      // This requests to set the "humidity" variable on every loop and calls getHum() function when the
  // variable is actually updated on Grandeur.
  delay(1000);

    }
      project.loop();                 // Synchronizing the ESP with the Cloud.
}

Credits

Linta Iqbal
1 project • 38 followers
Saad Ahmed Waqar
1 project • 12 followers

Comments