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.
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();
}
#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();
}
You are missing the all essential Blynk.run(); in your NodeMCU sketch
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
}
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.
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).
#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();
}
#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();
}
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.
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.
#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();
}
#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();
}