Close

Lacny termostat

Úvodní stránka Fórum Vaše projekty Arduino Lacny termostat

Aktuálně je na stránce zobrazeno 7 příspěvků - 1. až 7. (celkem z 7)
  • Autor
    Příspěvky
  • #3833
    kristian
    Účastník

    Dobry den. som tu novy a chcel by som sa podelit s mojim projektom.Nevymyslel som nic prevratne,ale za tu cenu to stoji. Ide o termostat s dotykovym displejom ktory upozornuje pipanim (ak niekto potrebuje daco zopnut/vypnut dame relatko) na prekrocenu teplotu.Nastavenu teplotu si pamata aj po odpojeni napajania.
    Po zapnuti zariadenie ukazuje teplotu a do menu sa vchadza tak, ze stlacime a podrzime stred displeja.
    Po nastaveni teploty +/- (momentalne 0-99 termostat zapina cerpadlo na peci,neriesil som zaporne cisla:) )
    tlacitkom end ulozime hodnotu do eeprom.takze cena arduino+displej 9e,vodotesne cidlo DS18B20 1,2e,piezo alebo relatko 1,5e a trafo 9V/1A 2e spolu cca 15e plus programovacka 🙂

    #3834
    kristian
    Účastník
    
    #include <EEPROM.h>
    #include <OneWire.h>
    #include <DallasTemperature.h>
    #include <Adafruit_GFX.h>    // Core graphics library
    #include <Adafruit_TFTLCD.h> // Hardware-specific library
    //#include <stdint.h>
    #include "TouchScreen.h"
    
     
    #define LCD_CS A3 //
    #define LCD_CD A2 //
    #define LCD_WR A1 //
    #define LCD_RD A0 //
    #define LCD_RESET A4 //
     
    
    #define YP A1  // must be an analog pin, use "An" notation!
    #define XM A2  // must be an analog pin, use "An" notation!
    #define YM 7   // can be a digital pin
    #define XP 6   // can be a digital pin
     
    
    // definice max a min tlaku na TouchScreen
    #define MINPRESSURE 10
    #define MAXPRESSURE 1000
    
    #define TS_MINX 131
    #define TS_MINY 947
    #define TS_MAXX 901
    #define TS_MAXY 129
    
    #define  BLACK   0x0000
    #define BLUE    0x001F
    #define RED     0xF800
    #define GREEN   0x07E0
    #define CYAN    0x07FF
    #define MAGENTA 0xF81F
    #define YELLOW  0xFFE0
    #define WHITE   0xFFFF
     
    TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300); // inicializace TouchScreen
    Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET); // inicializace LCD
    double cislo=1;
    int x, y = 0;
    TSPoint p;
    int NASTAVENAteplota;
    
    // Data wire is plugged into port 2 on the Arduino
    #define ONE_WIRE_BUS SCL
    
    // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
    OneWire oneWire(ONE_WIRE_BUS);
    
    // Pass our oneWire reference to Dallas Temperature. 
    DallasTemperature sensors(&oneWire);
    
    // arrays to hold device address
    DeviceAddress insideThermometer;
    
    void setup(void)
    {
      NASTAVENAteplota= EEPROM.read(0);
      pinMode(13, OUTPUT);
      digitalWrite(13, HIGH); // 0=off  
      
      tft.reset();
      tft.begin(0x9341); // inicializace naseho LCD shieldu
      tft.fillScreen(WHITE);
      sensors.begin();
      if (!sensors.getAddress(insideThermometer, 0)) //tft.println("Unable to find address for Device 0"); 
      delay(2);
      sensors.setResolution(insideThermometer, 9);
      tft.fillScreen(WHITE);
    }
    float temp=0;
    void printTemperature(DeviceAddress deviceAddress)
    {
     
      float tempC = sensors.getTempC(deviceAddress);
       if (tempC!=temp)
       {
       temp=tempC; 
       tft.fillScreen(WHITE); 
       tft.print(temp);
       }
    }
    
    void loop(void)
    { 
     
    //digitalWrite(13, HIGH);
     TSPoint p = ts.getPoint();
    //digitalWrite(13, LOW);
    
     pinMode(XM, OUTPUT);
      pinMode(YP, OUTPUT);
      
      if (p.z > MINPRESSURE && p.z < MAXPRESSURE) {
        
        p.x = tft.width()-(map(p.x, TS_MINX, TS_MAXX, tft.width(), 0));
        p.y = tft.height()-(map(p.y, TS_MINY, TS_MAXY, tft.height(), 0)); 
    
       
       if((75<p.x)&&(p.x<220)&&(57<p.y)&&(p.y<170))
    
       
                {
                   int menu=3;
                   tft.fillScreen(RED);
                    delay(500);
                    tft.fillScreen(WHITE);
                    ////////////////////////////////////////////////////////
                      tft.setRotation(1);
                      tft.drawFastHLine(0,39,320,RED);
                      tft.drawFastHLine(0,40,320,RED);
                      tft.drawFastHLine(0,41,320,GREEN);
                      tft.drawFastHLine(0,42,320,GREEN);
                      tft.drawFastHLine(0,43,320,BLUE);
                      tft.drawFastHLine(0,44,320,BLUE);
                      tft.setTextColor(RED);
                      tft.setCursor(200,12);
                      tft.setTextSize(2);
                      tft.setRotation(1);
                      tft.print("KikoSonic");
                      tft.setCursor(5,5);
                      tft.setTextSize(4);
                      tft.setRotation(1);
                      tft.print("Menu");
                      tft.setCursor(62,168);
                      tft.setTextColor(BLACK);
                      tft.setTextSize(5);
                      tft.setRotation(1);
                      tft.print("-");
                      tft.drawRoundRect(40,150,70,70,10,BLACK);  //spodny lavy
                      tft.setCursor(184,174);
                      tft.setTextColor(BLACK);
                      tft.setTextSize(4);
                      tft.setRotation(1);
                      tft.print("End");
                      tft.drawRoundRect(150,150,140,70,10,BLACK); //spodny pravy
                      tft.setCursor(62,78);
                      tft.setTextColor(BLACK);
                      tft.setTextSize(5);
                      tft.setRotation(1);
                      tft.print("+");
                      tft.drawRoundRect(40,60,70,70,10,BLACK); // vrch.lavy
                      tft.setCursor(184,90);
                      tft.setTextColor(BLACK);
                      tft.setTextSize(4);
                      tft.setRotation(1);
                      tft.print(NASTAVENAteplota);
                      
                    
                    while (menu==3){
                   
                    TSPoint p = ts.getPoint();
                   
                    
                    pinMode(XM, OUTPUT);
                    pinMode(YP, OUTPUT);
                    
                      
                    if (p.z > MINPRESSURE && p.z < MAXPRESSURE) {
                        
                    p.x = tft.width()-(map(p.x, TS_MINX, TS_MAXX, tft.width(), 0));
                    p.y = tft.height()-(map(p.y, TS_MINY, TS_MAXY, tft.height(), 0)); 
                    
                    if((140<p.x)&&(p.x<231)&&(30<p.y)&&(p.y<83)) //+
                    {
                     tft.setCursor(184,90);
                     tft.setTextColor(WHITE);
                     tft.setTextSize(4);
                     tft.setRotation(1);
                     tft.print(NASTAVENAteplota);
                     NASTAVENAteplota++;
                     if (NASTAVENAteplota==100)
                     {
                      NASTAVENAteplota=99;
                     }
                     tft.setCursor(184,90);
                     tft.setTextColor(BLACK);
                     tft.setTextSize(4);
                     tft.setRotation(1);
                     tft.print(NASTAVENAteplota);
                     delay(200);
                    }
                    if((15<p.x)&&(p.x<105)&&(30<p.y)&&(p.y<83)) //-
                    {
                    tft.setCursor(184,90);
                     tft.setTextColor(WHITE);
                     tft.setTextSize(4);
                     tft.setRotation(1);
                     tft.print(NASTAVENAteplota);
                     NASTAVENAteplota--;
                     if (NASTAVENAteplota==0)
                     {
                      NASTAVENAteplota=1;
                     }
                     tft.setCursor(184,90);
                     tft.setTextColor(BLACK);
                     tft.setTextSize(4);
                     tft.setRotation(1);
                     tft.print(NASTAVENAteplota);
                     delay(200);
                    }
                    if((15<p.x)&&(p.x<105)&&(111<p.y)&&(p.y<217)) //end 
                    {
                      menu=0;
                      EEPROM.write(0, NASTAVENAteplota );
                    }
                    }
                    }
                    
         
                  }  
      temp=0;            
      tft.fillScreen(RED);
      delay(1000);
      tft.fillScreen(WHITE);
      }
    
      
    
     //---------------------------menu----------------------
      
      
      
      tft.setCursor(45, 80);
      tft.setTextColor(BLACK);  
      tft.setTextSize(7);
      tft.setRotation(1);
      sensors.requestTemperatures(); // Send the command to get temperatures
         
       if (temp>=NASTAVENAteplota)
     //digitalWrite(13, LOW); //0=on  
       digitalWrite(13, HIGH);//opacna logika
      //else
     // digitalWrite(13, HIGH); // 1=off  
        if (temp<NASTAVENAteplota-0.5)
      digitalWrite(13, LOW);//opacna logikaopacna logika
      printTemperature(insideThermometer);
    
    }
    
    // function to print a device address
    void printAddress(DeviceAddress deviceAddress)
    {
      for (uint8_t i = 0; i < 8; i++)
      {
        if (deviceAddress[i] < 16) Serial.print("0");
        tft.print(deviceAddress[i], HEX);
      }
    
    }
    
    
    #3835
    kristian
    Účastník




    #3856
    Zbyšek Voda
    Správce

    Dobrá práce 🙂

    #7878
    alexejzenaty
    Účastník

    Ahoj, zkusíl jsem nahrát tvůj kod na uno s TFT, a mne se vše zobrazí obráceně. Jako odraz v zercádle. Mohl bys mi poradít, čímto je? Děkují

    #11387
    stapator
    Účastník

    Díky za dobrý nápad! Trochu jsem Tvůj kód upravil, aby spolehlivě fungoval s 2,4″LCD TFT shieldem s řadiči HC245 a knihovnou ILI9341 ver.1.0.6.

    Thermostat

    Attachments:
    #11389
    posjirka
    Účastník

    jednoduche a funkcni reseni. dobra prace

Aktuálně je na stránce zobrazeno 7 příspěvků - 1. až 7. (celkem z 7)
  • Pro reakci na toto téma se musíte přihlásit.