Проблема с одновременным считыванием температуры и активацией реле на Nextion

Нет ответов
Snidget
Offline
Зарегистрирован: 16.04.2017
Когда одновременно нажимаешь на кнопку и светодиоды RX и TX моргают, ардуина пропускает нажатия. Так и не нашёл решение проблемы.

#include <Nextion.h>
#include <SimpleTimer.h>
#include <OneWire.h>        
#include <DallasTemperature.h>

SimpleTimer DS;
SimpleTimer RELE;
Nextion myNextion(Serial, 9600); 
OneWire oneWire(7); 
DallasTemperature ds(&oneWire);
DeviceAddress mii = {0x28, 0xFF, 0xD0, 0x01, 0x86, 0x16, 0x04, 0xEE};
DeviceAddress mit = {0x28, 0xFF, 0x31, 0xE1, 0x60, 0x16, 0x05, 0x1B};
DeviceAddress heia = {0x28, 0xFF, 0x4F, 0x4F, 0xA1, 0x16, 0x05, 0x90};
DeviceAddress heit = {0x28, 0xFF, 0x50, 0x50, 0x60, 0x16, 0x05, 0xD9};
DeviceAddress hii = {0x28, 0xFF, 0xBA, 0x73, 0x60, 0x16, 0x05, 0x46};
DeviceAddress hit = {0x28, 0xFF, 0xB4, 0x28, 0x64, 0x16, 0x04, 0x68};
DeviceAddress hei = {0x28, 0xFF, 0x32, 0xC0, 0x64, 0x16, 0x04, 0xDE};
DeviceAddress het = {0x28, 0xFF, 0x35, 0xCF, 0x60, 0x16, 0x05, 0x61};
DeviceAddress tsh = {0x28, 0xFF, 0xA5, 0x64, 0x60, 0x16, 0x05, 0xEB};
DeviceAddress tsk = {0x28, 0xFF, 0xE3, 0x17, 0x64, 0x16, 0x04, 0x7E};
DeviceAddress tsb = {0x28, 0xFF, 0xA5, 0x64, 0x60, 0x16, 0x05, 0xEB};
void RELEr(){ 
String message = myNextion.listen(); 
 if(message == "nas:ON"){
digitalWrite(A0, LOW);
  };
   if(message == "nas:OFF"){
digitalWrite(A0, HIGH);
  };
 //=========================================
   if(message == "btc:ON"){
digitalWrite(A1, LOW);
  };
   if(message == "btc:OFF"){
digitalWrite(A1, HIGH);
  };
//==========================================  
  if(message == "bk:ON"){
digitalWrite(A2, LOW);
  };
   if(message == "bk:OFF"){
digitalWrite(A2, HIGH);
  };
//==========================================
  if(message == "bz:ON"){
digitalWrite(A3, LOW);
  };
   if(message == "bz:OFF"){
digitalWrite(A3, HIGH);
  };
//==========================================
  if(message == "bs:ON"){
digitalWrite(A4, LOW);
  };
   if(message == "bs:OFF"){
digitalWrite(A4, HIGH);
  };
//==========================================
  if(message == "btp:ON"){
digitalWrite(A5, LOW);
  };
   if(message == "btp:OFF"){
digitalWrite(A5, HIGH);
  };
//==========================================
}

void DSr(){
  ds.requestTemperatures();   

myNextion.setComponentText("mii", String(ds.getTempC(mii), 1));   

myNextion.setComponentText("mit", String(ds.getTempC(mit), 1));

myNextion.setComponentText("heia", String(ds.getTempC(heia), 1));

myNextion.setComponentText("heit", String(ds.getTempC(heit), 1));

myNextion.setComponentText("hii", String(ds.getTempC(hii), 1));

myNextion.setComponentText("hit", String(ds.getTempC(hit), 1));

myNextion.setComponentText("hei", String(ds.getTempC(hei), 1));

myNextion.setComponentText("het", String(ds.getTempC(het), 1));    

myNextion.setComponentText("tsh", String(ds.getTempC(tsh), 1));

myNextion.setComponentText("tsk", String(ds.getTempC(tsk), 1));

myNextion.setComponentText("tsb", String(ds.getTempC(tsb), 1));
}
void setup() {
  Serial.begin(9600);
  myNextion.init();
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
pinMode(A2, OUTPUT);
pinMode(A3, OUTPUT);
pinMode(A4, OUTPUT);
pinMode(A5, OUTPUT);
digitalWrite(A0, HIGH);
digitalWrite(A1, HIGH);
digitalWrite(A2, HIGH);
digitalWrite(A3, HIGH);
digitalWrite(A4, HIGH);
digitalWrite(A5, HIGH);
RELE.setInterval(100, RELEr);
DS.setInterval(2000, DSr);
ds.begin();
  ds.setResolution(mii, 11);
ds.setResolution(mit, 11);
ds.setResolution(heia, 11);
ds.setResolution(heit, 11);
ds.setResolution(hii, 11);
ds.setResolution(hit, 11);
ds.setResolution(hei, 11); 
ds.setResolution(het, 11);
ds.setResolution(tsh, 11);
ds.setResolution(tsk, 11);
ds.setResolution(tsb, 11);

}

void loop() {
String message = myNextion.listen();
if (message != ""){
RELE.run();
}
DS.run();
}