Rtc ds1307 is going nuts or circuit might be damaged

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Rtc ds1307 is going nuts or circuit might be damaged

Postby bioreefdude » Sun Apr 15, 2012 6:07 pm

sorry for posting whole sketch but i am a newbie and im trying to learn but i just can get it to verify and compile i believe the sketch might be out of day comparing to arduino software 1.0 .also ty in advance please help me
Code: Select all
/*******************************************************************************
*
* Purpose: Aquarium Controller
*
*
* Arduino Version 022
*
*
*
* Originally written by Martin, liquidartstattoos@gmail.com
*
* Initial version 1.0   5.21.2011
*
*  Changes      Date              Details
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or banned FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
*******************************************************************************/
#include "Wire.h"
#define DS1307_I2C_ADDRESS 0x68 //set rtc
#include <LiquidCrystal.h> // initialize the library with the numbers of the interface pins
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 9 //Define the pin of the DS18B20



int moon = 2;              // moon light
int fan = 49;            // Fan power relay connected to analog pin 0
int heater = 31;         // heater

int iBlueIntensity;   //declare the integer of blue intensity
float fBlueIntensity;   //declare the floating point version of blue intensity

// RTC variables
byte second, rtcMins, oldMins, rtcHrs, oldHrs, dayOfWeek, dayOfMonth, month, year, psecond; 

LiquidCrystal lcd(22,23,24,25,26,27);
//LiquidCrystal lcd(12,13,4,5,6,7);   // typically 8, 9, 4, 5, 6, 7


//  Set up the custom fish icon
byte newChar[8] = {
   B00000,
   B00000,
   B10001,
   B11011,
   B11111,
   B11111,
   B11001,
   B10000
};

byte newChar1[8] = {
   B00001,
   B00010,
   B11101,
   B11010,
   B11111,
   B11110,
   B11100,
   B00000
};
byte newChar2[8] = {
   B00000,
   B00000,
   B10001,
   B11011,
   B11111,
   B11111,
   B10011,
   B00001
};
byte newChar3[8] = {
   B10000,
   B01000,
   B10111,
   B01011,
   B11111,
   B01111,
   B00111,
   B00000
};
byte newChar4[8] = {
   B00111,
   B01110,
   B11100,
   B11000,
   B11000,
   B11100,
   B01110,
   B00111
};
byte newChar5[8] = {
   B01010,
   B10000,
   B00010,
   B01001,
   B00100,
   B10000,
   B00100,
   B10001
};
byte newChar6[8] = {
   B01010,
   B00100,
   B00001,
   B11011,
   B00011,
   B00001,
   B01000,
   B10010
};
byte newChar7[8] = {
   B10010,
   B00100,
   B10000,
   B11011,
   B11000,
   B10000,
   B00010,
   B01001
};

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);


// LED variables (Change to match your needs)
byte bluePins[]      =  {3,4};  // PWM pins for blues - if you plan to use the photo stagger, please place the pins in the order you would like them to start
byte whitePins[]     =  {5,6};       // PWM pins for whites - if you plan to use the photo stagger, please place the pins in the order you would like them to start

byte blueChannels    =        2;    // how many PWMs for blues (count from above)
byte whiteChannels   =        2;    // how many PWMs for whites (count from above)

int photoStagger     =        0;    //  offset for east - west delay on each channel in minutes
int startOffset      =        0;    // offset for start times in minutes - used if you want to change the start and finish time of the cycle.  i.e move it to a later time in the day
int colourOffset     =        30;   // offset for whites to start after blues start in minutes

byte blueLevel[]       =      {255,255};  // max intensity for Blue LED's
byte whiteLevel[]      =      {255,255};  // max intensity for White LED's


// Month Data for Start, Stop, Photo Period and Fade (based off of actual times, best not to change)

int daysInMonth[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};  //Days in each month

int minMinuteStart[12] = {310, 332, 348, 360, 372, 386, 394, 387, 364, 334, 307, 298}; //Minimum start times in each month
int maxMinuteStart[12] = {331, 347, 360, 372, 386, 394, 388, 365, 335, 308, 298, 309}; //Max start time in each month

int minMinuteFade[12] = {350, 342, 321, 291, 226, 173, 146, 110, 122, 139, 217, 282}; //Minimum fade time in each month
int maxMinuteFade[12] = {342, 321, 291, 226, 173, 146, 110, 122, 139, 217, 282, 350}; //Max fade time in each month

int minMinuteStop[12] = {1122, 1120, 1102, 1073, 1047, 1034, 1038, 1050, 1062, 1071, 1085, 1105}; //minimum stop times each month
int maxMinuteStop[12] = {1121, 1103, 1074, 1048, 1034, 1038, 1050, 1061, 1071, 1084, 1104, 1121}; //maximum stop times each month


// Weather variables

int weather = 1;  // 0 off, 1 on

int clearDays[12] = {15, 12, 20, 23, 28, 37, 43, 48, 51, 41, 29, 23};
int cloudyDays[12] = {60, 61, 62, 60, 64, 63, 68, 66, 63, 54, 52, 53}; 

float clearDay = 0.25; // Max cloud value on clear day (percent of max string value)
float cloudyDay = 0.75; // Max cloud value on cloudy day (percent of max string value)
float normalDay = 0.5; // Max cloud value on normal day (percent of max string value)

byte value;
int day, fadeOn, fadeOff, time, pause, count, cloud;
long start, finish;


// Other variables - Do not need to be changed.

int minCounter;  // counter that resets at midnight
long secCounter;  // counter for seconds - needed for weather
int fadeDuration;  // minutes to fade - calculated by map above
int ledStartMins;  // minute to start led’s - calculated by map above
int ledStopMins;  // minute to stop led’s - calculated by map above
byte blueMax[] = {0};      // used for over temp protection
byte whiteMax[] = {0};    // used for over temp protection
byte valueBlue[] = {0};  // value for clouds
byte valueWhite[] = {0};   // value for clouds

/****** LED Functions ******/
/***************************/

//function to set LED brightness according to time of day

byte setLed(
int mins,    // current time in minutes
byte ledPin,  // pin for this channel of LEDs
int start,   // start time for this channel of LEDs
int fade,    // fade duration for this channel of LEDs
int stop,    // stop time for this channel of LEDs
byte ledMax,  // max value for this channel of LEDs
long begin,   // time cloud cycle begins in seconds
long secs,    // current time in seconds
int on,       // time for cloud to fade on in seconds
int off,      // time for cloud to fade off in seconds
long time,     // time of cloud
byte value    // value for cloud


// max value for this channel
)  {
  byte ledVal = 0;   
  if (mins <= start || mins >= stop)  //this is when the LEDs are off, thus ledVal is 255;
  {
    ledVal = 0;
  }
  if (mins > start && mins <= start + fade) //this is sunrise 
  {
    ledVal =  map(mins, start, start + fade, 0, ledMax);
  }
  if (mins > start + fade && mins < stop - fade && weather == 1)
  {
    ledVal = ledMax;
    if (count == 1){
      if (secs >= begin && secs < begin + fadeOn)
      {
        ledVal = map(secs, begin, begin + on, ledMax, value);
      }
      if (secs >= begin + on && secs < begin + on + time)
      {
        ledVal = value;
      }
      if (secs >= begin + on + time && secs < begin + on + time + off)
      { 
        ledVal = map(secs, begin + on + time, begin + on + time + off, value, ledMax);
      }
      if (secs >= begin + on + time + off)
      {
        ledVal = ledMax;
      }
      if (secs >= finish)
      {
        count = 0;
      }
    } 
  }
  if (mins > start + fade && mins < stop - fade && weather == 0)
  {
    ledVal = ledMax;
  }
  if (mins < stop && mins >= stop - fade)  //this is the sunset
  {
    ledVal = map(mins, stop - fade, stop, ledMax, 0);
  }
 
  analogWrite(ledPin, ledVal);
  return ledVal;   
}
/***** RTC Functions *******/
/***************************/
// 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) );
}

// 1) Sets the date and time on the ds1307
// 2) Starts the clock
// 3) Sets hour mode to 24 hour clock
// Assumes you're passing in valid numbers
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.send(0);
  Wire.send(decToBcd(second)); // 0 to bit 7 starts the clock
  Wire.send(decToBcd(minute));
  Wire.send(decToBcd(hour));   // If you want 12 hour am/pm you need to set
  // bit 6 (also need to change readDateDs1307)
  Wire.send(decToBcd(dayOfWeek));
  Wire.send(decToBcd(dayOfMonth));
  Wire.send(decToBcd(month));
  Wire.send(decToBcd(year));
  Wire.endTransmission();
}

// Gets the date and time from the ds1307
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.send(0);
  Wire.endTransmission();

  Wire.requestFrom(DS1307_I2C_ADDRESS, 7);

  // A few of these need masks because certain bits are control bits
  *second = bcdToDec(Wire.receive() & 0x7f);
  *minute = bcdToDec(Wire.receive());
  *hour = bcdToDec(Wire.receive() & 0x3f); // Need to change this if 12 hour am/pm
  *dayOfWeek = bcdToDec(Wire.receive());
  *dayOfMonth = bcdToDec(Wire.receive());
  *month = bcdToDec(Wire.receive());
  *year = bcdToDec(Wire.receive());
}
int moonPhase(int moonYear, int moonMonth, int moonDay)
{
  int dayFromYear, dayFromMonth;
  double julianDay;
  int phase;

  if (moonMonth < 3)         //keep the month before march
  {
    moonYear--;         //take away a year
    moonMonth += 12;      //add an extra 12 months (the year taken away from before)
  }
  ++moonMonth;
  dayFromYear = 365.25 * moonYear; //get days from current year
  dayFromMonth = 30.6 * moonMonth; //get number of days from the current month
  julianDay = dayFromYear + dayFromMonth + moonDay - 694039.09; //add them all 
  julianDay /= 29.53;      //divide by the length of lunar cycle
  phase = julianDay;      //take integer part
  julianDay -= phase;      //get rid of the int part
  phase = julianDay*8 + 0.5;   //get it between 0-8 and round it by adding .5
  phase = phase & 7;      //get a number between 1-7
  return phase;       //1 == new moon, 4 == full moon
}


/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||  D E F I N E  :  O N E S E C O N D |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/



void onesecond() //function that runs once per second while program is running
{
  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
  lcd.setCursor(0, 0);
  if(hour>0)
  {
    if(hour<=12)
    {
      lcd.print(hour, DEC);
    }
    else
    {
      lcd.print(hour-12, DEC);
    }
  }
  else
  {
    lcd.print("12");
  }
  lcd.print(":");
  if (minute < 10) {
    lcd.print("0");
  }
  lcd.print(minute, DEC);
  //lcd.print(":");
  //if (second < 10) {
  //  lcd.print("0");
  //}
  //lcd.print(second, DEC);
  if(hour<12)
  {
    lcd.print("am");
  }
  else
  {
    lcd.print("pm");
  }
  lcd.print(" ");
  delay(1000);
}



void setup()  { 

  pinMode(heater, OUTPUT);      //Set Heater Relay
  pinMode(fan, OUTPUT);      // Set analog pin 0 as a output
  sensors.begin();             // Start up the DS18B20 Temp library
 
  // init I2C   
  Serial.begin(9600);
  Wire.begin();
  randomSeed(analogRead(1));
 
    /*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||  S E T U P - D I S P L A Y |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/



  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  Wire.begin();

  // Change these values to what you want to set your clock to.
  // You probably only want to set your clock once and then remove
  // the setDateDs1307 call.
  second = 00;
  minute = 50;
  hour = 6;
  dayOfWeek = 0;  // Sunday is 0
  dayOfMonth = 22;
  month = 5;
  year = 11;
 
  setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);

  lcd.createChar(0, newChar);
  lcd.createChar(1, newChar1);
  lcd.createChar(2, newChar2);
  lcd.createChar(3, newChar3);
  lcd.createChar(4, newChar4);
  lcd.createChar(5, newChar5);
  lcd.createChar(6, newChar6);
  lcd.createChar(7, newChar7);
  lcd.begin(20, 4); // set up the LCD's number of rows and columns:
   // Print a message to the LCD.
  lcd.setCursor(3, 0);
  lcd.write(0);
  lcd.write(1);
  lcd.setCursor(6, 0);// set the cursor to column 4, line 0
  lcd.print("SaltyDog's");
  lcd.setCursor(15, 0);
  lcd.write(3);
  lcd.write(2);
  lcd.setCursor(3, 2);
  lcd.print("ReefController");
  delay(5000);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.write(0);
  lcd.write(1);
  lcd.setCursor(3, 0);// set the cursor to column 0, line 0
  lcd.print("My Marine Tank");
  lcd.setCursor(18, 0);
  lcd.write(3);
  lcd.write(2);
  lcd.setCursor(11, 1);
  lcd.print("L: ");
  lcd.setCursor(0, 1);
  lcd.print("W: ");
  lcd.setCursor(1, 2);
  lcd.print("Heater: ");
  lcd.setCursor(12, 2);
  lcd.print("Fans: ");

}

/***** Main Loop ***********/
/***************************/
void loop(){
    onesecond();

         
  float fSecond, fHour, fMinute;      //turn the times read from the RTC into float for math ops
  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year; //declare variables to hold the times

  getDateDs1307(&second, &rtcMins, &rtcHrs, &dayOfWeek, &dayOfMonth, &month, &year);

  fSecond = (float) second;         //sets fSecond as the float version of the integer second from the RTC
  fMinute = (float) minute;         //same as above, but for the minute
  fHour = (float) hour;            //ditto, but for the hour
  int lunarCycle = moonPhase(year, month, dayOfMonth); //get a value for the lunar cycle
  //--------MOON LED SETUP----------//


  if ( ((hour == 7) && (minute < 00)) || (hour < 7))//Off at 730am.
  {
    fBlueIntensity = 255;      //...then we want the blue LED at the max brightness (255)
  }

  else if (hour > 17) //&& (hour < 19))             // On at 5pm
  {   
    fBlueIntensity = 255 * (((fHour - 19) + (fMinute / 59)) / 7);   //...set intensity out of 255 based on time since 17:00
  }
  else
  {
    fBlueIntensity = 0;
  }

//---------account for the moon cycle with the blue LEDs---------//

  if (lunarCycle == 0)      //new moon
  {
    fBlueIntensity /= 2;
  }
  if ((lunarCycle == 1) || (lunarCycle == 7))   //cresent
  {
    fBlueIntensity /= 1.75 ;
  }
  if ((lunarCycle == 2) || (lunarCycle == 6))   //half moon
  {
   fBlueIntensity /= 1.5;
  }
  if ((lunarCycle == 3) || (lunarCycle == 5))   //gibbous
  {
    fBlueIntensity /= 1.25;
  }

  //full moon is full intensity


  //----------FLOAT TO INT-------------//
  iBlueIntensity = (int) fBlueIntensity;



  //---prepare the intensities to be written to pin----//

  if (iBlueIntensity < 0) //if the blue intensity is less then 0, set it to 0
  {
    iBlueIntensity = 0;
  }



  //------------and finally, we write the values of the lights to the pins--------------//

  analogWrite(moon, iBlueIntensity);
  delay(1000);


  minCounter = rtcHrs * 60 + rtcMins;
  secCounter = (long)minCounter * 60 + (long)second;

  // Start and Stop Times, Fade Time Functions

  ledStartMins = map(dayOfMonth, 1, daysInMonth[month-1], minMinuteStart[month-1], maxMinuteStart[month-1]) + startOffset; //LED Start time
  fadeDuration = map(dayOfMonth, 1, daysInMonth[month-1], minMinuteFade[month-1], maxMinuteFade[month-1]); //LED Fade time
  ledStopMins = map(dayOfMonth, 1, daysInMonth[month-1], minMinuteStop[month-1], maxMinuteStop[month-1]) + startOffset; // LED Stop time

  // Weather Functions

  if (minCounter == 0 && second == 0 || day == 0){
    {
      day = random(1,101);
    }
  }   
  if (count == 0){
    if (day <= clearDays[month-1]) // Clear Day
    {
      int t;
      for (t = 0; t < blueChannels; t++)
      {   
        valueBlue[t] = random(blueLevel[t]*clearDay,blueLevel[t]);
      }
      for (t = 0; t < whiteChannels; t++)
      {
        valueWhite[t] = random(whiteLevel[t]*clearDay,whiteLevel[t]);
      }
    }
    if (day > clearDays[month-1] && day <= cloudyDays[month-1]) // Cloudy Day 
    {
      int t;
      for (t = 0; t < blueChannels; t++)
      {   
        valueBlue[t] = random(blueLevel[t]*normalDay,blueLevel[t]*cloudyDay);
      }
      for (t = 0; t < whiteChannels; t++)
      {
        valueWhite[t] = random(whiteLevel[t]*normalDay,whiteLevel[t]*cloudyDay);
      }
    } 
    if (day > cloudyDays[month-1]) // Normal Day 
    {
      int t;
      for (t = 0; t < blueChannels; t++)
      {   
        valueBlue[t] = random(blueLevel[t]*normalDay,blueLevel[t]);
      }
      for (t = 0; t < whiteChannels; t++)
      {
        valueWhite[t] = random(whiteLevel[t]*normalDay,whiteLevel[t]);
      }
    }   

    fadeOn = random(5,8); // Fade on of cloud in seconds
    fadeOff = random(5,8); // Fade off of cloud in seconds
    time = random(30,300); // Length of cloud in seconds
    pause = random(5,300); // Time between clouds in seconds
    start = secCounter; // Sets cycle start time
    finish = start + fadeOn + time + fadeOff + pause; // Sets cylce finish time in seconds
    count = 1;
  }
 

   
   
  int t;
      for (t = 0; t < blueChannels; t++)
      {   
        blueMax[t] = blueLevel[t];
      }
      for (t = 0; t < whiteChannels; t++)
      {
        whiteMax[t] = whiteLevel[t];
      }
       

  // LED State and Serial Print
  if (psecond != second){
    psecond = second;
    update_leds();
  }
  delay(50);
}


void update_leds( void ){
  int i;
  byte ledVal;
  for (i = 0; i < blueChannels; i++){
    ledVal = setLed(minCounter, bluePins[i], ledStartMins + (photoStagger * (i+1)), fadeDuration, ledStopMins - (photoStagger * (i+1)), blueMax[i], start, secCounter, fadeOn, fadeOff, time, valueBlue[i]);
  }
  for (i = 0; i < whiteChannels; i++){
    ledVal = setLed(minCounter, whitePins[i], ledStartMins + colourOffset + (photoStagger * (i+1)), fadeDuration, ledStopMins - colourOffset - (photoStagger * (i+1)), whiteMax[i], start, secCounter, fadeOn, fadeOff, time, valueWhite[i]);   
  }
// DS18B20 display
sensors.requestTemperatures(); // Send the command to get temperatures
delay(250);

  lcd.setCursor(13, 1);
 
float temp1=0, temp2=0;

  //lcd.print("Led Temp:");
  temp1=sensors.getTempFByIndex(1);
  lcd.print(sensors.getTempFByIndex(1));
  lcd.print((char)223);
  lcd.print("F");

  lcd.setCursor(2, 1);
  //lcd.print("Tank Temp: ");
  temp2=sensors.getTempFByIndex(0);
  lcd.print(sensors.getTempFByIndex(0));
  lcd.print((char)223);
  lcd.print("F");

if ( (temp1) > 98)
    {
    digitalWrite(fan, HIGH);
    lcd.setCursor(17,2);
    lcd.print("On");
    }
else if ( (temp1) < 92)
    {
    digitalWrite(fan, LOW);
    lcd.setCursor(17,2);
    lcd.print("Off");
    }

if ( (temp2) < 78 )
    {
    digitalWrite(heater, HIGH);
    lcd.setCursor(8,2);
    lcd.print("On");
    }
else if ( (temp2) > 82 )
    {
    digitalWrite(heater, LOW);
    lcd.setCursor(8,2);
    lcd.print("Off");
    }   
//  lcd.print(sensors.getTempCByIndex(0));
//  lcd.print((char)223);
//  lcd.print("C");
 
  //delay(500); 

i get all these error messages

sketch_apr15c:329: error: 'class TwoWire' has no member named 'send'

As of Arduino 1.0, the Wire.send() function was renamed to Wire.write() for consistency with other libraries.

sketch_apr15c.cpp: In function 'void getDateDs1307(byte*, byte*, byte*, byte*, byte*, byte*, byte*)':
sketch_apr15c:344: error: 'class TwoWire' has no member named 'send'

As of Arduino 1.0, the Wire.send() function was renamed to Wire.write() for consistency with other libraries.

sketch_apr15c:350: error: 'class TwoWire' has no member named 'receive'

As of Arduino 1.0, the Wire.receive() function was renamed to Wire.read() for consistency with other libraries.

sketch_apr15c:351: error: 'class TwoWire' has no member named 'receive'

As of Arduino 1.0, the Wire.receive() function was renamed to Wire.read() for consistency with other libraries.

sketch_apr15c:352: error: 'class TwoWire' has no member named 'receive'

As of Arduino 1.0, the Wire.receive() function was renamed to Wire.read() for consistency with other libraries.

sketch_apr15c:353: error: 'class TwoWire' has no member named 'receive'

As of Arduino 1.0, the Wire.receive() function was renamed to Wire.read() for consistency with other libraries.

sketch_apr15c:354: error: 'class TwoWire' has no member named 'receive'

As of Arduino 1.0, the Wire.receive() function was renamed to Wire.read() for consistency with other libraries.

sketch_apr15c:355: error: 'class TwoWire' has no member named 'receive'

As of Arduino 1.0, the Wire.receive() function was renamed to Wire.read() for consistency with other libraries.

sketch_apr15c:356: error: 'class TwoWire' has no member named 'receive'

As of Arduino 1.0, the Wire.receive() function was renamed to Wire.read() for consistency with other libraries.

sketch_apr15c.cpp: In function 'void setup()':
sketch_apr15c:472: error: call of overloaded 'write(int)' is ambiguous
D:\New Folder (2)\arduino-1.0\libraries\LiquidCrystal1/LiquidCrystal.h:82: note: candidates are: virtual size_t LiquidCrystal::write(uint8_t)
D:\New Folder (2)\arduino-1.0\hardware\arduino\cores\arduino/Print.h:49: note: size_t Print::write(const char*)
sketch_apr15c:484: error: call of overloaded 'write(int)' is ambiguous
D:\New Folder (2)\arduino-1.0\libraries\LiquidCrystal1/LiquidCrystal.h:82: note: candidates are: virtual size_t LiquidCrystal::write(uint8_t)
D:\New Folder (2)\arduino-1.0\hardware\arduino\cores\arduino/Print.h:49: note: size_t Print::write(const char*)
Last edited by bioreefdude on Thu May 03, 2012 10:09 pm, edited 1 time in total.
bioreefdude
 
Posts: 15
Joined: Thu Apr 12, 2012 8:01 pm

Re: i cant get this sketch to veriify

Postby franklin97355 » Sun Apr 15, 2012 8:08 pm

Have you fixed the errors you got with explainations like the wire.write rather than wire.send? That would be the first step.
User avatar
franklin97355
 
Posts: 1706
Joined: Mon Apr 21, 2008 1:33 pm

Re: i cant get this sketch to veriify

Postby bioreefdude » Sun Apr 15, 2012 9:42 pm

franklin97355 wrote:Have you fixed the errors you got with explainations like the wire.write rather than wire.send? That would be the first step.

hey thanks for pointing me in the rite direction ive done that now im geting this error message :

weather.cpp: In function 'void getDateDs1307()':
weather:253: error: call of overloaded 'write(int)' is ambiguous
D:\New Folder (2)\arduino-1.0\libraries\Wire1/Wire.h:55: note: candidates are: virtual size_t TwoWire::write(uint8_t)
D:\New Folder (2)\arduino-1.0\hardware\arduino\cores\arduino/Print.h:49: note: size_t Print::write(const char*)
weather:253: error: expected `;' before ')' token
weather.cpp: In function 'void serialCommands()':
weather:970: error: call of overloaded 'write(int)' is ambiguous
D:\New Folder (2)\arduino-1.0\libraries\Wire1/Wire.h:55: note: candidates are: virtual size_t TwoWire::write(uint8_t)
D:\New Folder (2)\arduino-1.0\hardware\arduino\cores\arduino/Print.h:49: note: size_t Print::write(const char*)
weather:970: error: expected `;' before ')' token
weather.cpp: In function 'void setDateDs1307()':
#################################################################

now i think it has to do with this section
Code: Select all
          }   
          Wire.endTransmission();
          getDateDs1307();
          printDateTime();
          Serial.println(": RTC1307 Initialized Memory");
        }
        else if (command == 50) {      //If command = "2" RTC1307 Memory Dump
          getDateDs1307();
          printDateTime();
          Serial.println(": RTC 1307 Dump Begin");
          Wire.beginTransmission(DS1307_I2C_ADDRESS);
          Wire.write(0x00));
          Wire.endTransmission();
          Wire.requestFrom(DS1307_I2C_ADDRESS, 64);
          for (i = 1; i <= 64; i++) {
             test = Wire.read();
             Serial.print(i);
             Serial.print(":");
             Serial.println(test, DEC);
          }
          Serial.println(" RTC1307 Dump end");
        }
bioreefdude
 
Posts: 15
Joined: Thu Apr 12, 2012 8:01 pm

Re: i cant get this sketch to veriify

Postby TommyFive » Sun Apr 15, 2012 11:40 pm

bioreefdude wrote:weather.cpp: In function 'void getDateDs1307()':
weather:253: error: call of overloaded 'write(int)' is ambiguous

Call (byte) before the hex value. 0x00 can be interpreted many different ways, so specifying it as a byte would solve this.

It would read as:
Code: Select all
  Wire.write((byte)0x00);
TommyFive
 
Posts: 5
Joined: Sun Apr 15, 2012 9:36 pm

Re: i cant get this sketch to veriify

Postby bioreefdude » Sun Apr 15, 2012 11:59 pm

TommyFive wrote:
bioreefdude wrote:weather.cpp: In function 'void getDateDs1307()':
weather:253: error: call of overloaded 'write(int)' is ambiguous

Call (byte) before the hex value. 0x00 can be interpreted many different ways, so specifying it as a byte would solve this.

It would read as:
Code: Select all
  Wire.write((byte)0x00);


homeboy u rock!yes lol it verified lol im happy
yes !!!! cant wait to get my controller up and running
bioreefdude
 
Posts: 15
Joined: Thu Apr 12, 2012 8:01 pm

Re: i cant get this sketch to veriify

Postby TommyFive » Mon Apr 16, 2012 12:26 am

bioreefdude wrote:
TommyFive wrote:
bioreefdude wrote:weather.cpp: In function 'void getDateDs1307()':
weather:253: error: call of overloaded 'write(int)' is ambiguous

Call (byte) before the hex value. 0x00 can be interpreted many different ways, so specifying it as a byte would solve this.

It would read as:
Code: Select all
  Wire.write((byte)0x00);


homeboy u rock!yes lol it verified lol im happy
yes !!!! cant wait to get my controller up and running

Compiled code is only the first step - hopefully it actually works once it gets to the hardware! Glad I could help.
TommyFive
 
Posts: 5
Joined: Sun Apr 15, 2012 9:36 pm

Re: i cant get this sketch to veriify

Postby bioreefdude » Mon Apr 16, 2012 1:00 am

[/quote]
Compiled code is only the first step - hopefully it actually works once it gets to the hardware! Glad I could help.[/quote]
well we will see and with the great forum and ppl like urself i feel as if i will get thru it fine
bioreefdude
 
Posts: 15
Joined: Thu Apr 12, 2012 8:01 pm

Re: i cant get this sketch to veriify

Postby bioreefdude » Wed May 02, 2012 7:33 pm

bioreefdude wrote:

Compiled code is only the first step - hopefully it actually works once it gets to the hardware! Glad I could help.[/quote]
well we will see and with the great forum and ppl like urself i feel as if i will get thru it fine[/quote]
:( i got my arduino mega2560 and im having the biggest problem getting my rtc ds1307 to show time or sum kind of valid response .i realized i didnt have it connect to power lol today and thought that would fix the problem but it didnt . ok so i have sda =pin 20
scl=pin 21 vcc =5v gnd=ground . now my problem is even with or without ds1307 in place only date and time i get is 45:165:32 and date 165/165/165 .Please help and no movement
bioreefdude
 
Posts: 15
Joined: Thu Apr 12, 2012 8:01 pm

Re: i cant get this sketch to veriify

Postby adafruit_support_bill » Thu May 03, 2012 4:45 am

Have you run the RTC with the example code in the tutorial?
Test with that first to make sure that the module is working properly.
User avatar
adafruit_support_bill
 
Posts: 16083
Joined: Sat Feb 07, 2009 9:11 am

Re: i cant get this sketch to veriify

Postby bioreefdude » Thu May 03, 2012 8:47 pm

adafruit_support wrote:Have you run the RTC with the example code in the tutorial?
Test with that first to make sure that the module is working properly.


well i ran the test sketch and on my serial monitor all i get is this:

¤ ƒ4¬Ê+ÐCB¢,!ëS9ùRŒÎ ˆ
¡Ö†M  ä#çû5£±Ë@DÂæä"¸[M«BWb€A A©ä

:O Please help idk if its my arduino freaking out or my rtc module
bioreefdude
 
Posts: 15
Joined: Thu Apr 12, 2012 8:01 pm

Re: Rtc ds1307 is going nuts or circuit might be damaged

Postby adafruit_support_bill » Fri May 04, 2012 4:40 am

well i ran the test sketch and on my serial monitor all i get is this:

¤ ƒ4¬Ê+ÐCB¢,!ëS9ùRŒÎ ˆ
¡Ö†M ä#çû5£±Ë@DÂæä"¸[M«BWb€A A©ä

That is a baud-rate mismatch. Make sure that your serial monitor is set to the same baud-rate as the Serial.begin() in the sketch.
User avatar
adafruit_support_bill
 
Posts: 16083
Joined: Sat Feb 07, 2009 9:11 am

Re: Rtc ds1307 is going nuts or circuit might be damaged

Postby CharlieD » Fri May 04, 2012 1:09 pm

What have you done with Pin '3' of the RTC ?? You cannot leave it floating - either connect a backup battery, or connect it to +v

Charles
CharlieD
 
Posts: 25
Joined: Thu Mar 11, 2010 1:14 pm
Location: Natal Midlands, South Africa

Re: Rtc ds1307 is going nuts or circuit might be damaged

Postby bioreefdude » Fri May 04, 2012 5:50 pm

CharlieD wrote:What have you done with Pin '3' of the RTC ?? You cannot leave it floating - either connect a backup battery, or connect it to +v

Charles

i bought the DS1307 Real Time Clock breakout board kit w/ backup battery .im starting to think my arduino mega2560 is not working correctly now that i have the proper baud rate i get :

2000/0/0 0:0:0
since midnight 1/1/1970 = 2313941504s = 26781d
now + 7d + 30s: 2043/5/6 17:32:14

2000/0/0 0:0:0
since midnight 1/1/1970 = 2313941504s = 26781d
now + 7d + 30s: 2043/5/6 17:32:14

2000/0/0 0:0:0
since midnight 1/1/1970 = 2313941504s = 26781d
now + 7d + 30s: 2043/5/6 17:32:14

2000/0/0 0:0:0
since midnight 1/1/1970 = 2313941504s = 26781d
now + 7d + 30s: 2043/5/6 17:32:14

but also when i try to hook up my temp sensor ds18b20 and run a test sketch i get :

Requesting temperatures...DONE
Temp C: 0.00 Temp F: 32.00
Requesting temperatures...DONE
Temp C: 0.00 Temp F: 32.00
Requesting temperatures...DONE
Temp C: 0.00 Temp F: 32.00
Requesting temperatures...DONE
Temp C: 0.00 Temp F: 32.00
Requesting temperatures...DONE
Temp C: 0.00 Temp F: 32.00
Requesting temperatures...DONE
Temp C: 0.00 Temp F: 32.00
Requesting temperatures...DONE
Temp C: 0.00 Temp F: 32.00
Requesting temperatures...DONE
Temp C: 0.00 Temp F: 32.00
Requesting temperatures...DONE
Temp C: 0.00 Temp F: 32.00
Requesting temperatures...DONE
Temp C: 0.00 Temp F: 32.00
Requesting temperatures...DONE
Temp C: 0.00 Temp F: 32.00
Requesting temperatures...DONE
Temp C: 0.00 Temp F: 32.00
Requesting temperatures...DONE
Temp C: 0.00 Temp F: 32.00
Requesting temperatures...DONE
Temp C: 0.00 Temp F: 32.00
Requesting temperatures...DONE
Temp C: 0.00 Temp F: 32.00
Requesting temperatures...DONE
now the fact about it is i followed the tutorial for temp sensor and tested it using my multimeter is my broad a piece of banned or do i suck
bioreefdude
 
Posts: 15
Joined: Thu Apr 12, 2012 8:01 pm

Re: Rtc ds1307 is going nuts or circuit might be damaged

Postby bioreefdude » Fri May 04, 2012 6:03 pm

also when i unplug my sensor and my rtc from my arduino i get those same readings even with nothing hooked up now back to my sketch lcd works relay signals work so wth please help u guys r wonderful ppl
bioreefdude
 
Posts: 15
Joined: Thu Apr 12, 2012 8:01 pm

Re: Rtc ds1307 is going nuts or circuit might be damaged

Postby bioreefdude » Fri May 04, 2012 7:07 pm

ok i got my temp sensor to work used a 4.7k pull up resistor . now it reads fine but in my coding to control heater the heater pin (relay to control heater on & off ) heater pin is not reacting to temp change
Code: Select all
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

void checkTemp()
{
  sensors.requestTemperatures();
  // Read Temperature from DS18B20
 
  float temp1=0;
 
  lcd.setCursor(8, 0);
  int temp = sensors.getTempFByIndex(0);
  lcd.print(temp,DEC);
 
  if ( (temp1) > 81)
    {
    digitalWrite(heater, HIGH);
      }
else if ( (temp1) < 82)
    {
    digitalWrite(heater, LOW);
    }


}
/*|||||||
bioreefdude
 
Posts: 15
Joined: Thu Apr 12, 2012 8:01 pm

Next

Return to Arduino

Who is online

Users browsing this forum: Fozzie and 10 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [108]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[31]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[34]
LCDs & Displays[48]
Components & Parts[70]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[111]
 
Wireless[14]
Cables[62]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[70]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]