Newbies trying to integrate OLED and SD Card on SPI

My daughter and I are trying to get a ebay purchased MicroSD Card Reader board and Sparkfun MicroOLED (LCD-13003) to work together on the SPI bus on an Arduino UNO.

We are using SPI, SD, and SFE_MicroOLED libraries

Micro SD CS is on pin 7
OLED CS is on pin 10
Both share MOSI on pin 11 & SCK on pin 13
SD Card uses MISO on pin 12 (OLED does not use MISO but does use DC on pin 8 & RESET on Pin 9)

We have declared both CS pins as OUTPUT

Following the examples in the Arduino program, we have been able to get both to work independently in this set up.

We want to display some numbers and write those numbers to the SD card for later use.

When trying to integrate we are running into problems and are banging our collective heads on 2x4s with rusty nails in them.

Have tried:

In Setup()
Set Serial Baud to 9600 in Setup()
Set both OLED CS HIGH and SD CS LOW
Open text file and write text to file
Close text file
Set SD CS HIGH
Set OLED LOW
Write to OLED Screen
Set OLED HIGH

In loop()
set OLED CS LOW
Write to OLED Screen
set OLED CS HIGH
Serial Print same information as to OLED
set SD CS LOW
Open SD
Write same information to SD Card using if loop
Close SD
set SD CS HIGH

When trying this - the SD card does not get written to but the file gets created
When changing the order - the OLED does not get displayed to

Added as bunch of Serial Prints to track where in the code things were not working

Even encountered the setup continuously looping an never getting getting to the main program loop.

We are looking for guidance on how to make this work and to understand what is going on.
Note that neither of us are programmers and we do not know C or C++
Thank you

I'm having a similar problem with a BMP280 barometer and SD. The best solution I've come up with is to either run SD.begin() every time you write (only if you don't care about write speed) or have your own buffer that everything gets written to and then dumped when it's full.

I have zero idea why this helps, but it seems to work. My guess is that something is floating around and SD.begin() gets it "back in line", but I don't know if that's actually what's happening.

Try leaving your setup( ) code the same, and commenting out the OLED code in loop( ).

If I comment out the OLED code then I won't have the OLED displaying the information

Scotty-G:
If I comment out the OLED code then I won't have the OLED displaying the information

But does it work?

You can add debug code temporarily to "write" to the Serial Monitor.

yes if we comment out OLED the SD Card works
If we comment out the SD Card, the OLED works
But having difficulty getting them both to work in the same code
Added a bunch of comment lines to see where things are and are not working
it seems to cycle the set up and not get to loop

Most SPI chips will tri-state (effectively disconnect) their MISO pin when their chip signal is high(inactive). However, some chips (some SD card shields) do not have a proper MISO tri-state behavior.

Some tips for a better SPI bus design:
https://www.dorkbotpdx.org/blog/paul/better_spi_bus_design_in_3_steps