PowerTGS440

Untitled

Mar 22nd, 2024
916
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.96 KB | Software | 0 0
  1. #include <EEPROM.h>
  2. #include "GravityTDS.h"
  3. #include <OneWire.h>
  4. #include <DallasTemperature.h>
  5. #include <ThreeWire.h>
  6. #include <RtcDS1302.h>
  7. #include <SPI.h>
  8. #include <Wire.h>
  9. #include <Adafruit_GFX.h>
  10. #include <Adafruit_SH1106.h>
  11.  
  12.  
  13.  
  14. #define OLED_SDA 21
  15. #define OLED_SCL 22
  16. #define SCREEN_WIDTH 128
  17. #define SCREEN_HEIGHT 64
  18. #define ONE_WIRE_BUS 5
  19. Adafruit_SH1106 display(21, 22);
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26. OneWire oneWire(ONE_WIRE_BUS);
  27.  
  28. DallasTemperature sensors(&oneWire);
  29.  
  30. ThreeWire myWire(19,18,23); //DAT,CLK,RST
  31. RtcDS1302<ThreeWire> Rtc(myWire);
  32.  
  33.  
  34. void Pompa1_wlacz()
  35. {
  36.    digitalWrite(33, HIGH);
  37.    // kod do wlaczenia pompy nr. 1
  38. }
  39.  
  40. void Pompa1_wylacz()
  41. {
  42.     digitalWrite(33, LOW);
  43.     // kod do wylaczenia pompy nr. 1
  44. }
  45. void pomiary()
  46. {
  47.     RtcDateTime now = Rtc.GetDateTime();
  48.     sensors.requestTemperatures();
  49.     static bool F_Pompa_1 = false;
  50.     int godzina = now.Hour();
  51.     int minuta = now.Minute();
  52.     int sekunda = now.Second();
  53.    
  54.  
  55.     // WLACZENIE POMPY nr. 1
  56.     if(godzina == 8 && minuta == 0 && sekunda == 0)
  57.     {
  58.       if(!F_Pompa_1)
  59.       {
  60.           Pompa1_wlacz();
  61.           F_Pompa_1 = true;
  62.       }
  63.     }
  64.  
  65.     // WYLACZENIE POMPY nr. 1  
  66.     if(godzina == 8 && minuta == 0 && sekunda == 5)
  67.     {
  68.         if(F_Pompa_1)
  69.         {
  70.             Pompa1_wylacz();
  71.             F_Pompa_1 = false;
  72.         }
  73.     }
  74.  
  75.     // WLACZENIE POMPY nr. 1
  76.     if(godzina == 19 && minuta == 0 && sekunda == 0)
  77.     {
  78.       if(!F_Pompa_1)
  79.       {
  80.           Pompa1_wlacz();
  81.           F_Pompa_1 = true;
  82.       }
  83.     }
  84.  
  85.     // WYLACZENIE POMPY nr. 1  
  86.     if(godzina == 19 && minuta ==15 && sekunda == 5)
  87.     {
  88.         if(F_Pompa_1)
  89.         {
  90.             Pompa1_wylacz();
  91.             F_Pompa_1 = false;
  92.         }
  93.     }
  94.  
  95.    
  96. }
  97.  
  98.  
  99.  void setup()
  100. {
  101. pinMode(12,OUTPUT);
  102. pinMode(14,OUTPUT);
  103.  
  104.   Rtc.Begin();
  105.    RtcDateTime now = Rtc.GetDateTime();
  106.  
  107.  RtcDateTime currentTime = RtcDateTime(2024,03,21,8,14,45);
  108.  Rtc.SetDateTime(currentTime);
  109.   sensors.begin();
  110.   pinMode(33, OUTPUT);
  111.   pinMode(32, OUTPUT);
  112.   pinMode(25, OUTPUT);
  113.  
  114.     Serial.begin(115200);
  115.  
  116.  
  117. pinMode(13,INPUT);
  118.  
  119.    display.begin(SH1106_SWITCHCAPVCC, 0x3C);
  120.   delay(2000);
  121.   display.clearDisplay();
  122. }
  123.  
  124.  
  125.  
  126. void loop(void)
  127. {
  128. RtcDateTime now = Rtc.GetDateTime();
  129. digitalWrite(12,HIGH);
  130. digitalWrite(14,HIGH);
  131. pomiary();
  132.  
  133.     display.clearDisplay();
  134.  
  135.   display.setTextSize(1);
  136.   display.setTextColor(WHITE);
  137.   display.setCursor(0, 10);
  138.   // Display static text
  139.    display.print("TEMP: ");
  140.   display.println(sensors.getTempCByIndex(0));
  141.  
  142.   display.println(  );
  143.   display.print(now.Day() );
  144.   display.print("/");
  145.   display.print(now.Month());
  146.   display.print("/");
  147.   display.print(now.Year());
  148.   display.print("/");
  149.   display.print(now.Hour());
  150.   display.print("/");
  151.   display.print(now.Minute());
  152.   display.print("/");
  153.   display.print(now.Second());
  154.  
  155.   display.display();
  156.   display.clearDisplay();
  157.  ;
  158. }
  159.  
Advertisement
Add Comment
Please, Sign In to add comment