Greenhouse project

Hi,
I have below hardware with me.
Arduino Uno
8 Relay module
DS3231 module
1602 LCD module

Can someone help me with the coding for this please. I tried so many codes out there. But It's very hard for me to customize the way I want it. Below is what I need.

  1. I want to water my plants on specific times on everyday.

  2. 1 relay to power 220V water motor.

  3. other 7 relays are for 220V solenoids. each one should open and close on specific times of the day. Every time a solenoid opens the water motor on relay 1 should work too.

  4. LCD must show the time, date and day current and Last time it has watered and when is the next one. Every 5 seconds info on the LCD can change from current time, date and day to last time it has watered to when is the next one.

Hope a Arduino expert can help me out. Thank you.

Cheers.

Start with a simple example for whichever DS3231 library you are using and display the time on the Serial monitor

Separately try a "Hello World" program from whichever LCD library that you are using

Merge the two together to display the time on the LCD

Come back if/when you get stuck. When the LCD display of time works you can move on to testing the time and taking action at specific times or intervals

Hi Bob,

Thank you for prompting to help me out.

I did below.

But I came across few issues which are highlighted.

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <DS3231.h>

// Init the DS3231 using the hardware interface
DS3231  rtc(SDA, SCL);

// set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27,20,4);

void setup()
{

   // Initialize the rtc object
  rtc.begin();
  
  // The following lines can be uncommented to set the date and time
  rtc.setDOW(SUNDAY);     // Set Day-of-Week to SUNDAY
  rtc.setTime(12, 00, 00);     // Set the time to 12:00:00 (24hr format)

rtc.setDate(1, 1, 2014); // Set the date to January 1st, 2014

//if i put as above code as below I get the error as 'Jan' was not declared in this scope.

  1. How can I declare JAN, FEB and so forth.

rtc.setDate(Jan, 1, 2014); // Set the date to January 1st, 2014

Rest of the code continues below)********

 // initialize the lcd 
  lcd.init();
  
}


void loop()
{

//Send Day-of-Week
  lcd.backlight();
  lcd.setCursor(0,0);
  lcd.print(rtc.getDOWStr());
  lcd.print(" ");

  // Send date
  lcd.setCursor(0,0);
  lcd.print(rtc.getDateStr());

  // Send time
  lcd.setCursor(0,1);
  lcd.print(rtc.getTimeStr());

 // Wait one second before repeating :)
  delay (1000);  
  
}

Please see my attachment.

Day-of-week********
This is not showing. Instead it shows 01.01.2014

Overall Outcome I need now.
How can I code to show below on the LCD

JAN 1 2014 MON
12:00:00

For your first problem, you could do this:

const byte jan =1;
const byte feb =2;

etc.

But why bother? It's clear enough what's being passed to that function and you will do it infrequently.

As to the second, you will have to get the month and day numbers from the clock and write code that uses them to display the time. An array of month names and another of day names would help. Or you could do a bunch of if statements (not recommended).

Hi wildbill,

I'm sorry mate. thanks for the info. but I'm very bad at this. I don't know where to put your code. "const byte". I tried everything I could after googling. Nothing Seem to work. But after studying few tutorials I managed to identify rows and character places.

Below is my code and my output attached.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DS3231.h>

// Init the DS3231 using the hardware interface
DS3231  rtc(SDA, SCL);

// set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);


void setup()
{
 
  // Initialize the rtc object
  rtc.begin();
  lcd.begin(16, 2);
  lcd.clear();
  lcd.backlight();
  rtc.setDOW(SUNDAY);     // Set Day-of-Week to SUNDAY
  rtc.setTime(20, 36, 00);     // Set the time to 12:00:00 (24hr format)
  rtc.setDate(28, 2, 2021);   // Set the date to January 1st, 2014

  // initialize the lcd
  lcd.init();

}


void loop()
{

  // Send date
  lcd.setCursor(0, 0);
  lcd.print(rtc.getDateStr());

  // Send time
  lcd.setCursor(0, 1);
  lcd.print(rtc.getTimeStr());

  //Send Day-of-Week
  lcd.setCursor(9, 1);
  lcd.print(rtc.getDOWStr());

  // Wait one second before repeating :)
  delay (1000);

}

Where did you get the DS3231 library?

From chipKit library. Attached is the doc.

DS3231.pdf (111 KB)

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.