Tijekom pandemije COVID-19, e-radionica.com nastavlja s normalnim radom. Sve mjere opreza se redovno poduzimaju te su naručeni paketi sigurni. Opcija dostave uslugama Hrvatske Pošte i osobno preuzimanje privremeno su onemogućeni iz sigurnosnih razloga.

  • Worldwide Shipping

  • 24/7 Customer Support

  • FAQ
  • Worldwide Shipping

  • 24/7 Customer Support

  • FAQ

Blynk + Croduino NOVA: Temperature and humidity reading (part 2/3)

In this example, we will measure temperature and humidity using the DHT11 sensor. Read more about the sensor here.

Blynk tutorial series consist of 3 parts;
1st part: Introduction, LED
2nd part: Temperature and humidity reading
3rd part: Controlling the motor

APPLICATION

In the same way as in the first example (link), we create a new project, but this time, instead of the button, we will use two new widgets called "gauge" which will display the measured data.

We connect the temperature to the virtual pin V6, and humidity to V5. Virtual pins always have V+number (V0, V1, V2...) marks which serve to send any type of data from the microcontroller and back to the application.

CONNECTING

Connect the sensor as shown in the picture, so we can start writing the code.

THE CODE

Since we are using the DHT11 temperature and humidity sensor, it is necessary to install its library.

Introductions on how to work with the DHT11

Also, re-enter your WiFi network data and the authorization token for this project.

#define BLYNK_PRINT Serial
#include "ESP8266WiFi.h"
#include "BlynkSimpleEsp8266.h"
#include "dht.h"
char auth[] = "AuthToken";
char ssid[] = "NazivMreže";
char pass[] = "LozinkaMreže";
#define DHTPIN 2
dht DHT;
BlynkTimer timer;
void sendSensor(){
DHT.read11(DHTPIN);
float h = DHT.humidity;
float t = DHT.temperature;
Blynk.virtualWrite(V5, h);
Blynk.virtualWrite(V6, t);
}
void setup(){
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
timer.setInterval(1000L, sendSensor);
}
void loop(){
Blynk.run();
timer.run();
}

In the following example, learn how to control speed of the DC motor using Blynk application. Click here!

Leave a Reply