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

How to add lables when my mega2560 digitalread is HIGH

hardware

#41

I have already connected the nodemcu to arduino with Tx and Rx pin (mega with nodemcu)

but the thing is for now i only want to use arduino as end controller

and nodemcu as internet or wifi transmitter and receiver

please guide me if have done this before, with any library (easy transfer or serially, bridge or etc…)


#42

That’s not the same thing that I was suggesting. You said earlier that you just want to know when one of your pins goes HIGH on the NodeMCU. What I suggested is a simple solution for that, and needs no library and minimal code to monitor the state of the input pin.

If your requirements have changed and you want to use the NodeMCU as a Wi-Fi modem for your Arduino then you need to flash the NodeMCU with AT firmware and treat the setup like an Arduino/ESP-01 setup.

To be honest, given your apparent lack of coding expertise, it sounds to me that your plans to control dozens of devices with your Arduino sounds very ambitious.
Personally, I’d do it differently and have a more modular system with multiple NodeMCUs controlling portions of system, and forget the Arduino altogether.

Pete.


#43

hey @Gunner this is my ET transfer code but it is not working

for arduino side

 #include <EasyTransfer.h>

//create object
EasyTransfer ET; 

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;
  //int16_t pause;
};

//give a name to the group of data
SEND_DATA_STRUCTURE mydata;

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.
  ET.begin(details(mydata), &Serial1);
  
  pinMode(52, INPUT);
  
}

void loop(){
  //this is how you access the variables. [name of the group].[variable name]
  mydata.limit = digitalRead(52);
  Serial.print(mydata.limit);
  //send the data
  ET.sendData();
  
}

#44

for nodemcu

#include <EasyTransfer.h>
#include <BlynkSimpleEsp8266.h>  // For Blynk
#include <ESP8266WiFi.h>  // For Blynk & OTA
//create object
EasyTransfer ET; 

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;
  //int16_t pause;
};

//give a name to the group of data
RECEIVE_DATA_STRUCTURE mydata;
char auth[] = "91bfeecc74";
char ssid[] = "qch Airtel";
char pass[] = "te";

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. 
  ET.begin(details(mydata), &Serial1);
  pinMode(52,INPUT);
  Blynk.begin(auth, ssid, pass);
 
}

BLYNK_WRITE(V5){
  bool i = mydata.limit;
  if (i ==1){
    Blynk.setProperty(V5,"labels","No1","No2","No3");
  }
  if (i ==0){
    Blynk.setProperty(V5,"labels","YNo1","YNo2","YNo3");
  }
}
void loop(){
  //check and see if a data packet has come in. 
  ET.receiveData();
}

#45

@PeteKnight what about this?
@Dmitriy


#46

I don’t understand your question, try elaborating a little.

Pete.


#47

@PeteKnight this is all my code of ET tranfer. but it is not working can you give my any idea how to solve this?
Pranav


#48

You are missing the all essential Blynk.run(); in your NodeMCU sketch :stuck_out_tongue_winking_eye:

And whatever is this function is supposed to trigger on??? As is, it will just trigger any time the widget on V5 changes state (e.g. twice on a button press/release), thus potentially giving both possible readings one after another since the bool variable input is being fed at the speed of the void loop()

And again… why bother with the bool?? If all you want is a 0 or 1 then the standard digitalRead() will feed an int variable just fine…

if (mydata.limit == 1){
// do something
} else {
// do something else
}

#49

I currently have no idea what it is you’re trying to achieve with this project, as your descriptions of your requirements are conflicting with each other and you’ve ignored my request for clarification.
If, as you’ve said earlier, and the title of the thread I,plies, you just want to know when a pin on your Arduino goes high, then you don’t need the Easy Transfer library at all, you just need to poll the pin with a digitalRead on a regular basis to see if it’s HIGH or not - as I explained earlier.

I can’t help further you until you help yourself by clarifying your requirements in more detail, rather than the one line vague responses that you’ve been giving so far.

Pete.


#50

hey it works @gunner but the problem is that it countinuosly send 0 to nodemcu and when i give signal high it can not change to 1 so what can i do??

and also i want to know i send my tempreture and humidity to nodemcu

on Atmega

mydata.temp = DHT.temperature;  ///it is Easy transfer
  mydata.hum =  DHT.humidity;

on nodemcu

BLYNK_WRITE(V0){
  Blynk.virtualWrite(V0,mydata.temp);
}
BLYNK_WRITE(V1){
  Blynk.virtualWrite(V1,mydata.hum);
}

but in my app it does not showing me anything.


#51

Easy Transfer is NOT a Blynk process, and I am not going to sit down and make a tutorial… however here is a few pointers… the rest is up to you to experiment with.

Instead of feeding the data “live” you should be applying some logic code that checks the “live” data from the button or whatever, so that it only sends the data via ET when/if it changes state from last time checked

With ET you have to setup the shared variable in the structure first… did you do that?

I would also avoid directly sending the “live” data as it may not translate properly… remember, the sensor is probably putting out a float while ET is using some form of serial conversion. Perhaps transfer the sensor input to a variable, process it for change checks as needed, then use that variable for the ET transfer.

And again, only send the data if it has changed, or only send it on a timed schedule (probably timed is best for Temp and Humidity anyhow).


#52

hi @Gunner Thank you for your reply !

For DHT and Humidity code

CODE ON TX



#include <EasyTransfer.h>
#include <Timer.h>
//create object
#include <dht11.h>
#include <DHT.h>

#define DHTPIN A0
#define DHTTYPE DHT11
Timer t;

EasyTransfer ET; 
DHT dht(DHTPIN,DHTTYPE);
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;
};

//give a name to the group of data
SEND_DATA_STRUCTURE mydata;

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.
  ET.begin(details(mydata), &Serial1);
  
  //pinMode(52, INPUT);
  pinMode(A0,INPUT);
  dht.begin();
  
}

void loop(){
  //this is how you access the variables. [name of the group].[variable name]
  //mydata.limit = digitalRead(52);
 temp();
 delay(2000);
}

void temp() {
  float h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit (isFahrenheit = true)
  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t) ) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  mydata.hum = h;
  mydata.temp = t;
  Serial.print("humidity");
  Serial.print(mydata.hum);
  Serial.print("temp");
  Serial.println(mydata.temp);
  ET.sendData();

}



#53

Code on reciever side

#include <EasyTransfer.h>
#include <BlynkSimpleEsp8266.h>  // For Blynk
#include <ESP8266WiFi.h>  // For Blynk & OTA
//create object
EasyTransfer ET;

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;
};

//give a name to the group of data
RECEIVE_DATA_STRUCTURE mydata;
char auth[] = "d5f9";
char ssid[] = "E5el";
char pass[] = "t53";

BlynkTimer timer;

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.
  ET.begin(details(mydata), &Serial);
  //pinMode(52,INPUT);

  Blynk.begin(auth, ssid, pass);
  BlynkTimer timer;
  timer.setInterval(1000L, sensordata);
}

/*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");
  }
  }*/

void sensordata(){
  float h = mydata.hum;
  float t = mydata.temp;

  Blynk.virtualWrite(V0,h);
  Blynk.virtualWrite(V1,t);
}
void loop() {
  //check and see if a data packet has come in.
  Blynk.run();
  timer.run();
  ET.receiveData();
}

#54

@Gunner Currently ET SEND Data is working good it is sending the temperature and Humidity value but on receiver side i can not find any value.

is any changes needed?


#55

in this code Blynk app can not showing me anything why it is happening. in serial monitor the ETsend data shows the mydata.temp and mydata.hum values but

why it is not showing in receiver side ? also the the Guages in Blynk app is not showing any value.

How can i fix this? @Gunner


#56

hey thanks @Gunner.
I have completed the serial communication between the Nodemcu and atmega 2560. With ET transfer.

when DHT is send it value to atmega it will serially transfer the value to nodemcu and after that the nodemcu sends to Widget
but the temperature value is shows on GUAGE WIDGET Not HUMIDITY

also i open the serial monitor both value are showing in that but not in Blynk app’s widget.


#57

NODE mcu code

#include <EasyTransfer.h>
#include <BlynkSimpleEsp8266.h>  // For Blynk
#include <ESP8266WiFi.h>  // For Blynk & OTA
//create object
EasyTransfer ET;

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;
};

//give a name to the group of data
RECEIVE_DATA_STRUCTURE mydata;
char auth[] = "sss";
char ssid[] = "sss";
char pass[] = "ss";

BlynkTimer timer;

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.
  ET.begin(details(mydata), &Serial);
  //pinMode(52,INPUT);
  
  Blynk.begin(auth, ssid, pass);
  
  timer.setInterval(5000L, sensordata);

}

/*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");
  }
  }*/
void sensordata(){
   float t = mydata.temp;
   float h = mydata.hum;
    Serial.println(t);
Serial.println(h);
    Blynk.virtualWrite(V1,t);
    Blynk.virtualWrite(V2,h);
}


void loop() {
  //check and see if a data packet has come in.
  Blynk.run();
  timer.run();
  ET.receiveData();
  
}

#58

i’m not getting correct value on App’s Gauge widget but in serial monitor i’m getting both values.

Serial.print(h);
Serial.print(t);

if you have found this problem ? can you guide me ?
because i have give 5 second Delay and also the

Blynk.virtualWrite(V1,t);  ///it is showing correct value
Blynk.virtualWrite(V2,h);   //  not showning correct value

#59

Hello,

I have nodemcu and atmega 2560. both are serially communicate.

when DHT is send it value to atmega it will serially transfer the value to nodemcu and after that the nodemcu sends to Widget

but the temperature value is shows on GUAGE WIDGET Not HUMIDITY

also i open the serial monitor both value are showing in that but not in Blynk app’s widget.


#60

nodemcu code

#include <EasyTransfer.h>
#include <BlynkSimpleEsp8266.h>  // For Blynk
#include <ESP8266WiFi.h>  // For Blynk & OTA
//create object
EasyTransfer ET;

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;
};

//give a name to the group of data
RECEIVE_DATA_STRUCTURE mydata;
char auth[] = "sss";
char ssid[] = "sss";
char pass[] = "ss";

BlynkTimer timer;

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.
  ET.begin(details(mydata), &Serial);
  //pinMode(52,INPUT);
  
  Blynk.begin(auth, ssid, pass);
  
  timer.setInterval(5000L, sensordata);

}

/*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");
  }
  }*/
void sensordata(){
   float t = mydata.temp;
   float h = mydata.hum;
    Serial.println(t);
Serial.println(h);
    Blynk.virtualWrite(V1,t);
    Blynk.virtualWrite(V2,h);
}


void loop() {
  //check and see if a data packet has come in.
  Blynk.run();
  timer.run();
  ET.receiveData();
  
}