-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Wire.h not able to change buffer length from .ino file #6967
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
Comments
@dharmik768 If it works for 1.0.6, the buffer size used in Arduino is always 128. There is no way to change it to any other size just using a simple Which makes me think that the size of the buffer may not be the problem for the vl53l3cx TOF sensor IF you want to test with a different Buffer Size, please try it by changing the value directly in Wire.h file. |
I have already tested successfully by changing the buffer length directly in the Wire.h and its works perfectly. I thought it would be more simple for the end user if they do not need to go and change buffer sizes in their ESP32 packages. Anyway, if there is no way around the possible solution I was going to try out to make a copy of the Wire.h file and change it as per my need and add it locally with my custom library package such that the code used my Wire.h instead of the default one. |
I see. In that case we may need to create some interface to fix it. |
@dharmik768 - Interesting... I just found this saying that it is necessary to change the buffer size directly in the Wire header file: |
Yes it is required in some cases as I mentioned the TOF sensor without its not working may be a TOF library side issue but the majority of the library part API is suggested by ST itself. So it would be very handy if we can directly manage the buffer size in the code itself when needed without modifying the package files. |
Closed by mistake, |
I'm currently working on a I will submit soon a PR. |
Let me know if you need any helping hand in that, I can test it out. |
@dharmik768 - Please test #7016 and let me know. Thanks! |
PR #7016 merged. |
Hello @SuGlider, Sorry for the late response today I got time to test the new modified wire library these are the steps I follow. Now I uploaded the test code for the sensor that I have without changing the buffer size, and a strange thing happened without changing the buffer also the code is working perfectly and I am able to read sensor data. So apart from the new buffer size change function in the library have you changed anything in the older wire library same code is not working without changing the buffer size. Anyways thank you for adding that function. |
Do you think this is happening because in my library.h file I have added this line Will this make changes in the buffer directly without using that function as previously it was not changing, let me comment it out and check it once. |
I commented and tested it is still working. |
Yes, this is used as default size when none is set using Make sure you don't have more than one Wire Library in use... |
As of today... August 28, 2024, Whereas editing the Wire.h as follows does work. (but this "solution" is not acceptable since an update to the library would break that.... (but keep reading... there is an easy solution...)
Here is test code... main.cpp #define mySDA 6 void setup(void) void loop(void) ` So, here is a solution that works... |
@peteDDD call |
Board
ESP32 DEV Module
Device Description
Using generic ESP32 dev board
Hardware Configuration
non
Version
v2.0.3
IDE Name
Arduino IDE
Operating System
Windows 11
Flash frequency
80
PSRAM enabled
no
Upload speed
921600
Description
I am using a vl53l3cx TOF sensor with an ESP32 board.
I am using this library and its example for testing and it works perfectly but I need to change inside the ESP32 package to make it work. To be specific inside the Wire.h file of the ESP32 package.
Initially, the example was not working directly but I read somewhere in the form that it needs to increase the I2C buffer size as the received packet size from the sensor is big therefore default size will not work.
First I tested it by changing the I2C_BUFFER_LENGTH to 256 directly in the Wire.h file and the example code is working perfectly. This test was done in the old ESP32 package release V1.0.6
But In the latest releases that I can see after V2.0.3 in Wire.h file it's defined like this
So I thought I can increase the size of the buffer externally directly from the Arduino .ino file itself like this before including the Wire.h
But on uploading in this way the sensor data is not read properly like previously, So I checked by printing the I2C_BUFFER_LENGTH in Arduino code as well as inside the Wire.begin(); library function.
And shockingly it printed 256 in the Arduino code and when begin to function is called it printed 128.
So it seems like it not making any change to the I2C_BUFFER_LENGTH even it's defined before calling the library.
Is there any way to change the I2C_BUFFER_LENGTH without making any modifications to the ESP32 package itself?
As I think the Arduino compile is somehow compiling all ESP32 packagess before even we include them. As I have done the same test with the blank sketch with only Wire.h library included and I2C_BUFFER_LENGTH same results were seen.
Thank you,
Dharmik Patel
Sketch
Debug Message
Other Steps to Reproduce
To debug properly add this line inside your Wire.cpp file function
add this inside that
Finally, it will look like this
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: