-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Will this work with RTC? #29
Comments
xtensa's ESP32 has two i2c buses.
esp-idf-ds3231 always uses I2C_NUM_0. |
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? |
Yes, you are correct.
change gpio and i2c bus using menuconfig The build will now pass.
|
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: cmake_minimum_required(VERSION 3.5) set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) |
This is my CMakeLists.txt
The components directory is linked unconditionally. |
Here is the latest error: But it looks like we are using ssd1306_i2c_new.c |
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. |
Yes.
Please specify the GPIO number of SSD1306 directly.
|
The following version works fine with the previous version of my program (originally in esp-idf 4.6). void app_main()
} |
Yes.
Please specify the GPIO number of SSD1306 directly.
|
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. |
Let's organize some information. Is your ESP-IDF version 4.6? Is the clone of ssd1306 the latest? |
When I try to initialize I2C for the OLED with the function call I get the following error: However, it works fine if I remove that line. |
I was hoping to use I2C in a manner similar to Arduino's |
C++ is very limited in esp-idf. |
It worked fine with the code below.
|
Not object-oriented, but rather C-style APIs. Initializing I2C might create an I2C channel handle or something similar. Devices are then added (registered) to one of the buses. The i2c_master_init() function is called only once to initialize the bus. I can look into how ESP-IDF handles this. |
I will give it a try tomorrow. I may have to get latest of your source. |
You're right.
This code work fine.
|
Changed i2c_master_init of esp-idf-ds3231 to i2c_dev_init. https://github.com/nopnop2002/esp-idf-ds3231 The i2c_master_init conflict is now gone.
SCL and SDA GPIOs are shared with DS3231. Wireing
My logging
Thank you for the great tips Note |
Yes, that worked! Shouldn't we be able to use the new I2C driver with ESP-IDF v5.3, rather than forcing legacy driver? (BTW, I just have this test app all in one function for the sake of simplicity). |
Achieving this with the new i2c driver would require major changes.
We only need to run this code once.
We need to run this code on the first device.
We need to run this code on the second device.
This library does not have the function to record bus_handle somewhere or retrieve bus_handle from somewhere. And implementing that functionality is not very effective. If SSD1306 use new i2c drivers, other i2c devices must also use new i2c drivers like this.
This is not acceptable.
ESP32C series has only one i2c bus. If I have time, I will update the DS3231 repository to make it I2C bus selectable and use the new IC2 driver. |
Can main() initialize I2C and store the bus handle, then pass that to each of the device initialization routines? We can add multiple devices to the same bus using this method. I was also looking into expanding I/O using the PCF8574T. Edit: |
Yes we can. But We cannot add arguments to i2c_master_init as it would break compatibility.
|
By this approach, you can add devices in any order, and you don't have to rely on devices to initialize the bus. This also aligns with the architecture of ESP-IDF 5.3. I think the I2C bus initialization (driver load) might have changed between versions, but I haven't looked into it. You said:
I did not quite follow this, could you explain? If arguments changed between esp-idf versions, we can include code conditionally. |
This function cannot change its arguments.
Adding this function has no effect on existing apps. |
That makes sense! |
This function is already available.
|
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!
The text was updated successfully, but these errors were encountered: