Multiple I2C device not working

Please help me with the code below.
#include <DFRobot_DS1307.h>
#include <Arduino.h>
#include <U8g2lib.h>

#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif

DFRobot_DS1307 DS1307;
U8G2_SSD1306_128X32_UNIVISION_F_SW_I2C u8g2(U8G2_R0, /* clock=/ SCL, / data=/ SDA, / reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED

void setup(void) {

u8g2.begin();
u8g2.enableUTF8Print(); // enable UTF8 support for the Arduino print() function

DS1307.start();
}

void loop(void) {
u8g2.setI2CAddress(0x3C * 2);
u8g2.setFont(u8g2_font_simple1_tf); // use chinese2 for all the glyphs of "你好世界"
u8g2.setFontDirection(0);
u8g2.clearBuffer();
u8g2.setCursor(0, 15);
u8g2.print("Hello World!");
u8g2.setCursor(0, 30);
u8g2.print("ABCD");
u8g2.sendBuffer();

delay(1000);
}
.........................................................
As soon as I introduce this line DS1307.start(); the display stops DISPLAYING.

Are you have a two displays?

What are the I2c addresses of the displays?

Also, please show your connection diagram

Running low on memory? What does the IDE's memory usage tell you?


Please edit your post, select all code and click the <CODE/> button; next save your post.

This will apply code tags which makes the code easier to read and copy and the forum software will display it correctly.

1 Like

Which line are you referring to? Your code is difficult to read, so please use code tags as suggested by other users. Additionally, posting an annotated schematic along with links to technical information on the hardware components will help us assist you more effectively.

I am having one 0.91'' OLED display and an RTC DS1307 parallely connected. When DS1307.start() is coomented out the display works fine, otherwise not. I think it's the addressing problem. DS130.start() is causing the display to stop. Please help in this issue . I want to display RTC time in display.

#include <DFRobot_DS1307.h>
#include <Arduino.h>
#include <U8g2lib.h>


#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif


DFRobot_DS1307 DS1307;
U8G2_SSD1306_128X32_UNIVISION_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE);   // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED



void setup(void) {
  

  u8g2.begin();
  u8g2.enableUTF8Print();		// enable UTF8 support for the Arduino print() function


  //DS1307.start();
}

void loop(void) {
  u8g2.setI2CAddress(0x3C * 2);
  u8g2.setFont(u8g2_font_simple1_tf);  
  u8g2.setFontDirection(0);
  u8g2.clearBuffer();
  u8g2.setCursor(0, 15);
  u8g2.print("Hello World!");
  u8g2.setCursor(0, 30);
  u8g2.print("Naushad");		
  u8g2.sendBuffer();
  
  delay(1000);
}

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