2

I think of adding a RTC Module to my Raspberry Pi. I found the following tutorial.

http://www.forum-raspberrypi.de/Thread-tutorial-realtime-clock-rtc-ds1307-am-raspberry-pi-betreiben

In general it's clear how I could connect it.

But I already have another thing connected to pin 5. Power Up Circuit

http://www.forum-raspberrypi.de/Thread-tutorial-hoch-und-runterfahren-mittels-taster-incl-status-led

In short words:

  • a 10k resistor between Pin#1 and Pin#5
  • a pushbutton between Pin #5 and Pin #6
  • I left out the LED on Pin #7
  • Pin #5 is configured as IN, listening for a low signal

I need to have the 10k Pullup Connected to Pin #5 and I need a pushbutton between #5 and ground. This is used to power the raspi up or initiate a shut down.


So my basic question is:

Can I connect the RTC to Pin 5 anyway or does that interfere with the wiring above?

If I cannot connect the RTC to Pin 5, is there any alternative wiring i could use?

Either connecting the RTC to an different pin, or using an alternative layout for the wiring above. One thought on that would be connecting the pushbutton to 2 pins, perhaps adding a diode if needed. And splitting the logic a bit.

Shortcircuit between #5 and ground for power up (there is no alternative) and listening for low on any other free pin for shutting down.

Thanks in advance :)

Ghanima
  • 15,958
  • 17
  • 65
  • 125
Christoph Daum
  • 175
  • 2
  • 8

4 Answers4

2

The RTC uses pin 5 as an output, for the SCL signal. But you want to use it as an input. This could be difficult, and could even damage the Pi (if SCL is 3.3V and you press the button you'll be creating a short, possibly damaging pin 5 and maybe even the entire chip).

To prevent any damage you could add a resistor between pin 5 and the button.

Reading pin 5 while it is an output isn't possible, but you can just connect a second (free) pin the the button, and read that one. See schematic below

This doesn't work

The top resistor should be less than 116Ohms to make GPIO 5 get below 0.8V. This is because of the relatively low value (1.8K) pull-up resistor present on the board, and the voltage drop of the diode. However when pin 5 is an output, and high, 28mA will flow when the button is pressed. Which is more than the Pi can handle.

To prevent a LOW on output-pin 5 from registering as a button press you need an additional diode.

Not ideal, but it will make you use a single button for both wake-from-halt and shutdown. Also note that it will disrupt I2C communication if you press the button while the PI is talking to the RTC module. Though the chances of that happening are slim, as communication is maybe once every few minutes, and only takes a few milli-seconds.

Gerben
  • 2,420
  • 16
  • 17
1

The RTC seems to use the I2C interface which requires the secondary functions on pins 3,5. (You could use the I2C on P5, but this would obviously require modifying the RTC software.)

There seems to be no reason why you could not use any of the other GPIO pins for the existing functions, although this would require minor changes to the software.

Incidentally there is no need for the 10KΩ pullup in your existing circuit as pins 3,5 already have 1.8KΩ pullups.

Milliways
  • 62,573
  • 32
  • 113
  • 225
1

I was facing the same problem; I had i2c RTCs, many models, and found that I needed to wake from halt, which was a problem. The solution was to switch my choice of the RTC over to an SPI based one. The one I ended up using was the DS3234.

Key Features

  • Highly Accurate RTC with Integrated Crystal and SRAM Completely Manages All Timekeeping Functions
  • Accuracy ±2ppm from 0°C to +40°C
  • Accuracy ±3.5ppm from -40°C to +85°C
  • Real-Time Clock Counts Seconds, Minutes, Hours, Day, Date, Month, and Year, with Leap Year Compensation Valid Up to 2099
  • Digital Temp Sensor Output: ±3°C Accuracy
  • Register for Aging Trim
  • Active-Low RST Input/Output
  • Two Time-of-Day Alarms
  • Programmable Square-Wave Output
  • Simple Serial Interface Connects to Most Microcontrollers
  • 4MHz SPI Bus Supports Modes 1 and 3
  • Battery-Backup Input for Continuous Timekeeping
  • Low Power Operation Extends Battery Backup Run Time
  • Operating Temperature Ranges: Commercial: 0°C to +70°C, Industrial: -40°C to +85°C
  • 300-Mil, 20-Pin SO Package
  • Underwriters Laboratories® (UL) Recognized

The temp sensor was a bonus, as I could use that for alerting of the ambient temperature of the RPI

Clown Man
  • 131
  • 1
0

Sorry. As far as I'm aware pins 3 and 5 are used for the hadware I2C port of the raspberry. There is another port available but it's used for HAT connectivity. I'd advice using another GPIO port for your input.

This website (not mine!) shows the different capabilities of the raspberry's GPIO header: http://pinout.xyz/

DrBomb
  • 86
  • 2