OLED doesnt work with BNO055 connected

Hello Everyone

I am having a problem with using a BNO055 Sensor together with an SSD1306 OLED Display. The final idea of the program would be to write some sensordata on the OLED but my program doesnt get past the setup because the SSD1306 cant be allocated.

I have tested the OLED on its own and the I2C adresses also check out. I have heard of possibly not having enough RAM to initialize the OLED, so i have tried to cut some variables, but nothing changed. I am using this library to read from my bno055:

Below is not the entire code, because its just the setup that doesnt work, so i have only included the top part of it.

sketch_sep01a.ino (2.1 KB)

Any help is appreciated.

It can be hardware or software, but I'm afraid it is both.

Which Arduino board do you use and which modules do you have (can you give a link to where you bought them ?).
The OLED displays have the nasty habit to disturb the I2C bus for others. It is therefor important to know exactly what you have.

What does the Serial Monitor show ? Can you copy that and show it ?

I'm not happy with the DFRobot library. The I2C bus is initialized for every read and write, that is very weird. That library is written as if the DFRobot library is the only library that uses the I2C bus.

Please show the full sketch between code-tags.
What does the compiler say about memory usage for Flash and SRAM (dynamic memory) ?

Go on. Which OLED displays? Please justify your remark.

Which Arduino board do you use and which modules do you have (can you give a link to where you bought them ?).

The Uno has only got 2048 bytes of SRAM. You have to be careful.

What does the compiler say about memory usage for Flash and SRAM (dynamic memory) ?

Adafruit_SSD1306 library will take an extra 1024 bytes of SRAM at runtime.


On this forum there are a number of topics where someone has a working I2C bus, which does no longer work when adding a OLED display. It seems to happen mainly when a OLED is connected to a 5V I2C bus.
The OLED displays are sold as 3-5V, but that is not true. They are internally 3.3V, so they have a 3.3V I2C bus.

In the past some OLED displays did not even acknowledge to their address. I hope those are not sold anymore.

Adafruit puts a level shifter between the I2C bus and the OLED (see schematic), that is the right thing to do. But then Adafruit uses the Stemma QT bus, which is wrong because SDA is next to SCL.

I can go on for days with this, but I already wrote some things in a Github wiki.

As a first step I would suggest you run the below I2C scanner. It will tell you what I2C addresses respond to a query.

On am M0 I ran an OLED display with another I2C device (SD Card) with no issues.
I used these Bill Greiman library from Github
It only does ASCII but is very compact and was stable for me.

#include "SSD1306Ascii.h"
#include "SSD1306AsciiWire.h"
// --------------------------------------
// i2c_scanner
// Version 1
//    This program (or code that looks like it)
//    can be found in many places.
//    For example on the Arduino.cc forum.
//    The original author is not known.
// Version 2, Juni 2012, Using Arduino 1.0.1
//     Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26  2013
//    V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
//    by Arduino.cc user Krodal.
//    Changes by louarnold removed.
//    Scanning addresses changed from 0...127 to 1...119,
//    according to the i2c scanner by Nick Gammon
//    http://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
//    As version 4, but address scans now to 127.
//    A sensor seems to use address 120.
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.

#include <Wire.h>

void setup()
  Serial.println("\n Started Wire...");
  Serial.println("\nI2C Scanner");

void loop()
  byte error, address;
  int nDevices;


  nDevices = 0;
  for(address = 1; address < 127; address++ ) 
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    error = Wire.endTransmission();

    if (error == 0)
      Serial.print("I2C device found at address 0x");
      if (address<16) 
      Serial.println("  !");

    else if (error==4) 
      Serial.print("Unknow error at address 0x");
      if (address<16) 
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");

  delay(5000);           // wait 5 seconds for next scan

Hello everyone, Thank you for the replies

I am using an Arduino uno board. The compiler says this:
Sketch uses 20044 bytes (62%) of program storage space. Maximum is 32256 bytes.
Global variables use 844 bytes (41%) of dynamic memory, leaving 1204 bytes for local variables. Maximum is 2048 bytes.

This is the OLED Im using, it is labeled as a ssd1306.

The BNO055 board Im using is from dfrobots, all information to it should be here:

I suspect it has something to do with either the dfrobot library, the RAM or the sensor(s) itself, because i was able to print data no problem using an hmc5883 magnetometer with the same OLED. I switched sensors because i need tilt corrected heading and this sensor was the only one easily accesible. The sensor itsself works perfectly, its just i can only view measurements in the serial monitor.

This is what the Serial Monitor shows:

bno begin success
SSD allocation failed

I have run the I2C scanner and it always prints the correct 3 adresses (0x28, 0x76 for the sensor and 0x3C for the OLED)

Think about it. When 1024 bytes is allocated at runtime it means 844+1024 bytes (91%) of dynamic memory.

91% is too risky. But if you got an "allocation failed" message it probably means that something else is allocating at runtime.

The cure is to reduce your SRAM usage by changing any print() and println() statements e.g.
print("anonymous literal string");
print(F("anonymous literal string"));
and checking the new value of Global variables use xxx bytes.


I made the changes and were getting somwhere. The code now gets through the setup. However now the loop doesnt work properly. Im pretty sure i still dont have enough memory, but i have already ordered an arduino every which has 4 more KB of SRAM. I will try it with the new board and post the results once it arrives.

The EVERY might give you more problems. Many "older" third-party libraries will not support it.

What did you get for Global variables use xxx bytes ?

The usual "memory save" advice is : "Anonymous strings in Flash", "use appropriate variable types", "use appropriate size arrays"

If you still have a problem paste your code to the message. Someone might offer advice.

Ok, i will try to further reduce memory usage, but i fear i wont be able to get low enough. I might have to find another library that works for the EVERY and rewrite the program, that should work. I will post again once i have found a solution (but i might have to do a lot of soldering first :confused: )

Thanks for your help!

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.