Open
Description
DS3231 in the following repository is using a different strategy to initialize i2c bus.
https://github.com/nopnop2002/esp-idf-ds3231
We can't initialize i2c bus twice, am I right?
Do we need to configure anything differently to use the OLED display along with RTC?
Thank you for these libraries that saved me a ton of time!
Metadata
Assignees
Labels
No labels
Activity
nopnop2002 commentedon Sep 6, 2024
xtensa's ESP32 has two i2c buses.
It is necessary to initialize each i2c bus.
esp-idf-ds3231 always uses I2C_NUM_0.
You can select either I2C_NUM_0/1 for this repository.

hsnprojects commentedon Sep 6, 2024
Thanks for taking the time to reply to my message.
Do we still need to include i2cdev from DS3231? It has its own i2c_master_init() function, which conflicts with the one from SSD1306. I noticed that ESP-IDF itself has a different I2C bus initialization function (i2c_new_master_bus(&bus_config, &i2c_bus)).
Can all three of these co-exist?
nopnop2002 commentedon Sep 6, 2024
Yes, you are correct.
change gpio and i2c bus using menuconfig
The build will now pass.
hsnprojects commentedon Sep 7, 2024
Fantastic! That resolved my original issue.
But I am still unable to include protocol_examples_common.h properly. I am very new to the CMake build system.
Following is what I have in my project root folder's CMakeLists.txt:
Could you take a look at this to see if you notice anything glaring?
cmake_minimum_required(VERSION 3.5)
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)
set(EXTRA_COMPONENT_DIRS ./components/ssd1306)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(ds3231)
nopnop2002 commentedon Sep 7, 2024
This is my CMakeLists.txt
The components directory is linked unconditionally.
hsnprojects commentedon Sep 7, 2024
Here is the latest error:
E (558) i2c: CONFLICT! driver_ng is not allowed to be used with this old driver
But it looks like we are using ssd1306_i2c_new.c
hsnprojects commentedon Sep 7, 2024
By the way, I have another similar board working with these components, but I am forcing it to use the legacy driver, and it works fine with esp-idf v5.3.
nopnop2002 commentedon Sep 7, 2024
Yes.
Added forced legacy i2c driver mode to latest version of SSD1306.
Please specify the GPIO number of SSD1306 directly.
CONFIG_SDA_GPIO and CONFIG_SCL_GPIO conflict on ds3231 and ssd1306
hsnprojects commentedon Sep 7, 2024
The following version works fine with the previous version of my program (originally in esp-idf 4.6).
void app_main()
{
i2c_dev_t devRTC;
memset(&devRTC, 0, sizeof(i2c_dev_t));
}
nopnop2002 commentedon Sep 7, 2024
Yes.
Added forced legacy i2c driver mode to latest version of SSD1306.
Please specify the GPIO number of SSD1306 directly.
CONFIG_SDA_GPIO and CONFIG_SCL_GPIO conflict on ds3231 and ssd1306
hsnprojects commentedon Sep 7, 2024
The reason I tried to upgrade was due to a warning I saw while building the program, which recommended upgrading the I2C driver. However, I don't see that warning now, which is strange.
nopnop2002 commentedon Sep 7, 2024
Let's organize some information.
Is your ESP-IDF version 4.6?
Is the clone of ssd1306 the latest?
hsnprojects commentedon Sep 7, 2024
I have upgraded my ESP-IDF to 5.3. I may still have 4.6 on another machine, though.
The version that works fine now even on 5.3 is an old clone of your repo, but the sample that I am working on now is based on your source from earlier today.
When I try to initialize I2C for the OLED with the function call
i2c_master_init_ssd1306(&devOled, 13, 12, -1);
I get the following error:
E (345) i2c: i2c driver install error.
However, it works fine if I remove that line.
hsnprojects commentedon Sep 7, 2024
I was hoping to use I2C in a manner similar to Arduino's
Wire.begin()
, where initializing the I2C bus would be separate from adding devices like the RTC or OLED to the bus.nopnop2002 commentedon Sep 7, 2024
C++ is very limited in esp-idf.
In order to use the class like Arduino, it is necessary to change from main.c to main.cpp, but the driver provided by ESP-IDF does not support main.cpp.
15 remaining items