Send Temperature & Humidity to Blynk App (Wemos D1 Mini Pro).

10,401

40

10

Introduction: Send Temperature & Humidity to Blynk App (Wemos D1 Mini Pro).

This Instructable looks at using the Wemos D1 Mini Pro to send datta (Temperature & Humidity) to the Blynk APP.

Step 1: ​Getting Started

We will get a temperature and humidity reading pushed to your Blynk App on your phone. Connect an LED as shown here: Note. I have used the blue DHT11 Digital Temperature/Humidity module which has three pins. The module is from Banggood. Other similar modules from different suppliers may have a different pin layout. Check this. The colours below are correct for the Banggood module:

Blue = Data signal (left)

Red = Vcc +5v (middle)

Black = Ground (right)

Step 2: Important.

As mentioned above.

Note. I used the blue DHT11 Digital Temperature/Humidity module from Banggood which has three pins. Other similar modules from different suppliers may have a different pin layout. Check this. The colours are correct for the Banggood module:

Blue = Data signal (left) Red = Vcc +5v (middle) Black = Ground (right)

Step 3: Getting Started With the Blynk App

Create a Blynk Account After you download the Blynk App, you’ll need to create a New Blynk account. This account is separate from the accounts used for the Blynk Forums, in case you already have one. We recommend using a real email address because it will simplify things later.

Why do I need to create an account?
An account is needed to save your projects and have access to them from multiple devices from anywhere. It’s also a security measure. You can always set up your own Private Blynk Server (Links to an external site.)Links to an external site. and have full control.

Step 4: ​Create a New Project

After you’ve successfully logged into your account, start by creating a new project.

Step 5: Name/Board/Connection

Give it a name and select the appropriate board (Wemos D1 Mini). Now click create.

Step 6: Authentication

Your Authentication token will be emailed to you and you will also be able to access it in the settings of your project. A new number will be generated for each project you create.

Step 7: ​Add Two Widgets (Value Display)

Your project canvas is empty, let’s add a two display widgets to show temperature and humidity. Tap anywhere on the canvas to open the widget box. All the available widgets are located here.

Step 8: Drag N Drop

Drag-n-Drop - Tap and hold the Widget to drag it to the new position.

Step 9: Humidity

Widget Settings - Each Widget has it’s own settings. Tap on the widget to get to them. Set them up with the following settings.

Step 10: Temperature

Widget Settings - Each Widget has it’s own settings. Tap on the widget to get to them. Set them up with the following settings.

Step 11: Run the Project.

Step 12: Run the Code.

Now let’s take a look at the example sketch for a Wemos D1 Mini Pro. Notice there are three key components that you will need to include:

1. char auth[] = ""; Specific to your project (Blynk App).

2. char ssid[] = ""; Specific to the network that we are connecting to (network name). You can "hotspot" from your phone also.

3. char pass[] = ""; Specific to the network we are connecting to (password).

CODE

#define BLYNK_PRINT Serial
 
#include <ESP8266WiFi.h>

#include <BlynkSimpleEsp8266.h>

#include <DHT.h> 

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "";
 
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "";
char pass[] = "";
 
#define DHTPIN D4          // What digital pin we're connected to
#define DHTTYPE DHT11     // DHT 11<p>DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
float t;
float h;

void setup()
{
  // Debug console
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  dht.begin();
  timer.setInterval(1000L, sendSensor);
}
 
void loop()
{
  Blynk.run();
  timer.run();
}
 
 
// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendSensor()
{
  h = dht.readHumidity();
  t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
//  l = analogRead(LDR);
  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);
}
 

Step 13: ​Display

Go back to the Blynk App and check your display. You should see the current temperature & humidity.

Step 14: Photo of Project

Step 15: Video of Project Working

Arduino Contest 2017

Participated in the
Arduino Contest 2017

Be the First to Share

    Recommendations

    • Tinkercad to Fusion 360 Challenge

      Tinkercad to Fusion 360 Challenge
    • Home and Garden Contest

      Home and Garden Contest
    • Woodworking Contest

      Woodworking Contest

    10 Comments

    0
    julian.peter.zewe
    julian.peter.zewe

    Question 1 year ago on Step 15

    Hey guys!

    did the exact same setup but just got the message "Failed to read from DHT Sensor". I tried two different boards and two different DHT11 sensors... The board seems to be fine with the WiFi connection (I also ran another script that just connects it and reads back the status).

    Any ideas?
    cheers

    0
    TalhaK14
    TalhaK14

    Question 3 years ago

    The compiler gives me an error that 'dht was not declared in this scope'. I have tried to install the correct DHT libraries multiple times but the problem persists.

    0
    gusqau
    gusqau

    Answer 2 years ago

    Need to add..

    DHT dht(DHTPIN, DHTTYPE);

    directly after..

    #define DHTPIN D4
    #define DHTTYPE DHT11

    0
    lct4246
    lct4246

    Answer 3 years ago

    DHT dht(DHTPIN, DHTTYPE);

    0
    joet1110
    joet1110

    Reply 3 years ago

    Could you please expand? Where do we need to put DHT dht(DHTPIN, DHTTYPE);?
    Could you please recommend a DHT library to use aswell?

    0
    TivainW
    TivainW

    Reply 3 years ago

    Thank you! That helped me fix my compiling error.

    0
    ricardosimoes78
    ricardosimoes78

    2 years ago

    Na compilação o resultado foi:
    'Horas' does not name a type.
    Alguém sabe como resolver ?
    Obrigado

    0
    vmed
    vmed

    3 years ago

    C:\Users\Victor\Documents\Arduino\libraries\Blynk-0.5.4\src/BlynkSimpleEsp8266.h:18:21: fatal error: version.h: No such file or directory
    #include <version.h>
    ^
    compilation terminated.

    0
    Andrewf64
    Andrewf64

    Question 4 years ago on Step 15

    How to change displayed temp to Fahrenheit?

    0
    Swansong
    Swansong

    4 years ago

    I'd love to have something like this set up here, the weather is so unpredictable lately!