Pantalla OLED I2C + Sensor Color I2C

Buenas tardes a todos, y gracias por adelantado por vuestra ayuda.

Quiero poner una pantalla OLED 128x64 I2C con un logo en un proyecto que usa un sensor de color TCS34725 I2C pero no consigo que inicialice la pantalla.
Por separado cada programa realiza su trabajo correctamente, pero cuando fundo los dos proyectos estoy metiendo la pata en algo que me esta volviendo loco.
Por favor podeis echarle un ojo.
He escaneado las direcciones obteniendo 0X3C para la pantalla y 0x29 para el sensor.

Muchas gracias y disculpa si se trata de una tonteria pero no soy capaz de verlo.

#include <Servo.h>
#include <Wire.h>
#include "Adafruit_TCS34725.h"
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define ANCHO_PANTALLA 128 // Ancho de la pantalla OLED
#define ALTO_PANTALLA 64 // Alto de la pantalla OLED

#define OLED_RESET -1 // Pin reset incluido en algunos modelos de pantallas (-1 si no disponemos de pulsador). 
#define DIRECCION_PANTALLA 0x3C //Dirección de comunicacion

Adafruit_SSD1306 display(ANCHO_PANTALLA, ALTO_PANTALLA, &Wire, OLED_RESET);

#define LOGO_WIDTH 84
#define LOGO_HEIGHT 52

const unsigned char PROGMEM logo[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x7f, 0xe3, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xf0, 0xf8, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xf8, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x1f, 0xff, 0xf8, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xf1, 0xff, 0x80, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xe3, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0xff, 0xff, 0xc3, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xc3, 0x00, 0x7f, 
0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0x82, 0x00, 0x1f, 0xf0, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x01, 0xfe, 0x00, 0x00, 0x0f, 0xe4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xfc, 0x00, 0x00, 
0x07, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x38, 0x03, 0xfc, 0x03, 0x32, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x09, 0x90, 0x0f, 0xff, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x60, 0x3f, 
0xff, 0x80, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x80, 0x7f, 0xff, 0xc0, 0x67, 0x80, 0x00, 
0x00, 0x00, 0x00, 0x1c, 0x00, 0x7f, 0xff, 0xe0, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 
0x7f, 0xff, 0xe0, 0x3f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x80, 0x7f, 0xff, 0xf0, 0x3f, 0x80, 
0x00, 0x00, 0x00, 0x00, 0x3f, 0x80, 0x3f, 0xff, 0xf0, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x3f, 
0x81, 0x3f, 0xff, 0xf0, 0x1f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x81, 0x1f, 0xff, 0xf0, 0x1f, 
0xc0, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x01, 0x3f, 0xff, 0xf0, 0x1f, 0xc0, 0x00, 0x00, 0x00, 0x00, 
0x7f, 0x01, 0x33, 0xf9, 0xf0, 0x1f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x20, 0x70, 
0x1f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x80, 0x20, 0x20, 0x1f, 0xc0, 0x00, 0x00, 0x00, 
0x00, 0x7f, 0x00, 0x00, 0x60, 0x20, 0x1f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x80, 0x01, 0x10, 
0x60, 0x1f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x33, 0x80, 0xcf, 0x1f, 0xe0, 0x3f, 0xc0, 0x00, 0x00, 
0x00, 0x00, 0x30, 0x00, 0xff, 0x0f, 0xe0, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x7f, 
0x1f, 0xc0, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x07, 0x1c, 0x00, 0xff, 0x80, 0x00, 
0x00, 0x00, 0x00, 0x03, 0xc0, 0x03, 0xfc, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x07, 0xf8, 
0x03, 0xf8, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x07, 0xfc, 0x03, 0xf8, 0x00, 0x7f, 0xc0, 
0x00, 0x00, 0x00, 0x00, 0x07, 0xf8, 0x00, 0x60, 0x00, 0x7f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x07, 
0xf8, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xfc, 0x00, 0x00, 0x06, 0x60, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x0f, 0xff, 0x80, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xe0, 0x00, 0xff, 
0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xfe, 0x07, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x7f, 0xff, 0x0f, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0x8f, 
0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xfe, 0xd7, 0xfe, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x03, 0xfe, 0xd7, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 
0xd7, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0xd7, 0x80, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00
};





Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_50MS, TCS34725_GAIN_4X);

Servo wheelServo;  // create a servo object to control a servo
Servo chuteServo;  // create another servo object to control a servo

const int calibrating = 0; //change this to 0 when you want to run the machine and to 1 when you set it up for the first time
const int wheelOverRun = 190; //decrease this if the skittle goes past the colour sensor or increase it if the skittle stops before it reaches the sensor

const int contactSwitch = 8;
const int resetButtonPin = 7;

int switchState;
int arrayIndexToAimAt;

int redCount = 0;
int greenCount = 0;
int yellowCount = 0;
int orangeCount = 0;
int purpleCount = 0;

float redReading, greenReading, blueReading; //somewhere to store our colour sensor readings

const int arrayRows = 6;
const int arrayColumns = 6;
int SAMPLES[arrayRows][arrayColumns] = {  // array goes red value, green value, blue value, colour, difference to sample (update by code later), angle for depositor
  {84, 78,  82,  "Red", 0, 0}, //red -0
  {59,  105,  77,  "Green", 0, 40}, //green -1
  {84,  96,  61,  "Yellow", 0, 80}, //yellow -2
  {102,  75,  65,  "Orange", 0, 120}, //orange -3
  {63,  85,  95, "Purple", 0, 150},  //purple -4
  {62, 87, 93, "No Skittle", 0, 75}, //no skittle -5
}; 
// Determines the number of samples stored in the array
const byte samplesCount = sizeof(SAMPLES) / sizeof(SAMPLES[0]);


void setup()
{
  pinMode(contactSwitch, INPUT_PULLUP);

  pinMode(resetButtonPin, INPUT);

  
  Serial.begin(9600);


  if(!display.begin(SSD1306_SWITCHCAPVCC, DIRECCION_PANTALLA)) {
    Serial.println(F("Fallo en la asignacion de SSD1306"));
  }
   


  if (tcs.begin()) {
    //Serial.println("Found sensor");
  } else {
    Serial.println("No TCS34725 found ... check your connections");
    while (1); // halt!
  }

  display.clearDisplay(); 
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.println("LaBuhardillaDelLoco");
  display.display();


  display.drawLine(0, 10, 128, 10, WHITE);
  display.display();


  display.drawBitmap( (display.width() - LOGO_WIDTH ) / 2,((display.height()- LOGO_HEIGHT) / 2 )+7, logo, LOGO_WIDTH, LOGO_HEIGHT, WHITE);
  display.display();








  wheelServo.attach(5);  // attaches the servo on pin d5 to the servo object
  chuteServo.attach(6);  // attaches the servo on pin d6 to the servo object

 

  printArray(SAMPLES) ;
  
}




void loop()
{


Su código no se compila. En primer lugar, no lo insertaste completamente, solo el título es del procedimiento de loop()
En segundo lugar, contiene errores evidentes.

Esta matriz se describe como una matriz de números int, ¿crees que una cadena de texto "Purple" es un número entero?

hola, gracias por tu interés.

Esa parte del programa no me da ningun problema, funciona de maravilla, pero ahora he querido añadir la pantalla y es lo que me provoca el fallo.

No arranca la pantalla.
El sensor de color y la pantalla OLED comparten A4 y A5.

He probado sacando lo que corresponde a la pantalla en un proyecto independiente, tal y como lo tengo en el proyecto global pero solo la pantalla, y funciona perfectamente, se enciende y muestra el logo.

¿No estás de acuerdo conmigo en que la matriz SAMPLES está descrita incorrectamente?

¿Crees que el color puede considerarse un número?

el sensor interpreta la lectura con numeros correspondientes a la gama R / G / B y con la calibración se realizan medidas de cada color de forma repetitiva y se obtienen valores medios para cada color. Despues en el funcionamiento compara y con el que tiene menos diferencia encaja el color de los cinco existentes

Ok, buena suerte

Puedes echarme una mano con el fallo que me da para poder hacer funcionar la pantalla ???

Una pregunta que tal vez consideres estúpida porque sino lo hubieses aclarado y a mí la bola de cristal no me funciona...

¿Qué placa estás usando?

Disculpa pero se me paso ponerlo.
Placa Arduino UNO

Se está quedando sin memoria por eso no inicia la pantalla.

Saludos

Como lo ves ??? no hay margen??

Y sólo tienes 650 bytes libres.
La biblioteca de pantalla OLED requiere 1 KB adicional de memoria, no incluida en estas cifras.

vale vale, se puede ampliar memoria o que placa debería de usar?

Gracias porque me estaba volviendo loco

No, la memoria no se puede aumentar.
Puedes cambiar el código para reducir el requisito de memoria o conseguir una placa más grande, como la Mega

ok. Pues muchas gracias a los dos por vuestra ayuda porque me estaba volviendo loco.

GRACIAS

Que trabaje a 5V, la Mega.
A 3.3V puedes usar alguna con ESP32 o una Raspberry Pi Pico, por ejemplo.

ok, muchas gracias