What is the easiest way to mount DS1307 to ethernet shield?

I tried to do this: https://learn.adafruit.com/ds1307-real-time-clock-breakout-board-kit/wiring-it-up

but my program just freezes when I try to read data from RTC. Is there any other ways to do it?

Code looks like this:

const int RTCpin2 = 2;
const int RTCpin3 = 3;

void setup() {
    pinMode(RTCpin2, OUTPUT);
    pinMode(RTCpin3, OUTPUT);

    analogWrite(RTCpin2, LOW);
    analogWrite(RTCpin3, HIGH);

void loop() {
     // process RTC time
  • What do you hope to achieve with that code?
    – Majenko
    Commented Dec 8, 2015 at 22:05
  • this is not the whole code, is bunch of other things too, so I need ethernet shield and then RTC mounter to it. Commented Dec 8, 2015 at 22:17
  • Yes, but what do you hope to achieve with that code that you have shown? What do you think it will do?
    – Majenko
    Commented Dec 8, 2015 at 22:18
  • 5V to pin3, reading with pin2? Commented Dec 8, 2015 at 22:54
  • 1
    Nope, you couldn't be more wrong. I assume those pins are supposed to power the RTC? Well, first you are using the wrong pins, and secondly you are using the wrong functions.
    – Majenko
    Commented Dec 8, 2015 at 22:56

1 Answer 1


I assume that snippet of code is supposed to provide the +5Vand GND for powering the RTC module. Well, there's two fundamental flaws with it:

  1. Pins 2 and 3 are the DIGITAL pins, not the analog pins. Instead you want to be using pins A2 and A3.
  2. analogWrite controls the PWM output on pins that support PWM. HIGH is 1, so analogWrite will be providing a 1/255 duty cycle PWM signal on that pin.

So to fix it:

  1. Use pins A2 and A3 instead of 2 and 3
  2. Use digitalWrite() instead of analogWrite().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.