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

13K4117

Intro: 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


10 Comments

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

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.

Need to add..

DHT dht(DHTPIN, DHTTYPE);

directly after..

#define DHTPIN D4
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
Could you please expand? Where do we need to put DHT dht(DHTPIN, DHTTYPE);?
Could you please recommend a DHT library to use aswell?
Thank you! That helped me fix my compiling error.
Na compilação o resultado foi:
'Horas' does not name a type.
Alguém sabe como resolver ?
Obrigado
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.
How to change displayed temp to Fahrenheit?

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