hello Blynk community
first, i connect 2 nodemcu with wifi and after that i send value temperature of first nodemcu (client) to second nodemcu (server ) and compare 2 value of temperature and control led but it not working . Does any can help me ? thanks you so much
// this is code sever
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <DHT.h>
#define den D0
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "de7e5b820d7a4e54be6d760*******";
char ssid[] = "Nokia5.1"; //Tên wifi
char pass[] = "88888888"; //Mật khẩu
#define SOIL_MOIST_1_PIN A0
#define DHTPIN D3 // What digital pin we're connected to
int soilMoist = 0;
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
SimpleTimer timer;
WidgetBridge bridge1(V1);
BLYNK_WRITE(V11) {
int pinValue = param.asInt();
}
BLYNK_CONNECTED() {
bridge1.setAuthToken("de7e5b820d7a4e54*********");
}
void sendSensor(){
float hsever = dht.readHumidity();
float tsever = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
if (isnan(hsever) || isnan(tsever)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Blynk.virtualWrite(V3, hsever);
Blynk.virtualWrite(V4, tsever);
if( tsever < V11 )
{
digitalWrite(den,1);
}
else{
digitalWrite(den,0);
}
}
void setup(){
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
dht.begin();
timer.setInterval(1000L, sendSensor);
}
void loop(){
Blynk.run();
timer.run();
}
and this is client
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>
#define DHTPIN D2
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
#include <SimpleTimer.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "de7e5b820d7a4e54be6d7****5a84d6";
SimpleTimer timer;
int soilMoist = 0;
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Nokia5.1"; //Tên wifi
char pass[] = "88888888"; //Mật khẩu
void sendSensor(){
// get readings from the DHT22 sensor
float hclient = dht.readHumidity();
float tclient = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
if (isnan(hclient) || isnan(tclient)) {
Serial.println("Failed to read from DHT sensor!");
return;
Blynk.virtualWrite(V2, tclient);
bridge1.virtualWrite(V11, tclient);
}
}
void setup()
{
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
dht.begin();
timer.setInterval(1000L, sendSensor);
}
void loop()
{
Blynk.run();
timer.run();
}