Missing "Begin" in RTC library?

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Missing "Begin" in RTC library?

Postby Spiney » Thu Oct 11, 2012 2:56 pm

I am using Adafruit datalogger shield on an Arduino Uno.
I borrowed Sheepdogguides interrupt program and caused the interrupt to print the date and time to the Serial monitor – Yes I know one should not print within interrupts!
A compile error appeared “class RTC_DS1307” has no member named “begin”.
Serendipitously I tried including “include <wire.h>” and that fixed the compile error.
Now why should the RTC need to have the Wire library included?

Code: Select all
#include "RTClib.h"

RTC_DS1307 RTC;
#define TEMP_PIN  2 //See Note 1, sheepdogguides..ar3ne1tt.htm
#include <PinChangeInt.h>
#include <PinChangeIntConfig.h>
#define PIN 3  // the pin for button
volatile byte burp=0;    // a counter to see how many times the pin has changed
byte cmd=0;     // a place to put our serial data

void setup() {
    digitalWrite(TEMP_PIN, LOW);
    pinMode(TEMP_PIN, INPUT);      // sets the digital pin as input (logic 1)
    Serial.begin(9600);
    RTC.begin();
    delay(100);
    Serial.print("PinChangeInt test on pin ");
    Serial.print(PIN);
    Serial.println();
    pinMode(PIN, INPUT);     //set the pin to input
    digitalWrite(PIN, HIGH); //use the internal pullup resistor
    PCintPort::attachInterrupt(PIN, burpcount,FALLING); // attach a PinChange Interrupt to our pin on the rising edge
// (RISING, FALLING and CHANGE all work with this library)
// and execute the function burpcount when that pin changes 
    RTC.adjust(DateTime(__DATE__, __TIME__));
}
void loop(){
}
void burpcount()
{
  burp++;
    Serial.print("burpcount:\t");  //\t means a tabular space.
    Serial.println(burp, DEC);
    interrupts();
    DateTime now = RTC.now();   
   
    Serial.print(now.day(), DEC);
    Serial.print('/');
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.year(), DEC);
    Serial.print(' ');
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.println();
   
    delay(3000);
   
}
Spiney
 
Posts: 46
Joined: Mon Jul 09, 2012 5:35 am

Re: Missing "Begin" in RTC library?

Postby adafruit_support_bill » Thu Oct 11, 2012 3:08 pm

Now why should the RTC need to have the Wire library included?

Because the RTC is an I2C device and utilizes the I2C implementation from the wire library.
User avatar
adafruit_support_bill
 
Posts: 16022
Joined: Sat Feb 07, 2009 9:11 am

Re: Missing "Begin" in RTC library?

Postby Spiney » Thu Oct 11, 2012 4:11 pm

Great. Thanks.
Shoud have been obvious - sorry.
Spiney
 
Posts: 46
Joined: Mon Jul 09, 2012 5:35 am


Return to Other Arduino products from Adafruit

Who is online

Users browsing this forum: No registered users and 2 guests

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


New Products [103]

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[30]


 
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[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[109]
 
Wireless[14]
Cables[61]
 
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]