Go Down

Topic: SD card logger on Mega - Combining DS1307 rtc with IMU (SDA & SCL pins - I2C) (Read 1 time) previous topic - next topic

Nigh_Teagle

Setup:
- Genuino Mega 2560
- SD card logger shield (similar to Adafruit's version, mine is from Velleman)
- BNO055 IMU

I changed from the Uno to the Mega to try and get my sample frequency higher. But to get my rtc working, I need to make a jumper connection from A4 to D20 (SDA) and A5 to D21 (SCL). Now I also need the SDA and SCL pins for my IMU.

Can I just share this connection on a breadboard ? Or is there no way to have both working at the same time on the Mega ?

groundFungus

I2C is a bus.  Meaning that many devices can connect to the same 2 pins (SDA, SCL).  Each device on the bus has an address,  The processor can communicate with any device on the bus by using its address.  You should be able to find libraries to facilitate the use of your devices.

Nigh_Teagle

Thanks for the link. I found the datasheet for the sd card shield, but unfortunately there's no I2C address mentioned in it... The Velleman shield seems to be derived from the adafruit shield, so I'll try it out with that address and see if I can get it to work.

CrossRoads

"but unfortunately there's no I2C address mentioned in it"

That's because SD cards run on the SPI bus, not I2C.
You need connection to SCK, MISO, MOSI, and SS.
On an Uno these would be 13,12,11 and 10, or sometimes 4. Or any pin you wanted as long as 10 was declared as an output.

On the Mega, those are 52 (SCK), 50 (MISO), 51 (MOSI), and 53 (SS).
SCK, MISO, MOSI are also on the ICSP header:
1 MISO   VCC  2
3 SCK    MOSI 4
5 Reset  GND  6
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Nigh_Teagle

SD cards write data over the SPI bus, but I believe the RTC clock does use I2C (related topic: https://forum.arduino.cc/index.php?topic=53774.0)

CrossRoads

Oh, the SD card has an RTC on it as well? DS1307, DS3231, yes they use I2C. DS3234 uses SPI.
You can look up the I2C addresses for each in their datasheets at www.maxim-ic.com or from links at www.digikey.com
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up