BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Virtualwrite is misbehaving


#1

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();

}

#2

and this is Atmega mcu 2560 code

#include <EasyTransfer.h>
#include <Timer.h>
#include <dht11.h>
#include <DHT.h>

#define DHTPIN A0
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);


Timer t;
EasyTransfer ETout, ETin,ETin1,ETin2,ETin3;

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
  //bool limit;
  float temp;
  float hum;
  //will be limit switch

};


struct RECEIVE_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 RECEIVE_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 RECEIVE_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  m1;
  int8_t  m2;
  
  
};
struct RECEIVE_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;
  
};


//give a name to the group of data
SEND_DATA_STRUCTURE mega;
RECEIVE_DATA_STRUCTURE node;
RECEIVE_DATA_STRUCTURE_OF_MOTOR1 nodemotor1;
RECEIVE_DATA_STRUCTURE_OF_MOTOR2 nodemotor2;
RECEIVE_DATA_STRUCTURE_OF_MOTOR3 nodemotor3;


//////////////////ALL output devices /////////////

//////////////////////////stack 1 /////////////////////////
int light1 = 22;
int M1U = 23;
int M1D = 24;
int ls1 = 25;

//////////////////////////stack 2 /////////////////////////
int light2 = 26;
int M2U = 27;
int M2D = 28;
int ls2 = 29;

//////////////////////////stack 3 /////////////////////////
int light3 = 30;
int M3U = 31;
int M3D = 32;
int ls3 = 33;

//////////////////////////common /////////////////////////
int fan = 34;
int oxygen = 35;
int pump = 36;


void setup() {
  Serial.begin(9600);
  Serial1.begin(19200);        /// Important
  //start the library, pass in the data details and the name of the serial port. Can be Serial, Serial1, Serial2, etc.
  ETout.begin(details(mega), &Serial1);
  ETin.begin(details(node), &Serial1);
  ETin1.begin(details(nodemotor1), &Serial1);
  ETin2.begin(details(nodemotor2), &Serial1);
  ETin3.begin(details(nodemotor3), &Serial1);
  


  /////////////////////////////INPUTS AND OUTPUTS ///////////////////////////////
  pinMode(A0, INPUT);             ///////////////DHT SENSOR /////////////////
  pinMode(light1, OUTPUT);
  pinMode(light2, OUTPUT);
  pinMode(light3, OUTPUT);
  pinMode(M1U, OUTPUT);
  pinMode(M2U, OUTPUT);
  pinMode(M3U, OUTPUT);
  pinMode(M1D, OUTPUT);
  pinMode(M2D, OUTPUT);
  pinMode(M3D, OUTPUT);
  pinMode(ls1, INPUT);
  pinMode(ls2, INPUT);
  pinMode(ls3, INPUT);

  dht.begin();
  t.every(60L * 1000L, temphum, NULL);
}

void loop() {
  //this is how you access the variables. [name of the group].[variable name]
  //mega.limit = digitalRead(52);
  shelve1();
  shelve2();
  shelve3();
  
  motor2();
   common();
  t.update();
}

void motor2() {
  if (ETin2.receiveData() ) {
    switch(nodemotor2.m2){
      case -4:
      digitalWrite(M2D,HIGH);
      delay(5000);
      digitalWrite(M2D,LOW);
      break;
      case 4:
      digitalWrite(M2U,HIGH);
      delay(5000);
      digitalWrite(M2U,LOW);
      break;
    }
  }
}


void shelve1() {
 if (ETin.receiveData()){

   
    Serial.println(node.l1);
    switch (node.l1){
      case 0:
      digitalWrite(light1,LOW);
      break;
      case 1:
      digitalWrite(light1,HIGH);
      break;
    }
  }
}



#3

hey @Gunner can you help me with this problem.


#4

why don’t you use bridge widget instead of easy transfer?


#5

i’m using Easytransfer because i have serially connected both . I only have one nodemcu which can connect the internet but the atmega2560 doesn’t have any internet connection so connected both serially.

tx >> rx Serial 1 of atmega
rx >> tx Serial 1 of atmega

i’m facing too much delay in this system also I can not understand the Step H widget property directly as i mention in my code. Is it right or wrong??
Thanks @Alexis_Cabrera for reply


#6

I can’t help you , I use 2 nodemcu and bridge widget to control each other :thinking:


#7

ya Thanks , some one will
As of now i have to work with this after that i will purchase the multiple node mcu.


#8

I suggest you buy the new nodemcu with ESP32 Wroom, only 5$
dual core and 32 I/O :smiling_face_with_three_hearts:


#9

Hello Community I need help

How can i change my button property if it is in device tiles??

I have two tabs one is Auto and manual

so when is press on button in auto it has to change the property of 3 buttons (Which is located in device tiles also have virtual pins assign them,)

please any support me.


#10

:thinking:
maybe you can use styled button ?
please post a picture of your UI


#11

hey @Alexis_Cabrera Thanks for your reply,

Actually it is working now. let’s see if add 2 more device to it how it works.