I want to display serial data to my I2C lcd

I am new to arduino and electronics. I was trying to build a automatic doser and found this project on internet.

Every thing is running ok, I just wanted to add a I2C lcd to see which of my pump is starting and what time does the RTC is reporting.

I have attached the codes and other details.

Help needed on:

Programming the arduino to enable I2C to display time, date and pump status. (as it prints in the serial monitor).

I am using :

Arduino Atmega 328p

DS1307 RTC

I2C lcd with PCF8574

I am powering 5 motors with IRFZ44N Mosfets.

Using a 12 vdc smps 10 amps for 6 motors and arduino

A help would be highly appreciated.

Project Link http://fishtankprojects.com/diy-aquarium-projects/arduino-controlled-dosing-pumps/

---------------*-------------------------
Code.

// Deven Rich 12-5-2013
// This project was built on the Arduino Uno - ATmega328P
// I would also like to give credit to Maurice Ribble for providing chunks of the RTC code
// This code sets up the DS1307 Real Time clock on the Arduino board to controll 3 dosing pumps
// The RTC keeps track of time, the code checks it and turns on the pumps at a specified time
// to dose your aquarium

#include <Wire.h>
#define DS1307_I2C_ADDRESS 0x68

////Convert normal decimal numbers to binary coded decimal.
byte decToBcd(byte val)
{
return ( (val/10*16) + (val%10) );
}

////Convert binary coded decimal to normal decimal numbers.
byte bcdToDec(byte val)
{
return ( (val/16*10) + (val%16) );
}

////Stops the clock, but it has the side effect of setting seconds to 0.
/void stopDs1307()
{
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.write(0);
Wire.writeWire.writeWire.write(0x80);
Wire.endTransmission();
}
/

////1) Sets date and time on the clock.
////2) Starts the clock.
////3) Sets hour mode to 24 hours.
void setDateDs1307(
byte second, ////0-59
byte minute, ////0-59
byte hour, ////1-23
byte dayOfWeek, ////1-7
byte dayOfMonth, ////1-28/29/30/31
byte month, ////1-12
byte year) ////0-99
{
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.write(0);
Wire.write(decToBcd(second)); ////0 to bit 7 starts the clock
Wire.write(decToBcd(minute));
Wire.write(decToBcd(hour)); ////If you want 12 hours (am/pm) you need to set
////bit 6 (also need to change getDateDs1307)
Wire.write(decToBcd(dayOfWeek));
Wire.write(decToBcd(dayOfMonth));
Wire.write(decToBcd(month));
Wire.write(decToBcd(year));
Wire.endTransmission();
}

////Reads date and time from the clock,
void getDateDs1307(
byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{

////Reset the register pointer.
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.write(0);
Wire.endTransmission();
Wire.requestFrom(DS1307_I2C_ADDRESS, 7);

////A few of these need masks because certain bits are control bits.
*second = bcdToDec(Wire.read() & 0x7f);
*minute = bcdToDec(Wire.read());
*hour = bcdToDec(Wire.read() & 0x3f); ////Need to change this for 12 hours (am/pm)
*dayOfWeek = bcdToDec(Wire.read());
*dayOfMonth = bcdToDec(Wire.read());
*month = bcdToDec(Wire.read());
*year = bcdToDec(Wire.read());
}

////Define pump pin outs.
int motorPin1 = 8; //Pump 1 – Flourish Excel
int motorPin2 = 9; //Pump 2 – Flourish Iron
int motorPin3 = 10; //Pump 3 – Flourish
int motorPin4 = 11; //Pump 4 – Flourish
int motorPin5 = 12; //Pump 5 – Flourish

int actled = 13; //Status Led

void setup() ////One time run at each execution.
{
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(motorPin3, OUTPUT);
pinMode(motorPin4, OUTPUT);
pinMode(motorPin5, OUTPUT);

pinMode(actled, OUTPUT);
Wire.begin();
Serial.begin(9600);

////Set date and time on the clock.
////You only need to run this the first time you setup your RTC.
////Set the correct value below and un comment it to run it.
/*
second = 00;
minute = 20;
hour = 17;
dayOfWeek = 2;
dayOfMonth = 1;
month = 5;
year = 18;
setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
*/

}

////Main programm loop.
void loop()
{
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;

////Serial Monitor Output.
getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
Serial.print("Date: ");
Serial.print(dayOfMonth, DEC);
Serial.print("/");
Serial.print(month, DEC);
Serial.print("/");
Serial.print(year, DEC);
Serial.println(" ");
Serial.print("Day of week: ");
Serial.print(dayOfWeek, DEC);
Serial.println(" ");
Serial.print("Time: ");
Serial.print(hour, DEC);
Serial.print(":");
Serial.print(minute, DEC);
Serial.print(":");
Serial.print(second, DEC);
Serial.println(" ");

delay(500);
analogWrite(actled, 255);
delay(500);

////Pump Operation
////Everyday: IRON

if((dayOfWeek !=7)&&(hour == 17)&&(minute == 31)&&(second == 10)){

////Start Iron pump 1.5ml
Serial.print("Iron Pump 1.5ml");
Serial.println("");
Serial.println("On");
analogWrite(motorPin1, 255);
delay(1500); // 1000 = aprox 1 ml
analogWrite(motorPin1, 0);
Serial.println("");
Serial.println("Off");

////Monday: kno3, kho2s4, pso4
if(dayOfWeek == 2){

////Start kno3 7.5ml
Serial.print(" Flourish Excel Pump 7.5ml");
Serial.println("");
Serial.println("On");
analogWrite(motorPin2, 255);
delay(7500); // 1000 = aprox 1 ml
analogWrite(motorPin2, 0);
Serial.println("");
Serial.println("Off");

////Start kho2s4 1.5ml
Serial.print("kho2s4 Pump 1,5ml");
Serial.println("");
Serial.println("On");
analogWrite(motorPin3, 255);
delay(1500); // 1000 = aprox 1 ml
analogWrite(motorPin3, 0);
Serial.println("");
Serial.println(" Off");

////Start kho2s4 1.5ml
Serial.print("kho2s4 Pump 1,5ml");
Serial.println("");
Serial.println("On");
analogWrite(motorPin4, 255);
delay(1500); // 1000 = aprox 1 ml
analogWrite(motorPin4, 0);
Serial.println("");
Serial.println(" Off");

}

////TUESDAY
if(dayOfWeek == 2){

////Start Micro pump
Serial.print(" Micro Pump 1,5ml");
Serial.println(" ");
Serial.println("On");
analogWrite(motorPin3, 255);
delay(1500); // 1000 = aprox 1 ml
analogWrite(motorPin3, 0);
Serial.println("");
Serial.println("Off");

}

////Wednesday: kno3, kho2s4, pso4
if(dayOfWeek == 3){

////Start kno3 7.5ml
Serial.print(" Flourish Excel Pump 7.5ml");
Serial.println("");
Serial.println("On");
analogWrite(motorPin2, 255);
delay(7500); // 1000 = aprox 1 ml
analogWrite(motorPin2, 0);
Serial.println("");
Serial.println("Off");

////Start kho2s4 1.5ml
Serial.print("kho2s4 Pump 1,5ml");
Serial.println("");
Serial.println("On");
analogWrite(motorPin3, 255);
delay(1500); // 1000 = aprox 1 ml
analogWrite(motorPin3, 0);
Serial.println("");
Serial.println(" Off");

////Start kho2s4 1.5ml
Serial.print("kho2s4 Pump 1,5ml");
Serial.println("");
Serial.println("On");
analogWrite(motorPin4, 255);
delay(1500); // 1000 = aprox 1 ml
analogWrite(motorPin4, 0);
Serial.println("");
Serial.println(" Off");

}

////Thursday
if(dayOfWeek == 4){

////Start Micro pump
Serial.print(" Micro Pump 1,5ml");
Serial.println(" ");
Serial.println("On");
analogWrite(motorPin3, 255);
delay(1500); // 1000 = aprox 1 ml
analogWrite(motorPin3, 0);
Serial.println("");
Serial.println("Off");

}

////Friday: kno3, kho2s4, pso4
if(dayOfWeek == 5){

////Start kno3 7.5ml
Serial.print(" Flourish Excel Pump 7.5ml");
Serial.println("");
Serial.println("On");
analogWrite(motorPin2, 255);
delay(7500); // 1000 = aprox 1 ml
analogWrite(motorPin2, 0);
Serial.println("");
Serial.println("Off");

////Start kho2s4 1.5ml
Serial.print("kho2s4 Pump 1,5ml");
Serial.println("");
Serial.println("On");
analogWrite(motorPin3, 255);
delay(1500); // 1000 = aprox 1 ml
analogWrite(motorPin3, 0);
Serial.println("");
Serial.println(" Off");

////Start kho2s4 1.5ml
Serial.print("kho2s4 Pump 1,5ml");
Serial.println("");
Serial.println("On");
analogWrite(motorPin4, 255);
delay(1500); // 1000 = aprox 1 ml
analogWrite(motorPin4, 0);
Serial.println("");
Serial.println(" Off");

}

////Saturday
if(dayOfWeek == 6){

////Start Micro pump
Serial.print(" Micro Pump 1,5ml");
Serial.println(" ");
Serial.println("On");
analogWrite(motorPin3, 255);
delay(1500); // 1000 = aprox 1 ml
analogWrite(motorPin3, 0);
Serial.println("");
Serial.println("Off");

}
}

else{

Serial.println ("Pump Status:Off");

////Backup Close Pump
analogWrite(motorPin1, 0);
analogWrite(motorPin2, 0);
analogWrite(motorPin3, 0);
analogWrite(motorPin4, 0);
analogWrite(actled, 0);

}

// delay(1000);

}

Every thing is running ok, I just wanted to add a I2C lcd

The difference between sending data to serial and data to LCD is

Serial.print(data):
lcd.print(data):

any example included with the lCD library will show you that.

Thanks for the quick reply.

How do I choose library for this module, it says " commonly used HD44780 is built in this 1602 lcd module".

I currently have this library with me (file attached).

LiquidCrystal_I2C.zip (19.7 KB)

That library is as it says - for use with i2c bus. You need to know if your LCD is for I2C. You can tell by the four-pin connection and the I2C converter is usually a piggy back. If you don't have this, you need the standard Liquid Crystal library, which I think is already included in the IDE.

Yes it is a i2c lcd.

Read reply #1 again, and check examples included with the library.