Components and supplies
Standard LCD - 16x2 White on Blue
solenoid valve
power supply
Arduino UNO
Relay (generic)
DS3231M - ±5ppm, I2C Real-Time Clock
Rotary potentiometer (generic)
Breadboard (generic)
Resistor 10k ohm
10K Precision Epoxy Thermistor
Tools and machines
Laser cutter (generic)
Apps and platforms
Arduino IDE
Project description
Code
Code
arduino
1#include <Wire.h> //real time clock sensor library 2#include <DS3231.h> 3#include <LiquidCrystal.h> //LCD monitor library 4#include <Keypad.h> //keypad library 5 6DS3231 clock; 7RTCDateTime dt; 8LiquidCrystal lcd(7, 8, 9, 10, 11, 12); // initialize the library with the numbers of the interface pins 9 10const byte ROWS = 4; //four rows 11const byte COLS = 1; //one column 12//define the cymbols on the buttons of the keypads 13char hexaKeys[ROWS][COLS] = { 14 {'1'}, 15 {'2'}, 16 {'3'}, 17 {'4'} 18}; 19byte rowPins[ROWS] = {6, 5, 4, 3}; //connect to the row pinouts of the keypad 20byte colPins[COLS] = {2}; //connect to the column pinouts of the keypad 21 22//initialize an instance of class NewKeypad 23Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); 24 25int ThermistorPin = A0; // Temperature sensor 26int relaypin = 13; //relay pin 27 28int Vore = 0; //time, in hours 29int Vmin = 0; //time, in minutes 30int Vtemp = 0; //limit temperature 31int VOfin = 0; //end time, in hour 32int VMfin = 0; //end time, in minutes 33int Vo = 0; //conversion 34 35float R1 = 10000; //temperature sensor variables 36float logR2, R2, T, Tc, Tf; 37float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07; 38 39void setup() { 40 clock.begin(); 41 clock.setDateTime(__DATE__, __TIME__); //set up the real time clock sensor 42 pinMode (ThermistorPin, INPUT); 43 pinMode (relaypin, OUTPUT); 44 lcd.begin(16, 2); // set up the LCD's number of columns and rows: 45 lcd.setCursor(0, 0); //reset the lcd monitor 46 lcd.print (" "); 47 lcd.setCursor(0, 1); 48 lcd.print (" "); 49} 50 51void loop() { 52 Vo = analogRead(ThermistorPin); // reading the temperature and conversion in celsius 53 R2 = R1 * (1023.0 / (float)Vo - 1.0); 54 logR2 = log(R2); 55 T = (1.0 / (c1 + c2 * logR2 + c3 * logR2 * logR2 * logR2)); 56 Tc = T - 273.15; 57 dt = clock.getDateTime(); //reading the time from the RTC DS3231 58 char customKey1 = customKeypad.getKey(); //reading the keypad key 59 if (customKey1 == '1' ) { // change of time 60 Vore = Vore + 1; 61 if (Vore > 23) { 62 Vore = 0; 63 } 64 } 65 if (customKey1 == '2' ) { 66 Vmin = Vmin + 1; 67 if (Vmin > 59) { 68 Vmin = 0; 69 } 70 } 71 if (customKey1 == '3' ) { //change of temperature 72 Vtemp = Vtemp + 1; 73 if (Vtemp > 40) { 74 Vtemp = 0; 75 } 76 } 77 lcd.setCursor(0, 0); // set the cursor to column 0, line 0 78 lcd.print ("Sh"); //print the time that it will start (start hour) 79 lcd.print (Vore); 80 lcd.print(":"); 81 lcd.print(Vmin); 82 lcd.print(" Ch"); //print the current time (current hour) 83 lcd.print (dt.hour); 84 lcd.print (":"); 85 lcd.print(dt.minute); 86 lcd.setCursor(0, 1); // set the cursor to column 0, line 1 87 lcd.print ("Tl "); //print the limit temperature 88 lcd.print (Vtemp); 89 lcd.print("C"); 90 lcd.print(" Tm "); //print the current temperature 91 lcd.print (Tc); 92 lcd.print("C"); 93 if ((dt.hour == Vore) && (dt.minute == Vmin)) { //condition for irrigation 94 if (Tc < Vtemp) { 95 digitalWrite (relaypin, HIGH); //start irrigate 96 if (dt.second < 50) { 97 VMfin = Vmin + 2; 98 VOfin = Vore; //set the final time of irrigation 99 if (VMfin > 60) { 100 VMfin = VMfin - 60; 101 VOfin = Vore + 1; 102 if (VOfin == 24) { 103 VOfin = 0; 104 } 105 } 106 delay(50000); //delay to allow the correct calculation of the final time of irrigation, because we need to calculate it one time and not more// 107 } 108 delay(1000); 109 } 110 } 111 else if ((dt.hour == VOfin) && (dt.minute == VMfin)) { 112 digitalWrite (relaypin, LOW); //stop irrigate at final time of irrigation 113 } 114 else { 115 delay(120); //delay to refresh the LCD monitor 116 } 117} 118
Code
arduino
1#include <Wire.h> //real time clock sensor library 2#include <DS3231.h> 3#include <LiquidCrystal.h> //LCD monitor library 4#include <Keypad.h> //keypad library 5 6DS3231 clock; 7RTCDateTime dt; 8LiquidCrystal lcd(7, 8, 9, 10, 11, 12); // initialize the library with the numbers of the interface pins 9 10const byte ROWS = 4; //four rows 11const byte COLS = 1; //one column 12//define the cymbols on the buttons of the keypads 13char hexaKeys[ROWS][COLS] = { 14 {'1'}, 15 {'2'}, 16 {'3'}, 17 {'4'} 18}; 19byte rowPins[ROWS] = {6, 5, 4, 3}; //connect to the row pinouts of the keypad 20byte colPins[COLS] = {2}; //connect to the column pinouts of the keypad 21 22//initialize an instance of class NewKeypad 23Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); 24 25int ThermistorPin = A0; // Temperature sensor 26int relaypin = 13; //relay pin 27 28int Vore = 0; //time, in hours 29int Vmin = 0; //time, in minutes 30int Vtemp = 0; //limit temperature 31int VOfin = 0; //end time, in hour 32int VMfin = 0; //end time, in minutes 33int Vo = 0; //conversion 34 35float R1 = 10000; //temperature sensor variables 36float logR2, R2, T, Tc, Tf; 37float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07; 38 39void setup() { 40 clock.begin(); 41 clock.setDateTime(__DATE__, __TIME__); //set up the real time clock sensor 42 pinMode (ThermistorPin, INPUT); 43 pinMode (relaypin, OUTPUT); 44 lcd.begin(16, 2); // set up the LCD's number of columns and rows: 45 lcd.setCursor(0, 0); //reset the lcd monitor 46 lcd.print (" "); 47 lcd.setCursor(0, 1); 48 lcd.print (" "); 49} 50 51void loop() { 52 Vo = analogRead(ThermistorPin); // reading the temperature and conversion in celsius 53 R2 = R1 * (1023.0 / (float)Vo - 1.0); 54 logR2 = log(R2); 55 T = (1.0 / (c1 + c2 * logR2 + c3 * logR2 * logR2 * logR2)); 56 Tc = T - 273.15; 57 dt = clock.getDateTime(); //reading the time from the RTC DS3231 58 char customKey1 = customKeypad.getKey(); //reading the keypad key 59 if (customKey1 == '1' ) { // change of time 60 Vore = Vore + 1; 61 if (Vore > 23) { 62 Vore = 0; 63 } 64 } 65 if (customKey1 == '2' ) { 66 Vmin = Vmin + 1; 67 if (Vmin > 59) { 68 Vmin = 0; 69 } 70 } 71 if (customKey1 == '3' ) { //change of temperature 72 Vtemp = Vtemp + 1; 73 if (Vtemp > 40) { 74 Vtemp = 0; 75 } 76 } 77 lcd.setCursor(0, 0); // set the cursor to column 0, line 0 78 lcd.print ("Sh"); //print the time that it will start (start hour) 79 lcd.print (Vore); 80 lcd.print(":"); 81 lcd.print(Vmin); 82 lcd.print(" Ch"); //print the current time (current hour) 83 lcd.print (dt.hour); 84 lcd.print (":"); 85 lcd.print(dt.minute); 86 lcd.setCursor(0, 1); // set the cursor to column 0, line 1 87 lcd.print ("Tl "); //print the limit temperature 88 lcd.print (Vtemp); 89 lcd.print("C"); 90 lcd.print(" Tm "); //print the current temperature 91 lcd.print (Tc); 92 lcd.print("C"); 93 if ((dt.hour == Vore) && (dt.minute == Vmin)) { //condition for irrigation 94 if (Tc < Vtemp) { 95 digitalWrite (relaypin, HIGH); //start irrigate 96 if (dt.second < 50) { 97 VMfin = Vmin + 2; 98 VOfin = Vore; //set the final time of irrigation 99 if (VMfin > 60) { 100 VMfin = VMfin - 60; 101 VOfin = Vore + 1; 102 if (VOfin == 24) { 103 VOfin = 0; 104 } 105 } 106 delay(50000); //delay to allow the correct calculation of the final time of irrigation, because we need to calculate it one time and not more// 107 } 108 delay(1000); 109 } 110 } 111 else if ((dt.hour == VOfin) && (dt.minute == VMfin)) { 112 digitalWrite (relaypin, LOW); //stop irrigate at final time of irrigation 113 } 114 else { 115 delay(120); //delay to refresh the LCD monitor 116 } 117} 118
Downloadable files
Elettric
Elettric
Elettric
Elettric
Documentation
laser cutter file
laser cutter file
laser cutter file
laser cutter file
laser cutter file
laser cutter file
laser cutter file
laser cutter file
laser cutter file
laser cutter file
laser cutter file
laser cutter file
laser cutter file
laser cutter file
Comments
Only logged in users can leave comments
smana_00
0 Followers
•0 Projects
Table of contents
Intro
11
0