Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Tempaerature switch is used to switch relay ON/OFF according to room's temperature
- // BOM:
- // - Arduino Micro - RobotDyn - https://www.aliexpress.com/item/Micro-ATmega32U4-5V-16MHz-Pins-soldered-Compatible-with-Arduino-Micro-and-Leonardo/32676998690.html?spm=2114.13010608.0.0.dKi9ne
- // $ 4.39
- // - Button - RobotDyn - https://www.aliexpress.com/item/Button-Switch-module-WHITE/32628948023.html?spm=2114.13010608.0.0.aM9oQE
- // -- Interrupt pin 9
- // $ 0.75
- // - 2 Channel 5V Relay - RobotDyn https://www.aliexpress.com/item/Relay-Module-2-relays-5V/32530849971.html?spm=2114.13010608.0.0.dKi9ne
- // -- Pins 4, 5
- // $ 1.09
- // - Temperature and Humidity sensor SHT1x - RobotDyn - https://www.aliexpress.com/item/Temperature-and-Humidity-sensor-SHT1x/32569601511.html?spm=2114.13010608.0.0.FQUvCk
- // -- Pins Data 6, SCK 7
- // $ 5.8
- // - RTC DS1307 - RobotDyn - https://www.aliexpress.com/item/RTC-Real-Time-Clock-DS1307-module-with-battery/32530897478.html?spm=2114.13010608.0.0.pEu9M6
- // -- I2C
- // $ 1.25
- // - Krabice na omítku KLIK 130
- // CZK 42,-
- // - Dupont lines
- //include guard
- #ifndef _TemperatureSwitch_h_
- #define _TemperatureSwitch_h_
- // Include libraries
- #include "Arduino.h"
- #include "Board.h"
- #include "Wire.h"
- #include "p.h"
- #include "SHT1x.h"
- #include "RtcDS1307.h"
- bool debug = false;
- // Typing
- typedef struct strucTime {
- uint8_t hour = 0;
- uint8_t minute = 0;
- uint8_t second = 0;
- } strucTime;
- // Relay Pins
- //p relayPin1(4);
- //p relayPin2(5);
- p relayPin1(4);
- p relayPin2(5);
- // Button pint
- int buttonPin = 20;
- int buttonInterruptPin = 2;
- // Standard led PIN
- p ledPin(13);
- // RTC
- RtcDS1307<TwoWire> Rtc(Wire);
- // SHT sensor
- int dataPin = 6;
- int clockPin = 7;
- SHT1x temperatureSensor(dataPin, clockPin);
- // Control variables
- float lowTemperature = 18; //TODO: Change
- float highTemperature = 21; //TODO: Change
- int minutesToRun = 10; //TODO: Change
- int stopMinute = -1;
- int startHour = 22;
- int endHour = 8;
- strucTime actualTime;
- strucTime buttonTime;
- strucTime temperatureTime;
- strucTime waitTime;
- bool buttonPressed = false;
- bool getTime = false;
- bool waitingTime = false;
- //float actualTemperature = 20;
- //bool step=false;
- //unsigned long startMillis=-1;
- void checkTemperature();
- void getDateTime();
- bool highTempeartureReached(float temperature);
- bool lowTemperatureReached(float temperature);
- void setupPins();
- void setupRTC();
- void handleButtonPressed();
- void setup();
- void loop();
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement