-
Notifications
You must be signed in to change notification settings - Fork 398
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
Added functionnality to choose between Wire and Wire1 #16
base: master
Are you sure you want to change the base?
Conversation
…s the opportunity to use Wire1 instead of Wire on the Arduino models that have two I2C buses (such as the Arduino DUE) Pierre-Aurélien Georges (https://github.com/Pigeo)
…o avoid a name conflict when compiling on some architectures such as Arduino DUE UPDATE: all the examples have been modified in order to call init(Wire1) instead of init() when ARDUINO_SAM_DUE is defined
Pierre-Aurélien Georges
…ine on Arduino DUE Pierre-Aurélien Georges
…gin() should be the function which calls Wire.begin() Renamed begin(...) into reset(...) in order to avoid any possible confusion. These modifications will make marcoschwartz/LiquidCrystal_I2C and fdebrabander/Arduino-LiquidCrystal-I2C-library more close and more compatible.
…of printing garbage on the LCD
I made several other modifications after that, but if you don't want them, you can just pull the first commit (079b4f8), it's up to you. |
…void compiler warnings)
Hi Pigeo, |
Hi RichJ123, try adding an extra carriage return at the end of the file : some compilers are picky and may not parse correctly the last #endif line at the end of the file if it's missing a carriage return at the end. |
Hi Pigeo, |
Hi RichJ123, With this in mind, I would advise you to check 2 things:
I've also found the following question on Arduino forum where it's not clear if the Wire library can work with BOTH Also perform those same tests with different devices and I2C peripherals if you can (to see if it's hardware related to a specific device). |
Thanks Pierre, really appreciate your help. Just to tell you I manage to
somewhat works the issue out, by not using your library. Here is the deal
as of now: If LCD goes Wire1 using your library, the sht31 won't work for
no apparent reason. I then looked and found Wire1 library for sht31. So,
I moved lcd back to Wire (using normal liquidcrystrl i2c lib.), and move
the sht31 to Wire1, they both perform perfectly. So both of the i2c
channels can work at the same time (with the normal liquidcrystral i2c
library). Exception only that sht41 doesn't have Wire1 library (like
sht31), which was the original reason I looked for modified lib. to get lcd
working in Wire1 , so that I will arrange all sht31, 41 in the same Wire.
So now I resource to having lcd+sht41 in Wire and sht31 in Wire1.
So your question of if these devices got the same interrupt, is not the
case. The problem should lie within the modified library. But anyhow
please don't bother since no one seems to care about this and I wish you
spend your precious time for your other interests. Thank you again for
your kind reply.
…On Thu, May 11, 2023 at 4:07 AM Pierre-Aurélien Georges < ***@***.***> wrote:
Hi Pigeo,
Sorry for not asking earlier but I got problem running this library (the
one with added Wire1 lcd). My sht31 works fine with either Wire or Wire1.
My lcd also works with both wires. But when I have lcd 16x2 at Wire1 and my
sht at Wire, my sht stop working. Can you advise where to resolve this
problem?
Hi RichJ123,
First of all, I must say that the proposed modification in this PR was
intended to give the choice between using either Wire - OR - Wire1: it
wasn't initially intended to use both at the same time, though after a new
review of the code I have the feeling that "it should work" (there's no
static variables, so the code should be "thread-safe", so to speak). Also I
realize I never tested that possibility: I've always been using only one of
the two I2C buses at a time.
With this in mind, I would advise you to check 2 things:
1. maybe the problem is hardware related to a physical limitation of
your specific device? (e.g. both I2C buses sharing the same hardware
interrupt, for instance)
2. maybe the problem comes from either library Print or Wire? (I would
advise you to look at the code in Print.h / Print.cpp / Wire.h / Wire.cpp
and search for "thread-safe issues" such as presence of the "static"
keyword)
I've also found the following question
<https://forum.arduino.cc/t/using-two-i2c-ports-simultaneously/508702> on
Arduino forum where it's not clear if the Wire library can work with BOTH
Wire and Wire1 AT THE SAME TIME (TL;DR nobody explicitly answered the
question), so I would suggest you to first perform some very simple tests
using only the Wire library and very simple I2C peripherals (not LCD
screens) in order to confirm whether Wire and Wire1 can be used at the same
time on your device.
Also perform those same tests with different devices and I2C peripherals
if you can (to see if it's hardware related to a specific device).
—
Reply to this email directly, view it on GitHub
<#16 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AUNK4FRVW2LJTK3FDAMPZHTXFP7Q5ANCNFSM4DA2N32A>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Hello, I added an optional parameter to the init() fonction, in order to be able to choose between Wire (default value) or Wire1, when using an Arduino model with two I2C buses (such as Arduino DUE for example).
I modified the 3 provided examples in order to show how to use this new parameter.
(I also made a little correction to example CustomChars in order to make it compatible with Arduino DUE)