My code is basically a mix of the example code provided in those two locations (it's on a different PC, or I'd post it - maybe get a chance later.) I'm reading the DS1307 and the DS18S20 once per loop, and Serial.print'ing the results. That's it.
Things seem to work fine, but about once a day, the RTC suddenly becomes inaccurate by several hours. I don't have any more details, since I'm not logging the output, just checking it periodically - it'll be totally accurate one day, then when I check the next morning, it'll be off by a few hours, or up to an entire day - seems rather random.
Thoughts? If I run the RTC by itself (i.e. comment out the temp sensor code), it's accurate for weeks.
The Dallas one-wire temperature sensors seem to be really popular. Anyone have alternatives? I don't want to go to an analog sensor, as I'm running out of analog pins already. I2C would be nice.
Anyone have experience with I2C and the TLC5940 used at the same time? I'm waiting to get some TLCs and am hoping it's not an issue. . .
I've used the I2C DS1621 temp sensor with the DS1307 and those work fine together. If that helps.
It's interesting that the incompatibility shows up as a change in the time setting. I assume the "new time" is permanent? This implies that the one-wire is writing the registers on the DS1307. Perhaps there's a way to CS disable the RTC when you are reading temperatures? Just a thought.
Ive got them working together as well in an incomplete project.
On top of the one wire and 2 wire theres also a 4 bit lcd hooked up and an ethernet shield as well.
All working well.
Gordon and BroHogan, care to share code and/or other details?
I like one-wire because it's so bloody simple, but the DS1621 looks straightforward, too.
And yeah, the change in time is permenant, so it does look like the DS1307 is getting written to. My code doesn't include writing to the DS13007, so it's clearly a fluke, not an "oops I didn't mean to call that function!"
This is the simple function I use to get the temp from the DS1621
// Function to get the temperature from a DS1621
#define DEV_ID 0x48 // DS1621 w/ A0, A1, A2 LOW
void Get_Temp(){
// this part was in init function
Wire.beginTransmission(DEV_ID); // connect to DS1621 (#0)
Wire.send(0xAC); // Access Config
Wire.send(0x02); // set for continuous conversion (not working)
Wire.beginTransmission(DEV_ID); // restart
Wire.send(0xEE); // start conversions
Wire.endTransmission();
delay(15); // need this delay after starting conversions
// this part was in get temp function
Wire.beginTransmission(DEV_ID);
Wire.send(0xAA); // read temperature
Wire.endTransmission();
Wire.requestFrom(DEV_ID, 1); // request one byte from DS1621
tempC = Wire.receive(); // get whole degrees reading
tempF = tempC * 9 / 5 + 32; // convert to Fahrenheit
}
Looking at the code for Wire.cpp your restart seems odd. The lib does not look like it would work as you expect. It does not support restarts. You have to finish the first transmission followed by a new one.
In you source only the start sample would be sent as the config bytes you sent would be wiped out by not finishing their transmission.
You have to finish your first transmission before you start another.
so where you have Wire.send() followed by Wire.beginTransmission() you have to add Wire.endTransmission() before the begin.