Esp master,arduino nano slave

Уважаемый Пит,все-таки вы рановато прикрыли тему,сегодня решил попробовать подключить по той же аналогии поплавковый датчик к WidgetLED,но esp никак не хочет реагировать на действия датчика .Возможно,что GunnerTechTools немного света прольет на мои ошибки,хотя я как только не пытался его заставить работать,но безуспешно.
Код на мастере:

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <EasyTransfer.h>
#include <WidgetRTC.h>
//#include <Servo.h>
//Servo myservo;



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

//give a name to the group of data
SEND_DATA_STRUCTURE ETdata;
char auth[] = "";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "HUAWEI";
char pass[] = "";
char server[] = "blynk-cloud.com";
int port = 8080;
BlynkTimer timer;

WidgetRTC rtc;
WidgetLED led4(V4);

// Digital clock display of the time
void clockDisplay()
{
  // You can call hour(), minute(), ... at any time
  // Please see Time library examples for details

  String currentTime = String(hour()) + ":" + minute() + ":" + second();
  String currentDate = String(day()) + " " + month() + " " + year();
  Serial.print("Current time: ");
  Serial.print(currentTime);
  Serial.print(" ");
  Serial.print(currentDate);
  Serial.println();

  // Send time to the App
  Blynk.virtualWrite(V1, currentTime);
  // Send date to the App
  Blynk.virtualWrite(V2, currentDate);
}

BLYNK_CONNECTED() {
  // Synchronize time on connection
  rtc.begin();
}

void setup() {
  Serial.begin(9600);
  ET.begin(details(ETdata), &Serial);
  Blynk.config(auth, server, port);
  Blynk.connect();
  setSyncInterval(10 * 60); // Sync interval in seconds (10 minutes)

  // Display digital clock every 10 seconds
  timer.setInterval(10000L, clockDisplay);
  
}
BLYNK_WRITE(V3) {
  ETdata.LED13 = param.asInt();
  if (param.asInt() == 1) {
    digitalWrite(13, HIGH);
  } else {
    digitalWrite(13, LOW);
  }
  ET.sendData();
}
BLYNK_WRITE(V4) {
  ETdata.LED1 = param.asInt();
  if (param.asInt() == 1) 
  {
    led4.on();
    
  } else {
    led4.off();
  }
  ET.sendData();
}




void loop() {
  Blynk.run();
  timer.run();
}

Код на слуге:


//#include <SimpleTimer.h>
#include <EasyTransfer.h>
//#include <Servo.h>
//Servo myservo;  // create servo object to control a servo
EasyTransfer ET;
//SimpleTimer timer;
//int pos = 0;
const int16_t pinSensor1 = 7;



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
  int16_t LED13;
  int16_t LED1;
};

//give a name to the group of data
RECEIVE_DATA_STRUCTURE ETdata;
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(ETdata), &Serial);

  pinMode(13, OUTPUT);
  pinMode(pinSensor1, INPUT_PULLUP);
}



void loop() {
  if (ET.receiveData())
  {

    if (ETdata.LED13 == 1) {
      digitalWrite(13, HIGH);
    } else {
      digitalWrite(13, LOW);
    }
    ETdata.LED1 = !digitalRead(pinSensor1);
    if (ETdata.LED1 == 1)
      if (!digitalRead(pinSensor1)) {
        Serial.println("СЕНСОР ТОНЕТ");
      }
  }
}

Всякие различные варианты перепробовал,как только не пробовал переменными крутить,но почему то датчик вообще не реагирует.Отдельно,когда подключаю,то он работает,а вот встроить его в конструкцию свою у меня не получается,какую то мелочь упускаю?Прошу помощи:Невинные:

Всех еще раз приветствую!Не дает мне покоя эта проблема,не прошу мне код написать,просто укажите на ошибки,какие я совершаю.Сегодня попробовал немного изменить,как мне казалось на правильное решение,но WidgetLED все равно не переключается.GunnerTechTools,если не сложно,то можешь указать на ошибки,которые я совершаю?

На мастере код:

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <EasyTransfer.h>
#include <WidgetRTC.h>
//#include <Servo.h>
//Servo myservo;a
const uint8_t pinSensor1 = V4;

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

//give a name to the group of data
SEND_DATA_STRUCTURE ETdata;
char auth[] = "";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "HUAWEI";
char pass[] = "";
char server[] = "blynk-cloud.com";
int port = 8080;
BlynkTimer timer;

WidgetRTC rtc;
WidgetLED led4(V4);

// Digital clock display of the time
void clockDisplay()
{
  // You can call hour(), minute(), ... at any time
  // Please see Time library examples for details

  String currentTime = String(hour()) + ":" + minute() + ":" + second();
  String currentDate = String(day()) + " " + month() + " " + year();
  Serial.print("Current time: ");
  Serial.print(currentTime);
  Serial.print(" ");
  Serial.print(currentDate);
  Serial.println();

  // Send time to the App
  Blynk.virtualWrite(V1, currentTime);
  // Send date to the App
  Blynk.virtualWrite(V2, currentDate);
}

BLYNK_CONNECTED() {
  // Synchronize time on connection
  rtc.begin();
}

void setup() {
  Serial.begin(9600);
  ET.begin(details(ETdata), &Serial);
  Blynk.config(auth, server, port);
  Blynk.connect();
  setSyncInterval(10 * 60); // Sync interval in seconds (10 minutes)

  // Display digital clock every 10 seconds
  timer.setInterval(10000L, clockDisplay);
}

BLYNK_WRITE(V3) {
  ETdata.LED13 = param.asInt();
  if (param.asInt() == 1) {
    digitalWrite(13, HIGH);
  } else {
    digitalWrite(13, LOW);
  }
  ET.sendData();
}

BLYNK_READ(V4) {
  Blynk.virtualWrite(V4, !digitalRead(pinSensor1));

  led4.on();

  led4.off();
  ET.sendData();
}




void loop() {
  Blynk.run();
  timer.run();
}

На слуге такой:

//#include <SimpleTimer.h>
#include <EasyTransfer.h>
//#include <Servo.h>
//Servo myservo;  // create servo object to control a servo
EasyTransfer ET;
//SimpleTimer timer;
//int pos = 0;
const int16_t pinSensor1 = 7;



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
  int16_t LED13;
  int16_t LED1;
};

//give a name to the group of data
RECEIVE_DATA_STRUCTURE ETdata;
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(ETdata), &Serial);

  pinMode(13, OUTPUT);
  pinMode(pinSensor1, INPUT_PULLUP);
}



void loop() {
 ET.receiveData();
  {

    if (ETdata.LED13 == 1) {
      digitalWrite(13, HIGH);
    } else {
      digitalWrite(13, LOW);
    }
    ETdata.LED1 = !digitalRead(pinSensor1);
    
      if (!digitalRead(pinSensor1)) {
        Serial.println("СЕНСОР ТОНЕТ");
      }
  }
}

Sorry, I now spend very little time in this forum.

Your current code appears to be is doing exactly what you are asking of it… turn the LED ON when the assigned button widget is pressed and OFF when it is released (or simply not being used).

If you want the LED (on both devices) to toggle states at each button press, then perhaps somthing like this? (completely UNTESTED… so take with grain of salt :stuck_out_tongue: )

On the master… Set up a variable for LED state

int LEDstate = 0;  // default state is OFF
BLYNK_WRITE(V3) {
   if (param.asInt() == 1) { // When button is pressed toggle local and slave LED states
   ETdata.LED13 = !LEDstate;  // Slave LED value is opposite of last known value
   digitalWrite(13, !LEDstate); // Local LED value is opposite of last known value
  } 
  ET.sendData();
}

On the slave…

void loop() {
 ET.receiveData();
 digitalWrite(13, ETdata.LED13);  // LED state based on Master input

 // whatever other stuff you have/need
}

PS… it has been awhile since I used ET with Blynk so I do not know how this will work, but perhaps move the masters ET.sendData(); command from within any of the Blynk functions into the masters void loop() so it is always running and sending the current values of your ET structures.

GunnerTechTools,мой код почти делает все то,что я хочу.Диод с помощью кнопки включается и выключается,но вот значения с поплавкового датчика не передает.


Как я понимаю,на слуге код выполняется как нужно,на картинке постарался запечатлить,что он передает команды,а serial monitor выводит показания.Значит проблема в мастере?Как только я не пытался крутить переменными,но код не работает и в serial monitor того,что я хочу,не передает.Не подскажите,в чем я ошибки допускаю при передачи мастеру этих показаний?
На мастере такой код:

#include <BlynkSimpleEsp8266.h>
#include <EasyTransfer.h>
#include <WidgetRTC.h>
//#include <Servo.h>
//Servo myservo;a
const uint8_t pinSensor1 = V4;
int LEDstate = 0;




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

//give a name to the group of data
SEND_DATA_STRUCTURE ETdata;
char auth[] = "";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "HUAWEI";
char pass[] = "";
char server[] = "blynk-cloud.com";
int port = 8080;
BlynkTimer timer;

WidgetRTC rtc;
WidgetLED led4(V4);

// Digital clock display of the time
void clockDisplay()
{
  // You can call hour(), minute(), ... at any time
  // Please see Time library examples for details

  String currentTime = String(hour()) + ":" + minute() + ":" + second();
  String currentDate = String(day()) + " " + month() + " " + year();
  Serial.print("Current time: ");
  Serial.print(currentTime);
  Serial.print(" ");
  Serial.print(currentDate);
  Serial.println();

  // Send time to the App
  Blynk.virtualWrite(V1, currentTime);
  // Send date to the App
  Blynk.virtualWrite(V2, currentDate);
}

BLYNK_CONNECTED() {
  // Synchronize time on connection
  rtc.begin();
}

void setup() {
  Serial.begin(9600);
  ET.begin(details(ETdata), &Serial);
  Blynk.config(auth, server, port);
  Blynk.connect();
  setSyncInterval(10 * 60); // Sync interval in seconds (10 minutes)

  // Display digital clock every 10 seconds
  timer.setInterval(10000L, clockDisplay);

}
BLYNK_WRITE(V3) {
  ETdata.LED13 = param.asInt();
  if (param.asInt() == 1) {
    digitalWrite(13, HIGH);
  } else {
    digitalWrite(13, LOW);
  }
  ET.sendData();
  }
/*BLYNK_READ(V4) {
  Blynk.virtualWrite(V4, !digitalRead(pinSensor1));
  Serial.println("GOGOGO");
  Blynk.virtualWrite(V4, ETdata.LED1);
  Blynk.virtualWrite(V4, 255);
  Serial.println("LED1.ON");

  led4.off();
  Serial.println("LED1.off");
  ET.sendData();
  }*/

/*BLYNK_WRITE(V4) {
  ETdata.LED1 = param.asInt();
  if (ETdata.LED1 == pinSensor1){
  led4.on();
  Serial.println("LED1.ON");
  } else {
  
    led4.off();
    Serial.println("LED1.OFF");
  }
}*/

/*BLYNK_WRITE(V4){
if (param.asInt() == 1) {
  ETdata.LED1 = !LEDstate;
  digitalWrite(pinSensor1, !LEDstate);
  led4.on();
} else {
led4.off();
ET.sendData();
}
}/*







void loop() {
  Blynk.run();
  timer.run();
}

На слуге такой:

//#include <SimpleTimer.h>
#include <EasyTransfer.h>
//#include <Servo.h>
//Servo myservo;  // create servo object to control a servo
EasyTransfer ET;
//SimpleTimer timer;
//int pos = 0;
const int16_t pinSensor1 = 7;



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
  int16_t LED13;
  int16_t LED1;
};

//give a name to the group of data
RECEIVE_DATA_STRUCTURE ETdata;
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(ETdata), &Serial);

  pinMode(13, OUTPUT);
  pinMode(pinSensor1, INPUT_PULLUP);
}



void loop() {
 ET.receiveData();
  {

    if (ETdata.LED13 == 1) {
      digitalWrite(13, HIGH);
    } else {
      digitalWrite(13, LOW);
    }
  ET.receiveData();{
  ETdata.LED1 == !digitalRead(pinSensor1);
  
    
      if (!digitalRead(pinSensor1)) {
        Serial.println("СЕНСОР ТОНЕТ");
      }
  }
}
}

Сам мастер команду заставить “поморгать светодиодом” выполняет без проблем,но вот ,не хочет заставить slave’a включить WidgetLED для поплавкового датчика,вы не подскажите,где я все-таки ошибку допускаю?

GunnerTechTools,если читаешь меня,то дай пожалуйста комментарий,где я ошибку допускаю?По всякому уже пытался заставить реагировать WidgetLED на мой поплавковый датчик,но он все никак не отзывается.
На мастере такой код:

#include <BlynkSimpleEsp8266.h>
#include <EasyTransfer.h>
#include <WidgetRTC.h>
//#include <Servo.h>
//Servo myservo;a
const uint8_t pinSensor1 = V4;
int LEDstate = 0;




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

//give a name to the group of data
SEND_DATA_STRUCTURE ETdata;
char auth[] = "";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "HUAWEI";
char pass[] = "";
char server[] = "blynk-cloud.com";
int port = 8080;
BlynkTimer timer;

WidgetRTC rtc;
WidgetLED led4(V4);
/*void blinkLedWidget()
  {
  if (led4.!(pinSensor1))
  led4.on();
  }*/

// Digital clock display of the time
void clockDisplay()
{
  // You can call hour(), minute(), ... at any time
  // Please see Time library examples for details

  String currentTime = String(hour()) + ":" + minute() + ":" + second();
  String currentDate = String(day()) + " " + month() + " " + year();
  Serial.print("Current time: ");
  Serial.print(currentTime);
  Serial.print(" ");
  Serial.print(currentDate);
  Serial.println();

  // Send time to the App
  Blynk.virtualWrite(V1, currentTime);
  // Send date to the App
  Blynk.virtualWrite(V2, currentDate);
}

BLYNK_CONNECTED() {
  // Synchronize time on connection
  rtc.begin();
}

void setup() {
  Serial.begin(9600);
  ET.begin(details(ETdata), &Serial);
  Blynk.config(auth, server, port);
  Blynk.connect();
  setSyncInterval(10 * 60); // Sync interval in seconds (10 minutes)

  // Display digital clock every 10 seconds

    timer.setInterval(10000L, clockDisplay);
  timer.setInterval (1000L, ledOnOff);

}
BLYNK_WRITE(V3) {
  ETdata.LED13 = param.asInt();
  if (param.asInt() == 1) {
    digitalWrite(13, HIGH);
  } else {
    digitalWrite(13, LOW);
  }
  ET.sendData();
}
void ledOnOff() 
{
  ETdata.LED1 == !digitalRead(pinSensor1);
  if (!digitalRead(pinSensor1)){
    Blynk.virtualWrite(V4, 255);
  Serial.println("LED4 ON");
} else {
  Blynk.virtualWrite(V4, 0);
  Serial.println("LED4 OFF");
}
ET.sendData();
}





/*BLYNK_READ(V4) {
  Blynk.virtualWrite(V4, !digitalRead(pinSensor1));
  Serial.println("GOGOGO");
  Blynk.virtualWrite(V4, ETdata.LED1);
  Blynk.virtualWrite(V4, 255);
  Serial.println("LED1.ON");

  led4.off();
  Serial.println("LED1.off");
  ET.sendData();
  }*/

/*BLYNK_WRITE(V4) {
  ETdata.LED1 = param.asInt();
  LEDstate = digitalRead(pinSensor1);
  Serial.println("OKOKOK");
  if (LEDstate == 1) {
    Serial.println("GOGOGO");
  Blynk.virtualWrite(V4, 255);
  Serial.println("LED1.ON");
  } else {

    Blynk.virtualWrite(V4, 0);
    Serial.println("LED1.OFF");
  }
  ET.sendData();
  }

  /*BLYNK_WRITE(V4){
  if (param.asInt() == 1) {
  ETdata.LED1 = !LEDstate;
  digitalWrite(pinSensor1, !LEDstate);
  led4.on();
  } else {
  led4.off();
  ET.sendData();
  }
  }*/







void loop() {
  Blynk.run();
  timer.run();
}```
На рабе такой:
```//#include <SimpleTimer.h>
#include <EasyTransfer.h>
//#include <Servo.h>
//Servo myservo;  // create servo object to control a servo
EasyTransfer ET;
//SimpleTimer timer;
//int pos = 0;
#define RELAY_ON LOW
#define RELAY_OFF HIGH
const int16_t pinSensor1 = 10;
const byte ledPins[] = {2, 3, 4, 5, 6, 7, 8, 9};



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
  int16_t LED13;
  int16_t LED1;
};

//give a name to the group of data
RECEIVE_DATA_STRUCTURE ETdata;
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(ETdata), &Serial);

  pinMode(13, OUTPUT);
  pinMode(pinSensor1, INPUT_PULLUP);
  for (byte i = 2; i <= 9; i++) {
    pinMode(i, OUTPUT);
    digitalWrite(i, RELAY_ON);
  }
}
 void loop() {
    ET.receiveData();
    {

      if (ETdata.LED13 == 1) {
        digitalWrite(13, HIGH);
      } else {
        digitalWrite(13, LOW);
      }
      if (ETdata.LED1 == 1)
        Serial.println("ETdata.LED1");

      if (!digitalRead(pinSensor1)) {
        Serial.println("СЕНСОР ТОНЕТ");
      }
    }
  }```

Может кто-нибудь подсказать,в чем я ошибку(и) допускаю в коде,почему  мастер не принимает значения?
Пожалуйста помогите:sweat_smile: