Уважаемый Пит,все-таки вы рановато прикрыли тему,сегодня решил попробовать подключить по той же аналогии поплавковый датчик к 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("СЕНСОР ТОНЕТ");
}
}
}
Всякие различные варианты перепробовал,как только не пробовал переменными крутить,но почему то датчик вообще не реагирует.Отдельно,когда подключаю,то он работает,а вот встроить его в конструкцию свою у меня не получается,какую то мелочь упускаю?Прошу помощи:Невинные: