I want to make sure that when the temperature drops, the mail goes. Bole wrote less, but when reaching the temperature range from 35 to 40 MAIL is constantly sent and other buttons do not work, as soon as the temperature goes out of range everything starts working normally. Did two options, one is commented.
Хочу сделать, чтобы при снижении температуры отправлялся маил. Боле менее написал, но при достижении диапазона температуры от 35 до 40 маил постоянно отправляется и другие кнопки не работают, как только температура выйдет из диапазона все начинает работать нормально. Делал два варианта, один закоментирован.
#define BLYNK_PRINT Serial
#define ONE_WIRE_BUS 2//датчик температуры на 2 пине
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define PIN 15 // контролируемый пин модуля с которого приходит сиграл
char auth[] = "YourAuthToken";
WidgetLED led1(V3);
BlynkTimer timer;
void buttonLedWidget(){
int x = digitalRead(PIN);//читаем пин модуля
if (x == 1) {//проверим состояние
led1.on(); //вкл вирт.светодиод
}
else { //иначе выключим
led1.off();
}
}
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
sensors.begin();
pinMode(PIN, INPUT_PULLUP);
timer.setInterval(500L, buttonLedWidget);
}
void sendTemps()
{
sensors.requestTemperatures();
float temp = sensors.getTempCByIndex(0);
Blynk.virtualWrite(V4, temp);
//if (temp >= 35 && temp <= 40){
// Blynk.email("your_email@mail.ru", "ВНИМАНИЕ низкая температура теплоносителя меньше 40С");
//}
}
void mail()
{
float sen;
sen=sensors.getTempCByIndex(0);
if (sen >= 35 && sen <= 40){
Blynk.email("your_email@mail.ru", "ВНИМАНИЕ низкая температура теплоносителя меньше 40С");//отправка майла при приходе сигнала
}
}
void loop()
{
Blynk.run();
sendTemps();
mail();
timer.run();
}