Hi there
I am new to this and trying to get Blynk working with my DHT22/AM2302 module, Arduino UNO and Ethernet Shield . It’s a class project for my students…
Anyway, both my Blynk Widgets show the humidity value, even though I have temperature and humidity on separate virtual pins.
Please have a look at my code…What am I missing? Any help would be great.
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#define DHTPIN 2
#define DHTTYPE DHT22
DHT_Unified dht(DHTPIN, DHTTYPE);
uint32_t delayMS;
char auth[] = "29cc7f6141894c02bafcaadfc067cc2a";
void setup()
{
Serial.begin(9600);
dht.begin();
delayMS = sensor.min_delay / 1000;
}
void loop() {
Blynk.begin(auth);
// 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("%");
}
Blynk.virtualWrite(1, event.temperature);
Blynk.virtualWrite(2, event.relative_humidity);
Blynk.run();
}
Much appreciated