How to use an RTC and SD reader with Pro Mini 3.3V

Hello,

I have a pro mini 3.3V (https://www.sparkfun.com/products/11114), a dead on RTC (https://learn.sparkfun.com/tutorials/de … okup-guide), and a micro SD board (https://learn.sparkfun.com/tutorials/mi … out-boards).

When trying to hook them up to make a low power data logger, they both want the same pins of the mini for their serial communication. Is there a way to share the communication pins, or is can I change the pins in the libraries so I can use different pins?

Here is a great tutorial I am following, but the breakouts are different from the Sparkfun boards. (https://thecavepearlproject.org/2019/02 … -feb-2019/)

I really wish there were a low power datalogger board offered by sparkfun. That would mean the world to me and my research…instead of buying $1,000’s of Campbell Scientific gear.

It looks like both the SD and RTC use the https://www.arduino.cc/en/reference/SPI protocol. This uses 4 wires (MOSI, MISO, SCK and CS). The first 3 wires can be shared across many devices (Master-Out-Slave-In, Master-In-Slave-Out, Serial Clock). The final pin, CS (Chip Select, sometimes also called SS for Slave Select) is not shared, each device needs to use a different one. The CS pin is a simple digital pin which is used to select a device.

So hook up both the RTC and the SD-Card boards using the same pins for MOSI, MISO and SCK. When you instantiate your library classes for the RTC and SD-Card you need to specify the 4 pins, keep the CS pin the same for one of the devices and choose an unused pin to use for the other device.

Generally you will set the pin your are using for CS to “HIGH” and this deactivates the device. When you want to communicate with the device you will set that pin to “LOW” and do your communications. Once finished, set the pin back to “HIGH”. Only one device can be active at a time.

The tutorial you linked to has a program that uses a variable called “chipSelect” which is hooked to the default CS pin (10), that can be changed so that the SD card uses another pin. The program I am referring to is at https://github.com/EKMallon/ProMiniData … Sketch.ino but there are other, better examples that you can use.