Having trouble reading Stalker (RTC), thru llc connection

Here is the project: builing a extensive weather station using the mega, and hope to
use the stalker so that I can poll it or request clock data with the mega using the llc
connection between the two boards and the serial port on the mega to send data to a logging program, I am also sending the data to a lcd, and eventually wirelessly to the pc
over quite a bit of distance. Here is the current issue: I really have no problems with the
sensors or serial data, or lcd data, but I am new to most of this and the Wire library and the RTC are giving me lots of problems, most important is the fact that no matter what code approach I take to request date,year and time what I get are odd characters or
zeros or nothing, could this be a problem with control bits needing to be masked ,
or I dont know maybe Iam not actually getting the RTC data,
I know the stalker works correctly because I can set the clock and serial print the data.
so just to clarify: seeeduino Mega (master Writer) with analog and digital sensors,
seeeduino stalker (Slave Sender) , llc connection between boards, master writer
requests date,year and time from the Slave Sender(stalker), and upon receit of data
sends time stamp and sensor readings to the serial port . Any one know what method
or code would work for this, Just not having any luck getting the RTC data to the Mega ?

Hi,

so just to clarify: seeeduino Mega (master Writer) with analog and digital sensors, seeeduino stalker (Slave Sender) , llc connection between boards, master writer requests date,year and time from the Slave Sender(stalker),
You should use the seeeduino Mega as master reader., the example code is Arduino IDE -> File -> Examples->Write -> master reader.
The seeeduino stalker as slaver sender. The example code is Arduino IDE -> File -> Examples->Write -> slave sender.
So the seeeduino Mega can read the data from the seeeduino stalker

Regards.

Thanks for the reply SQX, I actually made an error when I said master writer , Yes Iam using the stalker as (Slave sender) and the seeeduino mega as (master reader), I have tried the arduino examples you mentioned and the examples did work
and I was able to send “Hello” as per the examples,
The problem is that I have not been able to successfully
request or get the RTC data from the stalker thru the i2c/twi
connection and a second problem I am having is to send
charactors and numbers I can send one or the other but not both, I am sure its just because I don’t have very much code writing experiance, it seems difficult to me to manipulate the wire library as compaired to sending thru the serial port, I have also tried retrieving the RTC data by calling specific registers but was unsucessful, any advice or code help would be appreciated, and thanks again for the response !

Hi,

I try to use the seeeduino mega as slave receiver, and the stalker as master sender.
The demo code as following, you can refer to them.

the seeeduino mega as slave receiver:

[code]#include <Wire.h>

void setup()
{

// Wire.onReceive(receiveEvent); // register event
Wire.begin(4); // join i2c bus with address #4
Wire.onReceive(receiveEvent); // register event
Serial.begin(9600); // start serial for output
}

void loop()
{
// delay(100);
}

// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany)
{
while(1 < Wire.available()) // loop through all but the last
{
byte c = Wire.receive(); // receive byte as a character
Serial.print©; // print the character
}
byte c= Wire.receive(); // receive byte as an integer
Serial.println(’ '); // print the integer
}[/code]

the stalker as master sender:

[code]#include “FileLogger.h”
#include “DS1307.h”
#include <WProgram.h>
#include <Wire.h>

#define Timing 0
#define Accept 1
#define Record 2

byte start[7]= { ‘B’,‘e’,‘g’,‘i’,‘n’,0x0D,0x0A};
byte buffer[20];
int temp;
byte ASCII[10]={‘0’,‘1’,‘2’,‘3’,‘4’,‘5’,‘6’,‘7’,‘8’,‘9’};
unsigned char result;
unsigned char state;
int time=0;
int oldtime=0;
byte x = 0;
int i;
void setup()
{
Serial.begin(9600); // start serial for output
Wire.begin(); // join i2c bus (address optional for master)
RTC.stop();
RTC.set(DS1307_MIN,30); //set the minutes
RTC.set(DS1307_HR,10); //set the hours
RTC.set(DS1307_DATE,22); //set the date
RTC.set(DS1307_MTH,12); //set the month
RTC.set(DS1307_YR,9); //set the year
RTC.start();
}

void loop()
{
switch(state)
{
case Timing:

    time=RTC.get(DS1307_SEC,true);
    delay(200); 
    if(time!=oldtime)
    { 
      oldtime=time;    
      temp=RTC.get(DS1307_MTH,false);
      buffer[0]=ASCII[(temp/10)];
      buffer[1]=ASCII[(temp%10)];
      buffer[2]='-';
      temp=RTC.get(DS1307_DATE,false);
      buffer[3]=ASCII[(temp/10)];
      buffer[4]=ASCII[(temp%10)];
      buffer[5]='-';
      temp=RTC.get(DS1307_HR,false);
      buffer[6]=ASCII[(temp/10)];
      buffer[7]=ASCII[(temp%10)];
      buffer[8]='-';
      temp=RTC.get(DS1307_MIN,false);
      buffer[9]=ASCII[(temp/10)];
      buffer[10]=ASCII[(temp%10)];
      buffer[11]='-';
      //temp=RTC.get(DS1307_SEC,false);
      buffer[12]=ASCII[(time/10)];
      buffer[13]=ASCII[(time%10)];
      buffer[14]=':';
      state=Accept;
      Wire.beginTransmission(4); // transmit to device #4
      Wire.send("data:");        // sends five bytes          
      for(i=0;i<15;i++)
      {
          Serial.print(buffer[i]);                         
            Wire.send(buffer[i]);              // sends one byte              
      }  
      Wire.endTransmission();    // stop transmitting       
      Serial.println(' ');
    }
break;

default:state=Timing;break;
}
}
[/code]

Regards.

Hi SQX if your still out there, wow thanks for the Example, looks interesting.
I copied and pasted the code into a new arduino file and imported the libraries,
the seeduino mega slave receiver sketch compiled just fine, The stalker master sender
however won’t compile, I get the following errors : ds1307 has no member named
“stop” or “start”, and also MIN, HR, Date, MTH, and YR were not declared in this scope
( void setup), do you think this is a problem with the ds1307 library or maybe just a syntex issue ? Well any way Thanks for you help I am looking forward to getting it running so I can possibly adapt it or modify it to fit my project, I’ll keep working on it until I can get it to compile.
Happy Holidays !

Hi,

This is a problem with the ds1307 library, you can get my DS1307’s library, and put it on you arduino librarys.

Please feel free to ask any questions.

regards.
DS1307.zip (93.8 KB)

Hey SQX, thanks for the Library download, I installed the Library and I am happy to say that it seems to be working very well, it does appear to be a much more inclusive library,
I have been playing around with it a bit, I think it will work out well for the project I am
working on, I did notice that there is a issue with getting the year, or maybe it requires a
different code statment than the other parameters (date,hour, min etc…), I looked in the
Library source code and Year is defined (DS1307_YR),same form and syntax as the other parameters any Ideas ?
Well its great to be moving forward again, thanks for all your help !!!
oogs