Show Posts
Pages: 1 [2] 3 4
16  Using Arduino / Networking, Protocols, and Devices / Re: DS1307 + AT24C32 not keeping time when on battery on: August 20, 2013, 08:49:10 pm
Hahaha =)

you know, I'm kinda new to this world, and i just ended waiting for the delivery from China to EUW and now the module is not working. Complaining about a 0,99 USD module is just a waste of time, but I wanted to know if to be wrong is me or the module.

So just to kill any other doubt, I'd like to describe you my layout so you can tell me "yeah, you didn't miss anything" or beat me hard with a stick

what I have is:

an Arduino UNO R3 board with this module that is composed of a DS1307 RTC and an AT24C32, that has 2 sides of pins

one side has:
- DS
- SCL
- SDA
- VCC
- GND

the other side has   <-- this is the side i tinned the headers
- SQ
- DS
- SCL
- SDA
- VCC
- GND
- BAT

and there are 3 more pins, with no text, just grouped together and called U1 (you can see it in picture on eBay, maybe for a temp sensor?)

from the side I use I connected GND, VCC (to 5V), SDA (A4) and SCL (A5), with no resistors or any other elctric component

did I miss something?

thank you guys, again! =)
17  Using Arduino / Networking, Protocols, and Devices / Re: DS1307 + AT24C32 not keeping time when on battery on: August 20, 2013, 03:25:34 pm
I looked for a DS3231 on eBay, but it seems to cost the double or even more, so what's the difference? More precision and nv memory?
18  Using Arduino / Networking, Protocols, and Devices / Re: DS1307 + AT24C32 not keeping time when on battery on: August 20, 2013, 10:24:58 am
Ok I'll try buy a couple more, hoping they will send me at least a healthy one

thanks
19  Using Arduino / Networking, Protocols, and Devices / Re: DS1307 + AT24C32 not keeping time when on battery on: August 19, 2013, 08:15:34 pm
Yeah I think this may suit best my situation, cause the module keeps time if usb powered, it just doesnt get power from the bat imho. I'll try check the bat connection but I have no idea on how to do that cause its a plastic block glued on the pcb and I dont want to break it smiley-neutral
20  Using Arduino / Networking, Protocols, and Devices / Re: DS1307 + AT24C32 not keeping time when on battery on: August 19, 2013, 05:11:28 pm
So you suggest me to buy a couple more?
21  Using Arduino / Networking, Protocols, and Devices / Re: DS1307 + AT24C32 not keeping time when on battery on: August 18, 2013, 05:14:47 pm
Well, the module is pre soldered so if I want to solder something (pins excluded) I'd have to detach the battery clip, if you look on the link i provided, the picture shows the module is compact, so, in my opinion, no other soldering is needed but the pins'.
22  Using Arduino / Networking, Protocols, and Devices / DS1307 + AT24C32 not keeping time when on battery on: August 18, 2013, 12:23:12 pm
Hi all, I searched in old posts but nobody seems to have solved the problem.

I just bought a DS1307 + AT24C32 module (like this) from eBay.

I am able to write\read DateTime data to the module, and I can read the time updates via serial.
The problem is that when i disconnect the usb from the arduino, the RTC stops updating the time, and it starts again when USB is reconnected (from the point it stopped when USB was disconnected).

This should not happen since the battery is present, and it's a brand new CR2032.

All the posts I found with a similar issue are not about pre-soldered modules.

Can you help me? Should I buy another one or am I missing something?

Thank you guys! =)

If it can help, this is the datasheet for the DS1307 RTC
23  Using Arduino / Programming Questions / Re: error: Wire.h: No such file or directory on: August 14, 2013, 09:37:43 am
All working now, just forgot Serial.begin();  smiley-lol
24  Using Arduino / Programming Questions / Re: error: Wire.h: No such file or directory on: August 14, 2013, 09:34:31 am
No lol, it just doesnt give any error  smiley-lol , now I will look for logical errors

thanks for your precious time man! karma up and tons of gratitude! =)
25  Using Arduino / Programming Questions / Re: error: Wire.h: No such file or directory on: August 14, 2013, 09:30:33 am
*facepalm*

just accidentally removed RTCReader prefix from bcdToDec: I'm kinda retarded today, sorry  smiley-mr-green
26  Using Arduino / Programming Questions / Re: error: Wire.h: No such file or directory on: August 14, 2013, 09:18:45 am
I dont think so because everything worked as sketch, now that I'm turning it into a library it raises errors, but funcs and their use is just copy-pasted from the sketch

I tried to replay both parameter and return type (byte-short, both individually and together) but it just changes the error to a type conversion issue so I think this is not the solution T_T

EDIT: for completeness the whole errors report is
Quote
RTCReader\RTCReader.cpp.o: In function `RTCReader::getDateTime(short*, short*, short*, short*, short*, short*, short*)':
C:\Users\Daedalus\Documents\Arduino\libraries\RTCReader/RTCReader.cpp:72: undefined reference to `RTCReader::bcdToDec(short)'
C:\Users\Daedalus\Documents\Arduino\libraries\RTCReader/RTCReader.cpp:73: undefined reference to `RTCReader::bcdToDec(short)'
C:\Users\Daedalus\Documents\Arduino\libraries\RTCReader/RTCReader.cpp:74: undefined reference to `RTCReader::bcdToDec(short)'
C:\Users\Daedalus\Documents\Arduino\libraries\RTCReader/RTCReader.cpp:75: undefined reference to `RTCReader::bcdToDec(short)'
C:\Users\Daedalus\Documents\Arduino\libraries\RTCReader/RTCReader.cpp:76: undefined reference to `RTCReader::bcdToDec(short)'
RTCReader\RTCReader.cpp.o:C:\Users\Daedalus\Documents\Arduino\libraries\RTCReader/RTCReader.cpp:77: more undefined references to `RTCReader::bcdToDec(short)' follow
27  Using Arduino / Programming Questions / Re: error: Wire.h: No such file or directory on: August 14, 2013, 08:49:48 am
Replaced all but still the same error smiley-cry

UPDATE: this is the code I'm actually working on

.h file
Code:
#ifndef RTCReader_h
#define RTCReader_h

#include "Arduino.h"
#include <Wire.h>

class RTCReader
{
  public:
  RTCReader(int rtc_i2c_address);
  void start();
  void end();
  void setDateTime(short weekDay, short monthDay, short month, short year, short hours, short mins, short secs);
  void getDateTime(short* weekDay, short* monthDay, short* month, short* year, short* hours, short* mins, short* secs);
  uint8_t decToBcd(uint8_t val);
  uint8_t bcdToDec(uint8_t val);
 
  private:
  int RTC_I2C_ADDRESS;
  int regPtrReset;
};

#endif

.cpp file
Code:
#include "Arduino.h"
#include "RTCReader.h"

// Arduino version compatibility Pre-Compiler Directives
#if defined(ARDUINO) && ARDUINO >= 100   // Arduino v1.0 and newer
#define I2C_WRITE Wire.write
#define I2C_READ Wire.read
#else                                   // Arduino Prior to v1.0
#define I2C_WRITE Wire.send
#define I2C_READ Wire.receive
#endif

int regPointReset;

RTCReader::RTCReader(int rtc_i2c_address)
{
  RTC_I2C_ADDRESS = rtc_i2c_address;
  regPtrReset = 0x00;
}

void RTCReader::start()
{
  Wire.begin();
}

void RTCReader::end()
{
  //Wire.end();
}

// 1) Sets the date and time on the RTC
// 2) Starts the clock
// 3) Sets hour mode to 24 hour clock
// Assumes you're passing in valid numbers, Probably need to put in checks for valid numbers.
void RTCReader::setDateTime(short weekDay, short monthDay, short month, short year, short hours, short mins, short secs)
{
  Wire.beginTransmission(RTC_I2C_ADDRESS);
  I2C_WRITE(regPointReset);
  I2C_WRITE(decToBcd(secs) & 0x7f);    // 0 to bit 7 starts the clock
  I2C_WRITE(decToBcd(mins));
  I2C_WRITE(decToBcd(hours));      // If you want 12 hour am/pm you need to set
  // bit 6 (also need to change readDateRTC)
  I2C_WRITE(decToBcd(weekDay));
  I2C_WRITE(decToBcd(monthDay));
  I2C_WRITE(decToBcd(month));
  I2C_WRITE(decToBcd(year));
  Wire.endTransmission();
}

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

// Gets the date and time from the RTC and prints result
void RTCReader::getDateTime(short* weekDay, short* monthDay, short* month, short* year, short* hours, short* mins, short* secs)
{
  Wire.beginTransmission(RTC_I2C_ADDRESS);
  I2C_WRITE(regPointReset);
  Wire.endTransmission();
 
  Wire.requestFrom(RTC_I2C_ADDRESS, 7);

  // A few of these need masks because certain bits are control bits
  *secs     = bcdToDec(I2C_READ() & 0x7f);
  *mins     = bcdToDec(I2C_READ());
  *hours    = bcdToDec(I2C_READ() & 0x3f);  // Need to change this if 12 hour am/pm
  *weekDay  = bcdToDec(I2C_READ());
  *monthDay = bcdToDec(I2C_READ());
  *month    = bcdToDec(I2C_READ());
  *year     = bcdToDec(I2C_READ());
}

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

keywords file
Code:
RTCReader KEYWORD1
start KEYWORD2
end KEYWORD2
setDateTime KEYWORD2
getDateTime KEYWORD2

sketch file
Code:
#include <Wire.h>

#include <RTCReader.h>

#define RTC_I2C_ADDRESS 0x68  // This is the I2C address

RTCReader rtcReader(RTC_I2C_ADDRESS);

short weekDay, monthDay, month, year, hours, mins, secs;
char  *Day[] = {"","Lun","Mar","Mer","Gio","Ven","Sab","Dom"};
char  *Mon[] = {"","Gen","Feb","Mar","Apr","Mag","Giu","Lug","Ago","Set","Ott","Nov","Dic"};

void setup()
{
  rtcReader.start();
  rtcReader.getDateTime(&weekDay, &monthDay, &month, &year, &hours, &mins, &secs);
  if (year == 0)
  {
    rtcReader.setDateTime(3, 14, 8, 2013, 13, 15, 0);
  }
}

void loop()
{
  rtcReader.getDateTime(&weekDay, &monthDay, &month, &year, &hours, &mins, &secs);
 
  if (hours < 10)
    Serial.print("0");
  Serial.print(hours, DEC);
  Serial.print(":");
  if (mins < 10)
    Serial.print("0");
  Serial.print(mins, DEC);
  Serial.print(":");
  if (secs < 10)
    Serial.print("0");
  Serial.print(secs, DEC);
  Serial.print("  ");
  Serial.print(Day[weekDay]);
  Serial.print(", ");
  Serial.print(monthDay, DEC);
  Serial.print(" ");
  Serial.print(Mon[month]);
  Serial.print(" 20");
  if (year < 10)
    Serial.print("0");
  Serial.println(year, DEC);
}
28  Using Arduino / Programming Questions / Re: error: Wire.h: No such file or directory on: August 14, 2013, 08:40:01 am
Though I dont understand why i cant access a private member from the class itself, i moved the funcs to the public section
Code:
#ifndef RTCReader_h
#define RTCReader_h

#include "Arduino.h"
#include <Wire.h>

class RTCReader
{
  public:
  RTCReader(int rtc_i2c_address);
  void start();
  void end();
  void setDateTime(short weekDay, short monthDay, short month, short year, short hours, short mins, short secs);
  void getDateTime(short* weekDay, short* monthDay, short* month, short* year, short* hours, short* mins, short* secs);
  [b]uint8_t decToBcd(byte val);
  uint8_t bcdToDec(byte val);[/b]
 
  private:
  int RTC_I2C_ADDRESS;
  int regPtrReset;
};

#endif

but nothing changed (tried to restart the IDE too): the error remains
Quote
/RTCReader.cpp:68: undefined reference to `RTCReader::bcdToDec(unsigned char)'

P.S. keywords.txt created

thanks for the help you're giving me, i would be lost <3
29  Using Arduino / Programming Questions / Re: error: Wire.h: No such file or directory on: August 14, 2013, 08:28:49 am
If I #include <Wire.h> in .cpp the error dosen't change
if I #include <Wire.h> in the sketch it shows one single error:
Quote
RTCReader.cpp:66: undefined reference to `RTCReader::bcdToDec(unsigned char)'

if I get it right I'm trying to access the bcdToDec function but it doesnt know where to find it, so I tried both
Code:
RTCReader::bcdToDec
and
Code:
RTCReader.bcdToDec
but other errors rise, so the only cause that gets in my mind atm is that it's something about the KEYWORDS file that i dont have yet (cause I'm following step-by-step the official guide to create custom libraries)

Am I right or totally wrong?
30  Using Arduino / Programming Questions / Re: error: Wire.h: No such file or directory on: August 14, 2013, 08:00:25 am
Ok that was stupid, I saw many lines and got scared  smiley-red (and didn't read)

anyway

- void is not required by the ctor right?
- now it says that Wire doesnt exist in .cpp at every point I try to use it, example
Quote
RTCReader.cpp:27: error: 'Wire' was not declared in this scope

do I have to #include <Wire.h> in .cpp too? (like in .h)
Pages: 1 [2] 3 4