hello i have nodemcu and atmega 2560 and blynk app, When i press the button on blynk to turn on/off light it will send the command to atmega via Easy transfer but the there is some sort of delay .
also i have Step H widget which i have set to send step.
also when i press step H widget no 1 it has to turn acoording to its light (output) but what i found is it is misbehaving i can not understand How step widget should i use.
i have three button and three step H widget all are virtually connected.
here is my nodemcu code.
#define BLYNK_MAX_SENDBYTES 256
#define BLYNK_MSG_LIMIT 50
#include <EasyTransfer.h>
#include <BlynkSimpleEsp8266.h> // For Blynk
#include <ESP8266WiFi.h> // For Blynk & OTA
//create object
EasyTransfer ETin, ETout,ETout1,ETout2,ETout3;
struct SEND_DATA_STRUCTURE {
//put your variable definitions here for the data you want to send
//THIS MUST BE EXACTLY THE SAME ON THE OTHER ARDUINO
int8_t l1;
int8_t l2;
int8_t l3;
int8_t f1;
int8_t o1;
int8_t p1;
};
struct SEND_DATA_STRUCTURE_OF_MOTOR1 {
//put your variable definitions here for the data you want to send
//THIS MUST BE EXACTLY THE SAME ON THE OTHER ARDUINO
int8_t m1;
};
struct SEND_DATA_STRUCTURE_OF_MOTOR2 {
//put your variable definitions here for the data you want to send
//THIS MUST BE EXACTLY THE SAME ON THE OTHER ARDUINO
int8_t m2;
};
struct SEND_DATA_STRUCTURE_OF_MOTOR3 {
//put your variable definitions here for the data you want to send
//THIS MUST BE EXACTLY THE SAME ON THE OTHER ARDUINO
int8_t m3;
};
struct RECEIVE_DATA_STRUCTURE {
//put your variable definitions here for the data you want to receive
//THIS MUST BE EXACTLY THE SAME ON THE OTHER ARDUINO
//bool limit;
float temp;
float hum;
//will be limit switch
};
//give a name to the group of data
RECEIVE_DATA_STRUCTURE mega;
SEND_DATA_STRUCTURE node;
SEND_DATA_STRUCTURE_OF_MOTOR1 nodemotor1;
SEND_DATA_STRUCTURE_OF_MOTOR2 nodemotor2;
SEND_DATA_STRUCTURE_OF_MOTOR3 nodemotor3;
char auth[] = "4";
char ssid[] = "tel";
char pass[] = "3";
BlynkTimer timer;
#define BLYNK_GREEN "#76fd0e"
#define BLYNK_BLUE "#79d8f0"
#define BLYNK_YELLOW1 "#ffc04c"
#define BLYNK_YELLOW2 "#ffae19"
#define BLYNK_RED "#f96161"
#define BLYNK_BLUE1 "#b0e2ff"
#define BLYNK_BLUE2 "#7ec0ee"
#define BLYNK_BLUE3 "#1e90ff"
//////////////////////////////////SETUP/////////////////////////////
void setup() {
Serial.begin(9600);
//start the library, pass in the data details and the name of the serial port. Can be Serial, Serial1, Serial2, etc.
ETin.begin(details(mega), &Serial);
ETout.begin(details(node), &Serial);
ETout1.begin(details(nodemotor1), &Serial);
ETout2.begin(details(nodemotor2), &Serial);
ETout3.begin(details(nodemotor3), &Serial);
Blynk.begin(auth, ssid, pass);
timer.setInterval(60L * 1000L, sensordata);
}
///////////////////////////////////BLYNK CONNECTED ///////////////////
BLYNK_CONNECTED() {
Blynk.syncAll();
Blynk.syncVirtual(V1, V2);
//Blynk.syncVirtual(V11,V12,V13,V14,V15,V16,V17,V18,V19,V22);
Blynk.virtualWrite(V3, 3);
Blynk.virtualWrite(V4, 24);
}
/*BLYNK_WRITE(V5){
if (mydata.limit ==1){
Blynk.setProperty(V5,"labels","No1","No2","No3");
}
if (mydata.limit ==0){
Blynk.setProperty(V5,"labels","YNo1","YNo2","YNo3");
}
}*/
BLYNK_WRITE(V11) { //////////light 1 command//////
node.l1 = param.asInt();
Serial.print("l1");
Serial.println(node.l1);
ETout.sendData();
}
BLYNK_WRITE(V13) { //////////light 2 command//////
node.l2 = param.asInt();
Serial.print("l2");
Serial.println(node.l2);
ETout.sendData();
}
BLYNK_WRITE(V15) { //////////light 3 command//////
node.l3 = param.asInt();
Serial.print("l3");
Serial.println(node.l3);
ETout.sendData();
}
BLYNK_WRITE(V22) { //////////motor 1 command//////
/* nodemotor.m1 = param.asInt();
Serial.print(nodemotor.m1);
switch (nodemotor.m1) {
case -3:
ETout1.sendData();
break;
case 3:
ETout1.sendData();
break;
}*/
}
BLYNK_WRITE(V26) { //////////motor 2 command//////
nodemotor2.m2 = param.asInt();
Serial.println(nodemotor2.m2);
switch (nodemotor2.m2) {
case -4:
ETout2.sendData();
break;
case 4:
ETout2.sendData();
break;
}
}
BLYNK_WRITE(V30) { //////////motor 3 command//////
/*nodemotor3.m3 = param.asInt();
Serial.println(nodemotor3.m3);
switch (nodemotor3.m3) {
case -5:
ETout1.sendData();
break;
case 5:
ETout1.sendData();
break;
}*/
}
BLYNK_WRITE(V17) { //////////fan command//////
node.f1 = param.asInt();
Serial.print("f1");
Serial.println(node.f1);
ETout.sendData();
}
BLYNK_WRITE(V18) { //////////oxygen command//////
node.o1 = param.asInt();
Serial.print("o1");
Serial.println(node.o1);
ETout.sendData();
}
BLYNK_WRITE(V19) { //////////oxygen command//////
node.p1 = param.asInt();
Serial.print("p1");
Serial.println(node.p1);
ETout.sendData();
}
void loop() {
//check and see if a data packet has come in.
Blynk.run();
timer.run();
ETin.receiveData();
}