/////////////////////////////////////
//ARDUINO ya YUKLE
//DHT11 Lib
#include <DHT.h>
//Arduino to NodeMCU Lib
#include <SoftwareSerial.h>
#include <ArduinoJson.h>
//Initialise Arduino to NodeMCU (10=Rx & 11=Tx)
SoftwareSerial nodemcu(10, 11);
//Initialisation of DHT11 Sensor
#define DHTPIN 2
DHT dht(DHTPIN, DHT11);
float temp;
float hum;
void setup() {
Serial.begin(9600);
dht.begin();
nodemcu.begin(9600);
delay(1000);
Serial.println("Program started");
}
void loop() {
StaticJsonBuffer<1000> jsonBuffer;
JsonObject& data = jsonBuffer.createObject();
//Obtain Temp and Hum data
dht11_func();
//Assign collected data to JSON Object
data["humidity"] = hum;
data["temperature"] = temp;
//Send data to NodeMCU
data.printTo(nodemcu);
jsonBuffer.clear();
delay(2000);
}
void dht11_func() {
hum = dht.readHumidity();
temp = dht.readTemperature();
Serial.print("Humidity: ");
Serial.println(hum);
Serial.print("Temperature: ");
Serial.println(temp);
}
///////////////////////////////////////////////
74";
//NODEMCU ya YUKLE
#include <SoftwareSerial.h>
#include <ArduinoJson.h>
//D6 = Rx & D5 = Tx
SoftwareSerial nodemcu(D6, D5);
#include BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
BlynkTimer timer;
char auth[] = "AnGJ8Yh4LiQbGmZkibFPa";
char ssid[] = "Kablonet Netmaster-C5-G_EXT";
char pass[] = "191fds
void send_data() {
StaticJsonBuffer<200> jsonBuffer;
JsonObject& data = jsonBuffer.parseObject(nodemcu);
if (data == JsonObject::invalid()) {
//Serial.println("Invalid Json Object");
jsonBuffer.clear();
return;
}
Serial.println("JSON Object Recieved");
Serial.print("Recieved Humidity: ");
float hum = data["humidity"];
Serial.println(hum);
Blynk.virtualWrite(V0,hum);
Serial.print("Recieved Temperature: ");
float temp = data["temperature"];
Serial.println(temp);
Blynk.virtualWrite(V1,temp);
Serial.println("-----------------------------------------");
}
// ================= SETUP =============================
// ======================================================
void setup() {
// Initialize Serial port
Serial.begin(9600);
nodemcu.begin(9600);
while (!Serial) continue;
Blynk.begin(auth, ssid, pass,"blynk-cloud.com", 8080);
timer.setInterval(100L, send_data);
}
void loop() {
Blynk.run();
timer.run();
}
//////////////////////////
dht11+uno==> nudemcu ==>Blynk
Arkadaslar bu hatayi niye aliyorum acaba.. duzeltme yolu varmidir
Simdiden tesekkurler....
Blynk ile hicbir komut girmeden once seri iletisimde hicbir sikinti yok...ama blynk isin icine girince bir turlu asamiyorum...