nRF8001 Breakout + 128x64 OLED = Neither work

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
fault
 
Posts: 6
Joined: Tue Nov 25, 2014 11:53 pm

nRF8001 Breakout + 128x64 OLED = Neither work

Post by fault »

To avoid confusion on components let me just give you the links straight to the products:
https://www.adafruit.com/products/938
https://www.adafruit.com/products/1697

I'm trying to get both the bluetooth module and display to play nicely. I'm using a Pro Trinket (5v) for this. I have had both the bluetooth module and display working (independently, never together).

I tried previously with both using SPI, though currently the display is set up for I2C.

I moved the display to I2C hoping I could avoid what seemed a less than straight forward process of learning SPI management.


I started with working bluetooth via the callbackEcho demo (with serial message stuff removed, since I won't see it anyway on the Pro Trinket). I tossed an LED on pin 4 that gives me a visual when there is incoming data.
I then start adding in the dependencies for the display, which don't seem to mess anything up, but the moment I try to initialize the display, I get blinking pixels on the display and a flashing red light on pin 13 (I feel like that LED sharing a pin with the BTLE module is probably not the greatest).

I'm attaching a Fritzing breadboard image just to show my wiring (minus the LED, which is just a resistor from pin 4, to the led, to ground), and my latest run through with a sketch from scratch showing the last line I tossed in that just stops it in its tracks. I have taken it further (aka combining to entire working sketches), though those never work either.

Any assistance is appreciated.

trinket_pro_5v_bluefruit_le_OLED_bb.png
trinket_pro_5v_bluefruit_le_OLED_bb.png (316.16 KiB) Viewed 295 times

Code: Select all

#include <SPI.h>
#include "Adafruit_BLE_UART.h"
// ADDED FOR DISPLAY
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>


#define ADAFRUITBLE_REQ 10
#define ADAFRUITBLE_RDY 3
#define ADAFRUITBLE_RST 9
// ADDED FOR DISPLAY
#define OLED_RESET 8
// ADDED FOR DISPLAY
Adafruit_SSD1306 display(OLED_RESET);

Adafruit_BLE_UART uart = Adafruit_BLE_UART(ADAFRUITBLE_REQ, ADAFRUITBLE_RDY, ADAFRUITBLE_RST);




int led = 4;

/**************************************************************************/
/*!
 This function is called whenever select ACI events happen
 */
/**************************************************************************/
void aciCallback(aci_evt_opcode_t event)
{
  switch(event)
  {
  case ACI_EVT_DEVICE_STARTED:
    Serial.println(F("Advertising started"));
    break;
  case ACI_EVT_CONNECTED:
    Serial.println(F("Connected!"));
    break;
  case ACI_EVT_DISCONNECTED:
    Serial.println(F("Disconnected or advertising timed out"));
    break;
  default:
    break;
  }
}

/**************************************************************************/
/*!
 This function is called whenever data arrives on the RX channel
 */
/**************************************************************************/
void rxCallback(uint8_t *buffer, uint8_t len)
{

  /* Echo the same data back! */
  uart.write(buffer, len);

  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
}

/**************************************************************************/
/*!
 Configure the Arduino and start advertising with the radio
 */
/**************************************************************************/
void setup(void)
{ 
  // ADDED FOR DISPLAY
  display.begin(SSD1306_SWITCHCAPVCC, 0x3D);  // initialize with the I2C addr 0x3D (for the 128x64)


  uart.setRXcallback(rxCallback);
  uart.setACIcallback(aciCallback);
  uart.setDeviceName("PROTO01"); /* 7 characters max! */
  uart.begin();
}

/**************************************************************************/
/*!
 Constantly checks for new events on the nRF8001
 */
/**************************************************************************/
void loop()
{
  uart.pollACI();
}

EDIT (more information):

I pulled the trinket off the breadboard and powered it up, no rapidly flashing pin 13 LED. It takes new uploads fine, its something to do with this sketch or these two components together. Doesn't happen with the same code for just one of the two components, only when they are combined.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: nRF8001 Breakout + 128x64 OLED = Neither work

Post by adafruit_support_rick »

This is a classic case of running out of SRAM on your Pro Trinket. The OLED alone requires a 1K screen buffer, which is half of the available SRAM on the chip.
You will have to switch to a microcontroller with more SRAM. You could try a Leonardo, or a Mega. If you want the small size of the Pro Trinket, then look at an Arduino Micro.

User avatar
fault
 
Posts: 6
Joined: Tue Nov 25, 2014 11:53 pm

Re: nRF8001 Breakout + 128x64 OLED = Neither work

Post by fault »

Of course. :) Thanks.

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”