[SOLVED]WiShield and DS1307+ (Wire.h conflict)
hello,
i have problem use arduino uno r3 + wifi shield + rtc ds1307.
i use asynclab library wifi , rtclib ds1307. problem after add #include "wire.h" - request dont return correct data:
returned data included wire.h:
and returned date without included wire.h(this correct/complet):
and usre return function getrequest:
wifi shield futura eletronica(with chip mrf24wb0ma), and ds1307+ its:
http://tronixstuff.wordpress.com/2010/05/28/lets-make-an-arduino-real-time-clock-shield/
thanks much.
---
complet source:
i have problem use arduino uno r3 + wifi shield + rtc ds1307.
i use asynclab library wifi , rtclib ds1307. problem after add #include "wire.h" - request dont return correct data:
returned data included wire.h:
code: [select]
got connection cpd.as-to.eu
connected cpd.as-to.eu
tx 72 bytes
0 - 71 of 72
rx 0 bytes cpd.as-to.eu
rx 324 bytes cpd.as-to.eu
http/1.1 200 ok
date: fri, 11 may 2012 16:31:48 gmt
server: apache/2.2.16 (debian)
x-powered-by: php/5.3.3-7+squeeze8
vary: accept-encoding
content-length: 112
connection: close
c
got connection cpd.as-to.eu
ended connection cpd.as-to.euand returned date without included wire.h(this correct/complet):
code: [select]
got connection cpd.as-to.eu
connected cpd.as-to.eu
tx 72 bytes
0 - 71 of 72
rx 0 bytes cpd.as-to.eu
rx 324 bytes cpd.as-to.eu
http/1.1 200 ok
date: fri, 11 may 2012 16:39:39 gmt
server: apache/2.2.16 (debian)
x-powered-by: php/5.3.3-7+squeeze8
vary: accept-encoding
content-length: 112
connection: close
content-type: text/html
#date:may 11 2012:date#<br>#time:18:39:41:time#:<br>#unixstamp:1336761581<br>#source:time-a.timefreq.bldrdoc.gov
may 11 2012
ended connection cpd.as-to.euand usre return function getrequest:
code: [select]
// function prints data server
void printdatatime(char* data, int len) {
datastring="";
while (len-- > 0) {
//serial.print(*(data++));
datastring += *(data++);
}
serial.println(datastring);
if(datastring.indexof("#date:")!=-1){date=datastring.substring(datastring.indexof("#date:")+6,datastring.indexof(":date#"));}
if(datastring.indexof("#time:")!=-1){time=datastring.substring(datastring.indexof("#time:")+6,datastring.indexof(":time#"));}
if(datastring.indexof("#unixstamp:")!=-1){unixstamp=datastring.substring(datastring.indexof("#unixstamp:")+11,datastring.indexof("#unixstamp:")+21);}
if(datastring.indexof("#source:")!=-1){source=datastring.substring(datastring.indexof("#source:")+8,datastring.indexof("#source:")+13);}
serial.println(date);
}wifi shield futura eletronica(with chip mrf24wb0ma), and ds1307+ its:
http://tronixstuff.wordpress.com/2010/05/28/lets-make-an-arduino-real-time-clock-shield/
thanks much.
---
complet source:
code: [select]
#include <wiserver.h>
#include <wire.h>
#include "rtclib.h"
rtc_ds1307 rtc;
#define wireless_mode_infra 1
#define wireless_mode_adhoc 2
// wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {10,10,10,9}; // ip address of wishield
unsigned char gateway_ip[] = {10,10,10,1}; // router or gateway ip address
unsigned char subnet_mask[] = {255,255,255,0}; // subnet mask local network
const prog_char ssid[] progmem = {"myssid"}; ///:) rtfm & utfg ;) dl
unsigned char security_type = 0; // 0 - open; 1 - wep; 2 - wpa; 3 - wpa2
// wpa/wpa2 passphrase
const prog_char security_passphrase[] progmem = {"12345678"}; // max 64 characters
// wep 128-bit keys
// sample hex keys
prog_uchar wep_keys[] progmem = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, // key 0
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // key 1
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // key 2
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // key 3
};
// setup wireless mode
// infrastructure - connect ap
// adhoc - connect wifi device
unsigned char wireless_mode = wireless_mode_infra;
unsigned char ssid_len;
unsigned char security_passphrase_len;
string datastring;
string date;
string time;
string unixstamp;
string source;
string nazov;
// end of wireless configuration parameters ----------------------------------------
// function prints data server
void printdatatime(char* data, int len) {
// print data returned server
// note data not null-terminated, may broken smaller packets, ,
// includes http header.
datastring="";
while (len-- > 0) {
//serial.print(*(data++));
datastring += *(data++);
}
serial.println(datastring);
if(datastring.indexof("#date:")!=-1){date=datastring.substring(datastring.indexof("#date:")+6,datastring.indexof(":date#"));}
if(datastring.indexof("#time:")!=-1){time=datastring.substring(datastring.indexof("#time:")+6,datastring.indexof(":time#"));}
if(datastring.indexof("#unixstamp:")!=-1){unixstamp=datastring.substring(datastring.indexof("#unixstamp:")+11,datastring.indexof("#unixstamp:")+21);}
if(datastring.indexof("#source:")!=-1){source=datastring.substring(datastring.indexof("#source:")+8,datastring.indexof("#source:")+13);}
serial.println(date);
}
// ip address
uint8 ip[] = {46,28,110,165};
// request
getrequest gettime(ip, 80, "cpd.as-to.eu", "/time.php");
void setup() {
/* wire.begin();
rtc.begin();
if (! rtc.isrunning()) {
serial.println("rtc not running!");
} */
// initialize wiserver (we'll pass null page serving function since don't need serve web pages)
wiserver.init(null);
// enable serial output , ask wiserver generate log messages (optional)
serial.begin(57600);
wiserver.enableverbosemode(true);
// have processdata function called when data returned server
gettime.setreturnfunc(printdatatime);
}
// time (in millis) when data should retrieved
long updatetime = 0;
void loop(){
// check if it's time update
if (millis() >= updatetime) {
gettime.submit();
// update 1 hour now
updatetime += 3600000;
}
// run wiserver
wiserver.server_task();
delay(10);
}
you don't have lot of memory on arduino. wire library needs some. wifi library needs (a fair amount, actually). string class (that don't need using) needs more it's fair share.
and, yet think problem in conflict in wire.h? why?
before added wire.h, how communicating rtc? why necessary change?
and, yet think problem in conflict in wire.h? why?
before added wire.h, how communicating rtc? why necessary change?
Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > [SOLVED]WiShield and DS1307+ (Wire.h conflict)
arduino
Comments
Post a Comment