I have two I2C devices connected to an Arduino Uno: an RTC and an OBD interface (see links below). The SCL/SDA of both devices connect parallel to SCL/SDA (respectively) of the Uno. My problem: when I set the time on the RTC (either using the autoset option, or explicitly) it reports back odd readings, like the date set back by 4 days, the hour set back by 2 hours etc. This happens even with the default bare-bones RTC sample sketch.

I tried two RTCs (one DS1307, and the one linked below): both show the same strange behavior. I tried 2 configurations: 1) NO pull-up resistors on either device, 2) two 10K pull-up resistors on BOTH devices. Both situations produce RTC errors. If I detach the OBD sensor from SCL/SDA, the RTC shows the proper time. If I remove the RTC, the OBD by itself (works fine. Before I spend more time experimenting: any advice how to solve this pull-up resistor situation (if this is what it is)?

Adafruit DS3231 Precision RTC

OBD Freematics interface

migrated from electronics.stackexchange.com Aug 15 at 4:15

This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.

up vote 5 down vote accepted

I imagine you are using the Adafruit Library, since thats the URL of the product you posted.

If so, in RTClib.h:

#define DS1307_ADDRESS  0x68
#define DS3231_ADDRESS  0x68

And in the OBDs product page:

OBD I2C Address: 0x68

MEMS I2C Address: 0x62

Which obviously causes a conflict.

It seems that they have a fixed I2C address (some devices are configurable via software, others with external pins). So the solution would be to use other RTC, other OBD (or change its address) or use a bus splitter, or use a MCU with more than one I2C bus.

  • Thanks, well spotted, I'll research this. Why don't they make I2C devices with a small, on-board, solderable jumper to quickly set the address to something else than the default? Rhetorical question... – MrSparkly Aug 15 at 3:43
  • Well, they do, it is just not all of them that have this feature :) – Wesley Lee Aug 15 at 3:50

If anyone has the same problem: turns out Adafruit has a multiplexer just for this purpose. Also, there's LTC4316 which (supposedly) converts I2C addresses on the fly.

Adafruit TCA9548A I2C multiplexer

LTC4316

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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