Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <EEPROM.h>
- #include "GravityTDS.h"
- #include <OneWire.h>
- #include <DallasTemperature.h>
- #include <ThreeWire.h>
- #include <RtcDS1302.h>
- #include <SPI.h>
- #include <Wire.h>
- #include <Adafruit_GFX.h>
- #include <Adafruit_SH1106.h>
- #define OLED_SDA 21
- #define OLED_SCL 22
- #define SCREEN_WIDTH 128
- #define SCREEN_HEIGHT 64
- #define ONE_WIRE_BUS 5
- Adafruit_SH1106 display(21, 22);
- OneWire oneWire(ONE_WIRE_BUS);
- DallasTemperature sensors(&oneWire);
- ThreeWire myWire(19,18,23); //DAT,CLK,RST
- RtcDS1302<ThreeWire> Rtc(myWire);
- void Pompa1_wlacz()
- {
- digitalWrite(33, HIGH);
- // kod do wlaczenia pompy nr. 1
- }
- void Pompa1_wylacz()
- {
- digitalWrite(33, LOW);
- // kod do wylaczenia pompy nr. 1
- }
- void Pompa2_wlacz()
- {
- digitalWrite(32, HIGH);
- // kod do wlaczenia pompy nr. 1
- }
- void Pompa2_wylacz()
- {
- digitalWrite(32, LOW);
- // kod do wylaczenia pompy nr. 1
- }
- void pomiary()
- {
- RtcDateTime now = Rtc.GetDateTime();
- sensors.requestTemperatures();
- static bool F_Pompa_1 = false;
- static bool F_Pompa_2 = false;
- int godzina = now.Hour();
- int minuta = now.Minute();
- int sekunda = now.Second();
- // WLACZENIE POMPY nr. 1
- if(godzina == 8 && minuta == 0 && sekunda == 0)
- {
- if(!F_Pompa_1)
- {
- Pompa1_wlacz();
- F_Pompa_1 = true;
- }
- }
- // WYLACZENIE POMPY nr. 1
- if(godzina == 8 && minuta == 0 && sekunda == 5)
- {
- if(F_Pompa_1)
- {
- Pompa1_wylacz();
- F_Pompa_1 = false;
- }
- }
- // WLACZENIE POMPY nr. 1
- if(godzina == 19 && minuta == 0 && sekunda == 0)
- {
- if(!F_Pompa_1)
- {
- Pompa1_wlacz();
- F_Pompa_1 = true;
- }
- }
- // WYLACZENIE POMPY nr. 1
- if(godzina == 19 && minuta ==15 && sekunda == 5)
- {
- if(F_Pompa_1)
- {
- Pompa1_wylacz();
- F_Pompa_1 = false;
- }
- }
- // WLACZENIE POMPY nr. 2
- if(godzina == 20 && minuta == 0 && sekunda == 0)
- {
- if(!F_Pompa_2)
- {
- Pompa2_wlacz();
- F_Pompa_2 = true;
- }
- }
- // WYLACZENIE POMPY nr. 2
- if(godzina == 20 && minuta == 1 && sekunda == 5)
- {
- if(F_Pompa_2)
- {
- Pompa2_wylacz();
- F_Pompa_2 = false;
- }
- }
- }
- void setup()
- {
- pinMode(12,OUTPUT);
- pinMode(14,OUTPUT);
- Rtc.Begin();
- RtcDateTime now = Rtc.GetDateTime();
- RtcDateTime currentTime = RtcDateTime(2024,03,21,8,14,45);
- Rtc.SetDateTime(currentTime);
- sensors.begin();
- pinMode(33, OUTPUT);
- pinMode(32, OUTPUT);
- pinMode(25, OUTPUT);
- Serial.begin(115200);
- pinMode(13,INPUT);
- display.begin(SH1106_SWITCHCAPVCC, 0x3C);
- delay(2000);
- display.clearDisplay();
- }
- void loop(void)
- {
- RtcDateTime now = Rtc.GetDateTime();
- digitalWrite(12,HIGH);
- digitalWrite(14,HIGH);
- pomiary();
- display.clearDisplay();
- display.setTextSize(1);
- display.setTextColor(WHITE);
- display.setCursor(0, 10);
- // Display static text
- display.print("TEMP: ");
- display.println(sensors.getTempCByIndex(0));
- display.println( );
- display.print(now.Day() );
- display.print("/");
- display.print(now.Month());
- display.print("/");
- display.print(now.Year());
- display.print("/");
- display.print(now.Hour());
- display.print("/");
- display.print(now.Minute());
- display.print("/");
- display.print(now.Second());
- display.display();
- display.clearDisplay();
- ;
- }
Advertisement
Add Comment
Please, Sign In to add comment