2mmert
Üye
- Katılım
- 24 Nis 2021
- Mesajlar
- 24
- Puanları
- 1
- Yaş
- 52
Arkadaslar lutfen yardim edin..
Butun sensorler ve roleler unoya bagli..
45 gundur uno yu- nodemcu 8266 ile internete baglamaya calisiyorum ..sonunda baglandim..
Bu seferde bylinkde verileri goruyorum. ama buton fonksiyonlari ile 4 relay role yi kontrol edemiyorum..
Kodlara bir bakarmisiniz..
bir de ilginc sorunlarim var.. nodemcu uzerinde internete baglaninca yanan led yanmiyor(yazilimla mi yaniyor bilemedim)
arduino uno yu enerjiye bagladigim an 4 role de aciliyor ve yazilim tamamen okununca ,yazilima gore roleler gorevlerini yapiyor..enerji takildigi an acilmamasini nasil saglayabilirim..
[
//ARDUINO 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);
int temp;
int hum;
// MQ135 AYARLARI
#define sensor A1
int gas, co2lvl;
void setup() {
Serial.begin(9600);
pinMode(sensor, INPUT); //MQ135
dht.begin();
nodemcu.begin(115200);
pinMode(12,OUTPUT);
delay(1000);
Serial.println("Program started");
}
void loop() {
StaticJsonBuffer<1000> jsonBuffer;
JsonObject& data = jsonBuffer.createObject();
//Obtain Temp and Hum data
dht11_func();
mq135_func();
buton_func();
//Assign collected data to JSON Object
data["humidity"] = hum;
data["temperature"] = temp;
data["co2"] = co2lvl;
//Send data to NodeMCU
data.printTo(nodemcu);
jsonBuffer.clear();
delay(1000);
}
void dht11_func() {
hum = dht.readHumidity();
temp = dht.readTemperature();
Serial.print("Humidity: ");
Serial.println(hum);
Serial.print("Temperature: ");
Serial.println(temp);
}
void mq135_func() {
gas = analogRead(sensor);
co2lvl = gas-120;
co2lvl = map(co2lvl,0,1024,400,5000);
Serial.println(gas);
}
void buton_func() {
while (nodemcu.available() > 0 ) {
int val = nodemcu.parseInt();
if (nodemcu.read() == "\n") {
Serial.println(val);
if (val == HIGH) {
digitalWrite(12, HIGH);
}
else {
digitalWrite(12, LOW);
}
}
}
}
]
[
//NODEMCU YUKLE
#include <Blynk.h>
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
BlynkTimer timer;
char auth[] = "1HJh3g8b4ra9rFkhLjDz_ABL5CukkH4";
char ssid[] = "Kablonet Netmaster-C5B5-G_EXT";
char pass[] = "1971mm74";
#include <SoftwareSerial.h>
#include <ArduinoJson.h>
int a;
//D8 = RX & D7 = TX
SoftwareSerial nodemcu(D8, D7);
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(V6,hum);
Serial.print("Recieved Temperature: ");
float temp = data["temperature"];
Serial.println(temp);
Blynk.virtualWrite(V5,temp);
Serial.print("Recieved co2: ");
float co2lvl = data["co2"];
Serial.println(co2lvl);
Blynk.virtualWrite(V7,co2lvl);
Serial.println("-----------------------------------------");
}
BLYNK_WRITE(V2)
{
a = param.asInt();
nodemcu.print(a);
nodemcu.println("\n");
Serial.println(a);
}
// ================= SETUP =============================
// ======================================================
void setup() {
// Initialize Serial port
Serial.begin(9600);
nodemcu.begin(115200);
while (!Serial) continue;
Blynk.begin(auth, ssid, pass,"blynk-cloud.com", 8080);
timer.setInterval(100L, send_data);
pinMode(D8, INPUT);
pinMode(D7, OUTPUT);
}
void loop() {
Blynk.run();
timer.run();
}
Butun sensorler ve roleler unoya bagli..
45 gundur uno yu- nodemcu 8266 ile internete baglamaya calisiyorum ..sonunda baglandim..
Bu seferde bylinkde verileri goruyorum. ama buton fonksiyonlari ile 4 relay role yi kontrol edemiyorum..
Kodlara bir bakarmisiniz..
bir de ilginc sorunlarim var.. nodemcu uzerinde internete baglaninca yanan led yanmiyor(yazilimla mi yaniyor bilemedim)
arduino uno yu enerjiye bagladigim an 4 role de aciliyor ve yazilim tamamen okununca ,yazilima gore roleler gorevlerini yapiyor..enerji takildigi an acilmamasini nasil saglayabilirim..
[
//ARDUINO 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);
int temp;
int hum;
// MQ135 AYARLARI
#define sensor A1
int gas, co2lvl;
void setup() {
Serial.begin(9600);
pinMode(sensor, INPUT); //MQ135
dht.begin();
nodemcu.begin(115200);
pinMode(12,OUTPUT);
delay(1000);
Serial.println("Program started");
}
void loop() {
StaticJsonBuffer<1000> jsonBuffer;
JsonObject& data = jsonBuffer.createObject();
//Obtain Temp and Hum data
dht11_func();
mq135_func();
buton_func();
//Assign collected data to JSON Object
data["humidity"] = hum;
data["temperature"] = temp;
data["co2"] = co2lvl;
//Send data to NodeMCU
data.printTo(nodemcu);
jsonBuffer.clear();
delay(1000);
}
void dht11_func() {
hum = dht.readHumidity();
temp = dht.readTemperature();
Serial.print("Humidity: ");
Serial.println(hum);
Serial.print("Temperature: ");
Serial.println(temp);
}
void mq135_func() {
gas = analogRead(sensor);
co2lvl = gas-120;
co2lvl = map(co2lvl,0,1024,400,5000);
Serial.println(gas);
}
void buton_func() {
while (nodemcu.available() > 0 ) {
int val = nodemcu.parseInt();
if (nodemcu.read() == "\n") {
Serial.println(val);
if (val == HIGH) {
digitalWrite(12, HIGH);
}
else {
digitalWrite(12, LOW);
}
}
}
}
]
[
//NODEMCU YUKLE
#include <Blynk.h>
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
BlynkTimer timer;
char auth[] = "1HJh3g8b4ra9rFkhLjDz_ABL5CukkH4";
char ssid[] = "Kablonet Netmaster-C5B5-G_EXT";
char pass[] = "1971mm74";
#include <SoftwareSerial.h>
#include <ArduinoJson.h>
int a;
//D8 = RX & D7 = TX
SoftwareSerial nodemcu(D8, D7);
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(V6,hum);
Serial.print("Recieved Temperature: ");
float temp = data["temperature"];
Serial.println(temp);
Blynk.virtualWrite(V5,temp);
Serial.print("Recieved co2: ");
float co2lvl = data["co2"];
Serial.println(co2lvl);
Blynk.virtualWrite(V7,co2lvl);
Serial.println("-----------------------------------------");
}
BLYNK_WRITE(V2)
{
a = param.asInt();
nodemcu.print(a);
nodemcu.println("\n");
Serial.println(a);
}
// ================= SETUP =============================
// ======================================================
void setup() {
// Initialize Serial port
Serial.begin(9600);
nodemcu.begin(115200);
while (!Serial) continue;
Blynk.begin(auth, ssid, pass,"blynk-cloud.com", 8080);
timer.setInterval(100L, send_data);
pinMode(D8, INPUT);
pinMode(D7, OUTPUT);
}
void loop() {
Blynk.run();
timer.run();
}