2

I bought this RTC module on ebay for pennies. I initially bought it for the arduino but now I would like to use it with the pi. However, I know that in some cases you need logic level converters to keep from frying the I2C pins.

It says, "Operating voltage :3.3 - 5 .5 V". Does that mean I'm ok? Or do I still need a logic level converter? If helpful it uses a DS3231 chip.

3

The simplest thing to do is power it from 3V3. Even if you powered from 5V it would be okay as long as the device contains no pull-up resistors for the I2C bus.

Tu use the device connect it to 3V3, ground, SDA, and SCL and make the following entry in /boot/config.txt

dtoverlay=i2c-rtc,ds3231

  • OK, my dtoverlay already had a line in it so I just added a comma and put what you said. So my dtoverlay line now reads dtoverlay=X,i2c-rtc,ds3231 where X is what was already there.(I can't remember now :-)) . If that is correct... for later use why does that work? What is the purpose of that line? – NULL Aug 17 '15 at 18:57
  • The line I gave is the documented line. See /boot/overlays/README – joan Aug 17 '15 at 19:02
  • Just to be clear about the "Even if you powered from 5V it would be okay" assertion... The DS3231 can run on 5V and might receive I2C signals from a 3.3V device on the bus, but the datasheet for it says that the minimum value for VIH to be "high" is 0.7 * VCC. If VCC is 5V then VIH = 3.5V, so it is possible that the DS3231 might not see the communication at all. – WineSoaked Aug 18 '15 at 4:14
  • 1
    @WineSoaked Yes, it may not be okay in the sense of working, my okay was referring to it not damaging the Pi as long as there are not pull-up resistors. As you point out it will not operate properly if the Pi's 3V3 isn't seen as a logic high when the device is powered from 5V. – joan Aug 18 '15 at 7:43
  • Running it on 3.3v worked perfectly! Thanks for the help! I am so used to the arduino that I sort of forgot about the 3.3v pin! – NULL Aug 18 '15 at 12:59
3

I really have no idea how that RTC clock operates, but I can give you some info that might help you...

The I2C bus is designed in such a way that the I2C master (the RPi in this case), is what drives the voltage (brings it high, which would be 3V3 for the RPi). I2C slaves (the RTC clock here) "send" data by bringing the data line low (GND). So frying the Pi would not be a concern unless the I2C slave tries to draw some ungodly amount of current (which the Pi would be happy to deliver, at the expense of smoking itself in the process). This is because the RTC would never actually supply that deadly 5V that is sure to hurt your pi.

To sum it up, your RPi is delivering the voltage to the RTC, not the other way around.
As long as you power the RTC from the Pi's 3V3 rail, and the RTC doesn't do anything crazy with changing voltages, you should be safe.

Hope this helps :)

  • This is not exactly accurate, as I2C asserts "low" (meaning that low voltage is "1", and high voltage is "0"). This is why I2C busses use "pull-up" resistors. The key problem when dealing with devices where the one I2C device is running at 5V and another I2C device is running at 3.3V (or lower) is these pull-ups. In many cases, one or the other (or sometimes both) will provide the pull-ups, which could be at a voltage that can damage the 3.3V device. Suffice it to say, this is a deep subject into which someone can spend many, many hours troubleshooting. – WineSoaked Aug 18 '15 at 3:31
  • 1
    @WineSoaked Oh absolutely. Interfacing some I2C devices has gobbled up more time than I'd like sometimes. But I really didn't provide any inaccurate information. My error, if any, was that I made the assumption that the OP would power the RTC from the 3V3 rail, and that the RTC wouldn't do something like pull the voltage up to something past VCC on SCL or SDA. A safe assumption for an RTC, I would think. But I'll modify my answer to warn of these assumptions. ( even though the OP clearly solved his problem :P ) – MD-7 Aug 19 '15 at 13:02
2

Based on looking at the schematics in the Ebay listing and a perusal of the images of the board itself, you should be able to power this from the 3.3V rail on the Pi without incident. Both devices list 3.3V operation or have operating voltage ranges that include 3.3V.

Schematic: Provided on the Ebay listing

Board view: enter image description here

Datasheet for the DS3231: http://datasheets.maximintegrated.com/en/ds/DS3231.pdf

Datasheet for the AT24C32: http://www.atmel.com/images/doc0336.pdf

Some caveats, in general:

  • Definitely be aware of pull-up resistors (if they are included and this is the only device you're using, you might keep them, but be aware that the Raspberry Pi has pull-up resistors on the I2C bus pins as well). If multiple devices use pull-up resistors to the same voltage reference, then parallel resistor calculations are in order.
  • Start I2C signaling at a slower clock speed to start. If, for any reason, 400kHz signaling is too noisy or marginal between the Pi and the RTC, it might be intermittent or flaky. Just a cautionary note, take it or leave it.

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.