Problems with RTC DS1307 and Arduino Ethernet Shield

Talk about Arduino board, sheilds. Sharing Arduino projects, program, problems, solutions, suggestions..... many more, all are welcome.

Problems with RTC DS1307 and Arduino Ethernet Shield

Postby Summerzsx » Wed Dec 17, 2014 5:54 pm

Hi all, i'm new to arduino and would like to try out some DIY projects using arduino boards.

Currently i'm doing a small project: obtaining temperature and date/time using sensors and DS1307, after that transfer the data to my pc thru ethernet shield every 15 minutes.

When i directly connect RTC and Arduino Duemilanove, date and time displayed correctly but if add ethernet shield, it juz display 165165165... I have searched thru the internet but can't find solution. I tried to bend the A4 and A5 pins of the ethernet shield, it doesn't work too...

Are there compatibility issues between RTC and ethernet shield? Can any experts here to give advice...


Below is my code
CODE: SELECT_ALL_CODE
#include <Wire.h>
#include "RTClib.h" 
#include <OneWire.h>
#include <SPI.h>
#include <Ethernet.h>
   
RTC_DS1307 RTC;
int DS18S20_Pin = 2; //DS18S20 Signal pin on digital 2
OneWire ds(DS18S20_Pin);  // on digital pin 2
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDA, 0x02 };
IPAddress ip(192,168,8,253);


void setup () {
    Serial.begin(19200);
    Wire.begin();
    RTC.begin();
   
    Ethernet.begin(mac,ip);
    // initialize the library with the numbers of the interface pins 
    if (! RTC.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    RTC.adjust(DateTime(__DATE__, __TIME__));
    }
   
    }


void loop () {

      float temperature = getTemp();

      DateTime now = RTC.now();
      Serial.print(now.day(),DEC);
      Serial.print(now.month(),DEC);
      Serial.print(now.hour(),DEC);
      Serial.print(now.minute(),DEC);
      Serial.println(temperature);
     
      EthernetClient client = server.available();       
     
      client.print(now.day(),DEC);
      client.print(now.month(),DEC);
      client.print(now.hour(),DEC);
      client.print(now.minute(),DEC);
      client.println(temperature);

      delay(900000);
}

   
   
   
float getTemp(){
  //returns the temperature from one DS18S20 in DEG Celsius

  byte data[12];
  byte addr[8];

  if ( !ds.search(addr)) {
      //no more sensors on chain, reset search
      ds.reset_search();
      return -1000;
  }

  if ( OneWire::crc8( addr, 7) != addr[7]) {
      Serial.println("CRC is not valid!");
      return -1000;
  }

  if ( addr[0] != 0x10 && addr[0] != 0x28) {
      Serial.print("Device is not recognized");
      return -1000;
  }

  ds.reset();
  ds.select(addr);
  ds.write(0x44,1); // start conversion, with parasite power on at the end

  byte present = ds.reset();
  ds.select(addr);   
  ds.write(0xBE); // Read Scratchpad

 
  for (int i = 0; i < 9; i++) { // we need 9 bytes
    data[i] = ds.read();
  }
 
  ds.reset_search();
 
  byte MSB = data[1];
  byte LSB = data[0];

  float tempRead = ((MSB << 8) | LSB); //using two's compliment
  float TemperatureSum = tempRead / 16;
 
  return TemperatureSum;
 
}

Your advises are much appreciated~~!!
Summerzsx
Greenhorn
 
Posts: 2
Joined: Wed Dec 17, 2014 5:25 pm

Re: Problems with RTC DS1307 and Arduino Ethernet Shield

Postby Idris » Mon Dec 22, 2014 11:11 am

Hi Summerzsx,

I'm wonder why do you bend A4 and A5 pins on the ethernet shield. It is only analog pin on Arduino Due.

ArduinoDuePinout.png


Which one ethernet shield you used?
Cytron Technologies invest time and resources providing tutorial, training and support for STEM education and maker movement. We need your support by purchasing products from Cytron Technologies. Thanks.
http://www.cytron.com.my
User avatar
Idris
Moderator
 
Posts: 409
Joined: Thu Mar 22, 2012 5:28 pm
Location: Pulau Pinang

Re: Problems with RTC DS1307 and Arduino Ethernet Shield

Postby Summerzsx » Fri Feb 06, 2015 4:52 pm

Sorry, is Duemilanove... i'm using this ethernet shield >> http://cytron.com.my/p-shield-ether-sd
Summerzsx
Greenhorn
 
Posts: 2
Joined: Wed Dec 17, 2014 5:25 pm

Re: Problems with RTC DS1307 and Arduino Ethernet Shield

Postby ober » Sun Feb 08, 2015 11:33 am

Looking at the Schematic of Ethernet Shield, both A4 and A5 is not used by the shield, so it should not be affecting I2C of RTC.

Can you show us the hardware setup of the RTC with your Arduino? A few clear photos would be helpful. And where did you connect the temperature sensor?

There might be software issue too.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Re: Problems with RTC DS1307 and Arduino Ethernet Shield

Postby Abraham12li » Fri Feb 27, 2015 8:33 pm

Hi all, i'm new to arduino and would like to try out some DIY projects using arduino boards
_____________________________
smart lover
Get Braindumps demos Testking rhce certification and pass guide with 100% success rhce certification Our high quality itil prepares you well before appearing in the final keiseruniversity of www.sckans.edu
Abraham12li
Fledgling
 
Posts: 1
Joined: Fri Feb 27, 2015 8:25 pm

Re: Problems with RTC DS1307 and Arduino Ethernet Shield

Postby ober » Sun Mar 01, 2015 2:17 pm

Abraham12li WROTE:Hi all, i'm new to arduino and would like to try out some DIY projects using arduino boards


You can get yourself the Starter Kit for CT-UNO and download the Guide Book.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm


Return to Arduino Based

Who is online

Users browsing this forum: No registered users and 15 guests

cron