Problema con OLED 0.96 y Arduino NANO [SOLUCIONADO]

Buenas tardes, estoy trabajando en un proyecto que incorpora un display OLED 0.96 I2C y un arduino NANO. El programa consiste en a traves de unos pulsadores en serie activar una valvula que hace mover una pieza. Cuando esta pieza llega a ciero punto acciona un inductivo y la valvula se desactiva. Todo este hardware funciona OK. Agregue un OLED para utilizarlo como contador de operaciones. Cuando conecto el OLED sin modificar el programa el arduino deja de funcionar a los 3 o 4 segundos. Si desconecto los conectores SDA y SCL el arduino funciona sin inconvenientes. Si desconecto la alimentacion del OLED el Arduino sigue deteniendose a los 3 0 4 segundos.

Saben porq puede ocurrir esto??

#include <Adafruit_GFX.h>  // Include core graphics library for the display
#include <Adafruit_SSD1306.h>  // Include Adafruit_SSD1306 library to drive the display


Adafruit_SSD1306 display(128, 64);  // Create display


#include <Fonts/FreeMonoBold12pt7b.h>  // Add a custom font
#include <Fonts/FreeMonoBold18pt7b.h>  // Add a custom font
#include <Fonts/FreeMono9pt7b.h>  // Add a custom font
#include <Fonts/FreeMonoBold24pt7b.h>  // Add a custom font



int Contador;  // Create a variable to have something dynamic to show on the display
int Pulsadores = 4;
int Inductivo = 12;
int Reset = 6;
int Rele =  3;


void setup()  // Start of setup
{                

 pinMode (Rele, OUTPUT);
 pinMode (Pulsadores, INPUT);
 pinMode (Inductivo, INPUT);
 pinMode (Reset, INPUT);


  
  delay(100);  // This delay is needed to let the display to initialize

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // Initialize display with the I2C address of 0x3C
 
  display.clearDisplay();  // Clear the buffer

  display.setTextColor(WHITE);  // Set color of the text

  display.setRotation(0);  // Set orientation. Goes from 0, 1, 2 or 3

  display.setTextWrap(false);  // By default, long lines of text are set to automatically “wrap” back to the leftmost column.
                               // To override this behavior (so text will run off the right side of the display - useful for
                               // scrolling marquee effects), use setTextWrap(false). The normal wrapping behavior is restored
                               // with setTextWrap(true).

  display.dim(0);  //Set brightness (0 is maximun and 1 is a little dim)


  
 
}  // End of setup






void loop()  // Start of loop
{







if (digitalRead (4) == HIGH)
{ digitalWrite (3, HIGH);
}


  
if (digitalRead (12) == HIGH)
 {Contador++;
 
 
while (digitalRead (12) == HIGH){
 digitalRead (12);
  display.fillRoundRect(118, 4, 10, 10, 0, WHITE);  // Draw filled rounded rectangle (x,y,width,height,color)
  display.display();
  delay (100);
  digitalWrite (3, LOW);
}
 }

if (digitalRead(6) == HIGH)
{Contador = 0;}






  // Convert Variable1 into a string, so we can change the text alignment to the right:
  // It can be also used to add or remove decimal numbers.
  char string[10];  // Create a character array of 10 characters
  // Convert float to a string:
  dtostrf(Contador, 4, 0, string);  // (<variable>,<amount of digits we are going to use>,<amount of decimal digits>,<string name>)






  display.clearDisplay();  // Clear the display so we can refresh


  display.setFont(&FreeMonoBold12pt7b);  // Set a custom font
  display.setTextSize(0);  // Set text size. We are using a custom font so you should always use the text size of 0


  // Print text:
  display.setCursor(0, 15);  // (x,y)
  display.println("CONTADOR");  // Text or value to print



  


  

  // Draw rounded rectangle:
 display.drawRoundRect(4, 20, 120, 44, 8, WHITE);  // Draw rounded rectangle (x,y,width,height,radius,color)
                                                    
 


                                                    
  display.setFont(&FreeMonoBold24pt7b);  // Set a custom font
  display.setTextSize(0);  // Set text size. We are using a custom font so you should always use the text size of 0
  // Print variable with right alignment:
  display.setCursor(10, 55);  // (x,y)
  display.println(string);  // Text or value to print




  
  display.display();  // Print everything we set previously

 

  

}  // End of loop

Gracias y Saludos

La valvula como la accionas? Ya entendi que funciona OK pero lo que no se si usas un RELE o si usas un transitor y si la valvula tiene diodo en antiparalelo para evitar perturbaciones.

La valvula la acciono a través de un rele de 5V tipo SRD-05VDC. Igulmente el problema me lo hace sin tener conectada la valvula o rele

Hi,
A las lineas de SDA y SCK le anadistes las resistencias de pullup de 4K7.

tauro0221:
Hi,
A las lineas de SDA y SCK le anadistes las resistencias de pullup de 4K7.

Hi, no no lo hice. Voy a probar y aviso al respecto. Muchas Gracias

lw8dlv:
Hi, no no lo hice. Voy a probar y aviso al respecto. Muchas Gracias

Muchas gracias tauro0221, coloque resistencias pull up de 4k7 en SDA y SCL, y todo funciona a la perfeccion.

Muchas Gracias

TEMA SOLUCIONADO!!

Hi,
Me alegro que resolvio tu problema. El problema es que la mayoria de los displays no incluyen las resistencias a menos que no uses el I2C adapter que ya las tienen incluidas. Muchos de los modulos de sensores hoy dia se las estan instalando y esto causa un problema cuando tiene mas de un sensor. Algunos se las puedes eliminar por jumper pero otras no. De la unica manera es de de-soldarlas del modulo.