DS1307 SWQ to led

I want to have on a DS1307 pcb a led that is flashing. I have a pcb and i do not know how to connect the swq with the led. this is from the data sheet.

Square Wave/Output Driver. When enabled, the SQWE bit set to 1, the SQW/OUT pin outputs one of four square-wave frequencies (1Hz, 4kHz, 8kHz, 32kHz). The SQW/OUT pin is open drain and requires an external pullup resistor. SQW/OUT operates with either VCC or VBAT applied. The pullup voltage can be up to 5.5V regardless of the voltage on VCC. If not used, this pin can be left floating.

it needs pullup resistor that i thought is used for inputs not outputs. So it says i should connect swq pin to a resistor (i do not know the ohms tho) and then to Vcc and also before the resistor i should get the output also i want to send the output to the possitive leg of the pin.I will also need an 180ohm resistor to lower the voltage from 5 to 2 volts.when i make that circuit with a pullup resistor at 2.2kohms the led does not get High and if i make the circuit without the pull-up resistor the led is always High.

Also in the code i use adjust() to write to the control address like this

void RTC_DS1307::adjust(const DateTime& dt) {
    uint8_t x=144;
    Wire.beginTransmission(DS1307_ADDRESS);
    Wire.write(i);
    Wire.write(bin2bcd(dt.second()));
    Wire.write(bin2bcd(dt.minute()));
    Wire.write(bin2bcd(dt.hour()));
    Wire.write(bin2bcd(0));
    Wire.write(bin2bcd(dt.day()));
    Wire.write(bin2bcd(dt.month()));
    Wire.write(bin2bcd(dt.year() - 2000));
    Wire.write(x);// this is  the 1001000 in order to send  swq= out , swqe =enable and RS1=0 and RS0 = 0 to have an 1Hz square pulse and it is send at address 07H since 06H is for the year.
    Wire.write(i);
    Wire.endTransmission();
}

well what am i missing?

From SQW pin use a 2k2 resistor to go to the base of a PNP transistor, pull the base to 5V with 10k resistor, emitter goes to 5V, collector over a 180 Ohm resistor and the LED to ground.

It may work without the transistor but I wouldn't expect a signal output to drive (better sink in this case) the current for an LED.

this is also from the data sheet

REVISION HISTORY REVISION DATE DESCRIPTION PAGES CHANGED Moved the Typical Operating Circuit and Pin Configurations to first page. 1 Removed the leaded part numbers from the Ordering Information table. 1 Added an open-drain transistor to SQW/OUT in the block diagram (Figure 1). 4 Added the pullup voltage range for SDA, SCL, and SQW/OUT to the Pin Description table and noted that SQW/OUT can be left open if not used. 6 Added default time and date values on first application of power to the Clock and Calendar section and deleted the note that initial power-on state is not defined. 8 Added default on initial application of power to bit info in the Control Register section. 9 100208 Updated the Package Information section to reflect new package outline drawing numbers. 13

this is the data sheet http://www.wvshare.com/datasheet/DALLAS_PDF/DS1307.PDF

at page 4 it is the figure. i did not used the transistor yet. You said PNP transistor should i use something more specific?

Simpler:
5V to resistor, resistor to Anode, cathode to SqWv output.
LED turns on when SqWv output goes low.

For anything but 1Hz it will just look on, dimmer at low Freq’s and brighter at high Freq’s.

so sorry in order to understand you say to connect 5v to 180ohms resistor (5v to 2volt) then the anode of the led and the cathode to the swq.

And also you say the even the swq give a pulse of 1 to 32 hz ti will just show like it is always on?

DS1307 Square wave choices are 1Hz/4.096kHz/8.192kHz/32.768kHz

Anything other than 1Hz will look always on. Consider Arduino PWM - 490Hz, with variable width pulses. AnalogWrite(1) looks pretty dim, Analogwrite(244) looks pretty bright. Both pulse at 490 Hz, but look always on. 4KHz, 8KHz, 32KHz will also look always on. 1Hz flashing on/off for 1/2 second each is observable.

The Output is also controllable, you can write to the register that controls the square wave and turn the square wave on & off at will.

well thx it is still not working. i used an 180ohms resistor to lower the volts and i did connect the cathode to the swq. I used this code to setone byte to the control register. i have to sent 10010000 in order to set it to 1hz

void RTC_DS1307::adjust(const DateTime& dt) {

    Wire.beginTransmission(DS1307_ADDRESS);
    Wire.write(i);
    Wire.write(bin2bcd(dt.second()));
    Wire.write(bin2bcd(dt.minute()));
    Wire.write(bin2bcd(dt.hour()));
    Wire.write(bin2bcd(0));
    Wire.write(bin2bcd(dt.day()));
    Wire.write(bin2bcd(dt.month()));
    Wire.write(bin2bcd(dt.year() - 2000));
    Wire.write(0x90);//this is the hex of 10010000
 //   Wire.write(i);
    Wire.endTransmission();
}

the led is just at High state.

basically i swq pin does not have any voltage difference with ground as i check.So it somewhere else is the problem i do not think that the pin send the pulse at all it is just floating or set to ground also i checked it there is no problem of bridging with the ground on pcb

Open Drain means the pins is either floating or connected to ground. So you will never measure a voltage against ground on this pin (without an external circuit applied).

Open drain needs a pullup resistor to create a high level.

Hi, try this code. I have solved it with this

Wire.beginTransmission(0x68); // activate DS1307
  Wire.send(0); // where to begin
  Wire.send(0x00);          //seconds
  Wire.send(minutes);          //minutes
  Wire.send(0x80 | hours);    //hours (24hr time)
  Wire.send(0x06);  // Day 01-07
  Wire.send(0x01);  // Date 0-31
  Wire.send(0x05);  // month 0-12
  Wire.send(0x09);  // Year 00-99
  Wire.send(0x10); // Control 0x10 produces a 1 HZ square wave on pin 7. 
  Wire.endTransmission();

I had the same problem, here is the answer. MANY PEOPLE THINK THAT EVERY ONE IS PRO SO THEY JARGON AROUND WITH OUT GIVING THE REAL ANSWER.

This is the arduino file

http://shorted-neurons-code.googlecode.com/svn/trunk/arduino-projects/libraries/RTClib/examples/ds1307SqwPin/ds1307SqwPin.ino

this is the adafruit library with display how to wire....

https://learn.adafruit.com/ds1307-real-time-clock-breakout-board-kit/arduino-library