Difficulties with the RBL BLE shield on SPI and an OLED on I2C

Hi there,

So I’ve been working with the Red Bear Lab BLE shield and a Huhushop OLED (running on the Adafruit SSD1306 library) which run on the SPI and I2C busses respectively. To get them working together I tested them separately (and they both work great on their own!) but when I try to work them together the the OLED does a garbled start-up, prints the pixel, and then the code stops running.

After a week of work and research on this forum and others I still can’t get them working together in the same sketch. I’ve attached an example code below which I’ve been trying to get going:

//All OLED libraries
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

//BLE libraries
#include <boards.h>
#include <RBL_nRF8001.h>

//defining the display
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

void setup () {
  Serial.begin (9600);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.drawPixel(10, 10, WHITE); // simple draw pixel on the OLED
  ble_set_name("MyBLE"); //Name the BLE
  ble_begin(); // initializes functions of the RBL setup file

unsigned char buf[16] = {0};
unsigned char len = 0;

void loop (){// straight from the RBL example
   if ( ble_available() )
    while ( ble_available() )
  if ( Serial.available() )
    while ( Serial.available() )
        ble_write( Serial.read() );

I am using an arduino Uno and links to the two devices are:
BLE: http://redbearlab.com/bleshield/
OLED: http://www.amazon.com/Huhushop-TM-Serial-Display-Arduino/dp/B00JM88A94
(couldn’t seem to locate a datasheet for this one… it’s very similar to the adafruit OLED but only has 4 pins)

OLED Wiring is:
GND → GND (analog)

I have two gut feelings here for what the problem might be: 1, that because the baud rates for the BLE (57600) and the OLED (9600) are different, the arduino just might not be able to communicate properly with each device. 2, that maybe the two are just incompatible in some way? as far as I can tell, the code fails after calling the definition of the display. Or is this just a I2C/SPI problem? I’m fairly new to arduino so I’m kind of in the dark about how the two systems interact/how to toggle between the two of them.

Alternately if this has been answered somewhere else, feel free to redirect me as I may have missed something :slight_smile:

Any help would be much appreciated!