You need to log in to create posts and topics.

ssd1306 not being recognized in 1.1.0 SR1

I have a very simple circuit with just an arduino and the ssd1306.

The ssd1306 is not being recognized on the I2c bus.

It doesn't appear to complete begin properly with the SSD1306AsciiAvrI2c

I am uncertain what is causing the issue.  It is like the SSD1306 isn't there.

This code works with a real arduino and ssd1306.

I do not know if it works with other versions of Simulide.

#include <Wire.h>
#include <SSD1306Ascii.h>
#include <SSD1306AsciiAvrI2c.h>
#include <fonts/X11fixed7x14B.h>
#include <fonts/font8x8.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32

// display
SSD1306AsciiAvrI2c oled;
// setup variables in the order they are processed
bool setupfin = false;
bool displayok = false;

// Retrun true if device responds to write.
// can be used to scan for i2c devices
bool i2cCheck(uint8_t i2cAdd) {
  bool rtn;
  AvrI2c i2c;
  i2c.begin();
  // low bit zero starts write, low bit 1 starts read.
  rtn = i2c.start(i2cAdd << 1);
  i2c.end();
  return rtn;
}

void setup_display_init() {
  // start up the oled display
  delay(1000);
  Serial.println(F("Starting Display"));
//  bool oledok = i2cCheck(SCREEN_ADDRESS);
  bool oledok = true;
  if (oledok) {
    oled.displayRemap(false); // rotate 180 degrees
    oled.set1X();
    oled.setFont(X11fixed7x14B);
    Serial.println(F("oled begin"));
    oled.begin(&Adafruit128x64, SCREEN_ADDRESS);
    Serial.println(F("oled begin success"));
    delay(2000);

    // Clear the buffer
    oled.clear();
    oled.displayRemap(true);
    oled.setCursor(0, 0);     // Start at top-left corner

    delay(1000);
    displayok = true;
  } else {
    Serial.println(F("OLED not found"));
  }
}

void setup_display_clear() {
  // finish display setup
  if (displayok) {
    oled.clear();
    oled.set1X();
    oled.setFont(X11fixed7x14B);
    oled.displayRemap(true);
  }
}

void setup_serial_debug() {
  Serial.begin(115200);
  Serial.println(F("Serial Active"));
}

// call the various startup procedures
void setup() {
  // reset these before anything else
  setupfin = false;
  displayok = false;
  
  // put your setup code here, to run once:
  setup_serial_debug();

  setup_display_init();
  Serial.println(displayok);

  if (displayok) oled.println(F("MAX31855 K1"));

  delay(2000);
  setup_display_clear();
    
  delay(500);

  // setup is finished
  setupfin = true;
}

void loop() {
}

 

 

Uploaded files:

Hi.

Yo need to use pullup resistors with these libraries.

Using a 10K pullup fixed it.  Thanks for the info.  Interesting that the real life doesn't require them but the simulation does.

The real one probably have built in pullups.