Skip to content
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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

Pigeo
Copy link
Contributor

@Pigeo Pigeo commented Feb 20, 2017

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)

…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
…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.
@Pigeo
Copy link
Contributor Author

Pigeo commented Mar 1, 2017

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.

@RichJ123
Copy link

RichJ123 commented Jun 9, 2021

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.

Hi Pigeo,
I use esp32 and when I compile with your new LiquidCrystal_I2C.cpp and LiquidCrystal_I2C.h , it shows this error:
In file included from C:\Arduino\i2c_scannerf\i2c_scannerf.ino:4:0:
C:\Arduino\libraries\LiquidCrystal_I2c/LiquidCrystal_I2C.h:2:0: error: unterminated #ifndef
#ifndef LiquidCrystal_I2C_h
^
exit status 1
Error compiling for board Node32s.
What do I do ? is there a way to correct this? Thanks

@Pigeo
Copy link
Contributor Author

Pigeo commented Jun 9, 2021

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.
(This code was compiling perfectly on my environment, so I'm pretty convinced it's some compiler-related issue... I hope the extra carriage return will fix it!)

@RichJ123
Copy link

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?

@Pigeo
Copy link
Contributor Author

Pigeo commented May 10, 2023

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 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).

@RichJ123
Copy link

RichJ123 commented May 14, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants