1

I have a RTC DS3231 connected to my Raspberry Pi 3 B+. I connected it using this tutorial https://www.raspberrypi-spy.co.uk/2015/05/adding-a-ds3231-real-time-clock-to-the-raspberry-pi/ and everything works fine.

The DS3231 is connected to the pins:

DS1307  Pi GPIO
GND     P1-06
Vcc     P1-01 (3.3V)
SDA     P1-03 (I2C SDA)
SCL     P1-05 (I2C SCL)

Now, I want to connect a push button that will turn OFF and ON the raspberry pi. Per this tutorial https://howchoo.com/g/mwnlytk3zmm/how-to-add-a-power-button-to-your-raspberry-pi I can turn ON/OFF the pi by shorting pins 5 and 6. However, these pins are already taken by the RTC board.

I'm afraid that I will burn either the Pi, RTC, or something else if I connect the button to the same pins as the RTC.

I know I can select other pins like 18, to turn OFF The pi. However, this will not Turn ON the pi when the button is pressed again.

What would be the safest, faster, and easiest way to accomplish this? To have the RTC DS3231 and a push button/switch that will turn ON the pi.

  • well, the problem is that the python script tinkers with the SCL pin settings, making it an input - but according to the datasheet for the DS3231 it "operates as a slave on the I2C bus" - so, that means the Pi is the "Master", and must supply the SCL clock ... i.e., the pin needs to be an output - have you looked at alternative RTCs (there's many that use other means of communication that isn't I2C) - also, have you looked into why only GPIO3 wakes the Pi from "sleep"? – Jaromanda X Jul 25 '18 at 5:13
  • nevermind about that last bit, I see where that is "documented" – Jaromanda X Jul 25 '18 at 5:22
0

If you can safely short RPI's GPIO pins 5 and 6 to turn it on and off, then you can also do this safely with your RTC connected.

Here's why:

According to Adafruit's documentation, the chip is a Maxim DS3231, and the SCL line is connected to 3.3v through a pullup resistor. According to Maxim's documentation the SCL line is the clock input for the I2C serial interface used to synchronize data. If the SCL line is connected to RPi's GPIO pin 5, then it's also connected to the RPi's system clock.

The pullup resistor acts to limit current when the SCL pin and GPIO pin 5 are shorted to ground. This is exactly what happens when you short GPIO pin 5 to Ground at GPIO pin 6. Consequently, you will not damage the RTC, nor the RPi by connecting GPIO pins 5 and 6.

  • hi, thanks for the input. However, I did try connecting both to the same port after reading your comment via a breadboard. Noticed that now the RTC doesn't want to work anymore. I'm getting the error "hwclock: ioctl(RTC_RD_TIME) to /dev/rtc to read the time failed: Remote I/O error" after powering it off and on once with the button on the same pin. – Unxcellent Jul 25 '18 at 1:12
  • troubleshooting it more. I noticed that when the python script for the power button is running from the tutorial I posted above, the RTC stops to work with the error I gave you earlier. Any thoughts? – Unxcellent Jul 25 '18 at 1:27
  • I can't comment on the scripts you've chosen to use; I was only answering (what I thought was) your question regarding whether or not it was safe to connect RPi pins 5 and 6 while your RTC was connected. That is safe (will not damage your RTC or your RPi), but I can't say whether the software you've chosen will accomplish your objectives or not. There are numerous approaches to halt and start the RPi; for example. Perhaps you should research some alternatives to the software in your original question? – Seamus Jul 25 '18 at 17:57
0

You can NOT run a script using the I²C pins, as this will change the mode and prevent RTC from running.

There is NO NEED to load any script - the current Pi firmware already includes this functionality. I use this, but on a different pin. See https://raspberrypi.stackexchange.com/a/77918/8697

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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