• Уважаемые посетители сайта esp8266.ru!
    Мы отказались от размещения рекламы на страницах форума для большего комфорта пользователей.
    Вы можете оказать посильную поддержку администрации форума. Данные средства пойдут на оплату услуг облачных провайдеров для сайта esp8266.ru
  • Система автоматизации с открытым исходным кодом на базе esp8266/esp32 микроконтроллеров и приложения IoT Manager. Наша группа в Telegram

Энкодер Терморегулярот

Foxmaster

New member
Тупо не работает энкодер. хочу просто чтобы енкодером тоже сиенивать заданную температуру. А он тупо не работает. На тестах Работает на ура. Ну просто не могу ничего понять. В скетче просто подставлено значение не реагирует. Кто может ПОМОГИТЕ.
Код:
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#include "DHT.h"
#define DHTTYPE DHT11
DHT dht (D4, DHTTYPE);

  #define DHTPIN D4
  #define CLK D7
  #define DT D6
  #define SW D5
  #include "GyverEncoder.h"
  Encoder enc1(CLK, DT, SW);
  float value = 10;


#include <Adafruit_BMP280.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET    LED_BUILTIN
#define BMP280_I2C_ADDRESS  0x76
#define BLYNK_PRINT Serial
#define RELE D8
bool rele;
Adafruit_BMP280  bmp280;
const int oneWireBus = D3;
float velue;


   char auth[] = "UKL1WQF4sm4MIqqCoQpmkuktysEv9q_B";       
                                         
   char ssid[] = "Sosi";   
    char pass[] = "12345678";

float Delta =  0.5;             // Дельта (Гистерезес) терморегулятора
float deltaT = 0.0;

OneWire oneWire(oneWireBus);
Adafruit_SSD1306 display(OLED_RESET);

DallasTemperature sensors(&oneWire);
WidgetLED led (V7);


const unsigned char myBitmap [] PROGMEM = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x80, 0x00, 0x00, 0x00,
  0xff, 0xc0, 0x00, 0x00, 0x01, 0xc0, 0xe7, 0xf8, 0x00, 0x01, 0xc0, 0x67, 0xfc, 0x00, 0x01, 0x80,
  0x70, 0x00, 0x00, 0x01, 0x80, 0x70, 0x00, 0x00, 0x01, 0x80, 0x77, 0xe0, 0x00, 0x01, 0x80, 0x77,
  0xe0, 0x00, 0x01, 0x80, 0x70, 0x00, 0x00, 0x01, 0x80, 0x70, 0x00, 0x00, 0x01, 0x80, 0x77, 0xfc,
  0x00, 0x01, 0x80, 0x73, 0xf8, 0x00, 0x01, 0x80, 0x70, 0x00, 0x00, 0x01, 0x80, 0x70, 0x00, 0x00,
  0x01, 0x80, 0x77, 0xe0, 0x00, 0x01, 0x80, 0x73, 0xe0, 0x00, 0x01, 0x80, 0x70, 0x00, 0x00, 0x01,
  0x80, 0x70, 0x00, 0x00, 0x01, 0x80, 0x77, 0xf8, 0x00, 0x01, 0x80, 0x77, 0xf8, 0x00, 0x01, 0x80,
  0x70, 0x00, 0x00, 0x01, 0x9f, 0x70, 0x00, 0x00, 0x01, 0x9f, 0x77, 0xe0, 0x00, 0x01, 0x9f, 0x73,
  0xe0, 0x00, 0x01, 0x9f, 0x70, 0x00, 0x00, 0x01, 0x9f, 0x70, 0x00, 0x00, 0x01, 0x9f, 0x77, 0xfc,
  0x00, 0x01, 0x9f, 0x73, 0xf8, 0x00, 0x01, 0x9f, 0x70, 0x00, 0x00, 0x01, 0x9f, 0x70, 0x00, 0x00,
  0x01, 0x9f, 0x77, 0xe0, 0x00, 0x01, 0x9f, 0x77, 0xe0, 0x00, 0x01, 0x9f, 0x70, 0x00, 0x00, 0x01,
  0x9f, 0x70, 0x00, 0x00, 0x01, 0x9f, 0x77, 0xf8, 0x00, 0x01, 0x9f, 0x77, 0xf8, 0x00, 0x03, 0x9f,
  0x78, 0x00, 0x00, 0x07, 0x1f, 0x3c, 0x00, 0x00, 0x0e, 0x3f, 0x9c, 0x00, 0x00, 0x1c, 0xff, 0xce,
  0x00, 0x00, 0x1c, 0xff, 0xe6, 0x00, 0x00, 0x19, 0xff, 0xb7, 0x00, 0x00, 0x39, 0xff, 0x93, 0x00,
  0x00, 0x3b, 0xff, 0x93, 0x00, 0x00, 0x33, 0xff, 0xd3, 0x00, 0x00, 0x33, 0xff, 0xd3, 0x00, 0x00,
  0x3b, 0xff, 0x93, 0x00, 0x00, 0x39, 0xff, 0x97, 0x00, 0x00, 0x19, 0xff, 0xa6, 0x00, 0x00, 0x1c,
  0xff, 0xe6, 0x00, 0x00, 0x0c, 0x7f, 0xce, 0x00, 0x00, 0x06, 0x1f, 0x1c, 0x00, 0x00, 0x07, 0x80,
  0x38, 0x00, 0x00, 0x03, 0xe1, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x3f, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};


void setup()

{ 
  enc1.setType(TYPE2);
  pinMode(RELE, OUTPUT);
  digitalWrite(RELE, LOW);
Serial.begin(115200);
dht.begin();
sensors.begin();
bmp280.begin(BMP280_I2C_ADDRESS);
Blynk.begin(auth, ssid, pass);

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.display();
  display.clearDisplay();
 
     
}
BLYNK_CONNECTED()
{
Blynk.syncVirtual(V6);
}
BLYNK_WRITE (V6)
{
velue = param.asInt();
}

BLYNK_WRITE (V0)

{
  rele = param.asInt();
digitalWrite(RELE, rele);

}

void loop()
{
   {enc1.tick();
 
  if (enc1.isRight()) value++;        // если был поворот направо, увеличиваем на 1
  if (enc1.isLeft()) value--;         // если был поворот налево, уменьшаем на 1            
  Serial.print(value);            // выводим значение при повороте
   Serial.print("  enkoder");
   }
 
float temp     = bmp280.readTemperature ();   // get temperature
float pressure = bmp280.readPressure();      // get pressure

  //Serial.print("bmp280: ºC ");
// Serial.print(temp);
  // Serial.print("bmp280: pas ");
    // Serial.print(pressure);
  

float h = dht.readHumidity();
float t = dht.readTemperature();
//Serial.print("H1: ");
//Serial.print(h);
//Serial.print(" %\t");
//Serial.print("T1: ");
//Serial.print(t);
//Serial.print(" ºC ");
  sensors.requestTemperatures();
  float temperatureC = sensors.getTempCByIndex(0);
 
  //Serial.print(temperatureC);
   //Serial.println(" Ds18b20ºC ");

Blynk.virtualWrite(V1, t);
Blynk.virtualWrite(V3, h);
Blynk.virtualWrite(V5, temperatureC);
Blynk.virtualWrite(V8, temp);
Blynk.virtualWrite(V9, pressure/100*0.75);
Blynk.virtualWrite(V10, deltaT);

deltaT = (t+temperatureC+temp)/3;
     //Serial.print(deltaT);
     //Serial.println(" deltaTºC ");
     Serial.print(velue);
     Serial.println(" Slaider ");
  

   
   
    display.setTextSize(1);     
    display.setTextColor(WHITE); 
    display.setCursor(40, 0);           
    display.print("Temperatyra");
    display.drawBitmap(0, 5,  myBitmap, 33, 60, WHITE, BLACK);
   

            display.setTextSize(2);     
            display.setTextColor(WHITE);
            display.setCursor(33, 15);
            display.print(deltaT, 1);
            display.print(":C");
            //display.display();
 
 
  display.setTextSize(2);     
  display.setTextColor(WHITE);
  display.setCursor(33, 40);
  display.print(velue, 1);
  //display.setTextSize(1);
  display.print(":Vc");
  //display.display();


if(deltaT <= velue-Delta)
{
  led.on();
  digitalWrite(RELE, LOW);
  //Serial.println(" LOW");
}
else if (deltaT >= velue+Delta)
{
  led.off();
digitalWrite(RELE, HIGH);
  //Serial.println(" HIGH ");
}

display.display();

//delay (1000);
display.clearDisplay();
Blynk.run();

}
 
Сверху Снизу