Using Wire2 (SDA2/SCL2) to run a 4 Line X 20 display

Status
Not open for further replies.
Having trouble getting an I2C 4 X 20 LCD display (backpack controller, Address 0x27) to talk to a Teensy 3.6 via the Wire2 I2C bus. (SDA2/SCL2, pins 3 & 4 on the teensy)
I'm trying to use the i2c_t3 library and just run a simple "Hello World" type sketch to test it out. Can't seem to get the sketch to run. It compiles & loads okay but apparently doesn't talk to the display. Any help with this would be greatly appreciated.

Jim Sheldon

Source code

#include <i2c_t3.h>
//#include <Wire.h>
LiquidCrystal lcd(0x27);

void setup() {
lcd.begin(20,4);
lcd.setBacklight(HIGH);
//
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Test");
Wire2.beginTransmission (0x27);
lcd.setCursor(0,0);
lcd.print("Test");
Wire2.endTransmission (0x27);

}
 
Might help to see full source file, example where is LiquidCrystal defined? I assume you are using some form of LquidCrystal_i2c library?

Most of these I have seen have code hard coded to do stuff to the Wire object. Take a look at your actual library and see if for example: the ::print function maybe goes through a send function , which goes to .. which ends up calling Wire. something?
 
That IS the full source file. Didn't use the Liquid Crystal library, only used i2c_t3 . I haven't been able to find instructions on the definitions - maybe you can point me in the right direction on how to set up the display's definition using the LiquidCrystal_I2C library Everything I've found so far has been totally confusing

Thanks,

Jim
 
Last edited:
I see LiquidCrystal in the TeensyDuino installed libraries. There is also a ...\hardware\teensy\avr\libraries\LiquidCrystalFast\LiquidCrystalFast.cpp

It is used in the code above - but not explicitly included.

Not sure if that helps ...
 
I have not been able to find any instructions anywhere on how to define the I2C 4wire LCD properly using that library though. That's what's really frustrating me.

Jim
 
I tried the code you provided, but when I copy & paste it into Arduino it doesn't even verify.

sc.png

Now I know you're already frustrated and I'm guessing our forum's main rule probably seems rather arbitrary. But we ask for the complete code you're actually using because details matter. We can help you much better with the full details. Especially important is EXACTLY which libraries you are really using. Many are out there, particularly for I2C interfaced displays! Nobody can even guess which one you have, because the code you gave is clearly missing the include for whatever lib you have.

With I2C displays, unfortunately there are several libraries published by different people using exactly the same name. Just the name or #include line is not enough in this case. We need to know exactly which one you installed. The solution is probably going to involve looking at that code.

Also important is which hardware you're really using, and how it's actually connected. Since you said "backpack", I'd guess you may have an Adafruit product, since they use that term. But maybe you've got something from Ebay or a Chinese clone? These details can matter. Often on this forum we've solved hardware problems where lots of discussion was needed to finally get a picture of the wiring, only to discover there was just a simple misunderstanding from the very beginning.

So please, let us help you. Post the complete actual code you've compiling, so anyone here can copy it into Arduino. Tell us exactly which hardware you have. If needed, show us some photos. We're pretty good at helping if we can see what you're really doing. When we have to guess and fill in the missing details, helping is so much harder and far less effective.
 
You accidentally sent a private email reply.

Please Jim, before you do anything else, imagine you're me or Kurt or Defragster trying to help you. In Arduino, click File > New. Delete the template code and copy the code you gave in msg #1 into that new windows. Click Verify. You'll see it doesn't actually compile. It can't possibly compile, because it's missing whatever #include gives you "LiquidCrystal".
 
We help people with problems like this every day. We're actually pretty good at this, but details matter. Nobody can effectively help you on this one when critical info is missing!
 
That IS the exact and complete code I used and nothing else. The only library I used was the one I was told to use by someone elsewhere. That library is "i2c_t3" and I was told that was the only way I could use Wire2.

BTW, I followed your forum rules to the letter, I thought and the code I posted IS what I was trying to make work. I'm not a good programmer and still trying to learn C and C++ so forgive me if I didn't do something right. I keep getting RTFM replies from others (not on this forum) but I can't find the FM to read! Otherwise, I would never have even asked for help. Sorry if I offended anyone.

Jim Sheldon
 
Most of the Adafruit and Sparkfun libraries use the Wire library internally, so you cannot easily change to using Wire2 without editing the library files. For example, this LiquidCrystal library https://github.com/marcoschwartz/LiquidCrystal_I2C would have to be altered to use Wire2. You might search the forum for "Wire2" to review others experience in attempting to use Wire2.

you might first verify your sketch/LCD works with the default I2C Wire settings on pins 18 and 19.

Sometimes, it is as simple as adding #define Wire Wire2 to the top of the library .cpp file

Wire.h has supported Wire1 and Wire2 since Teensyduino 1.36
 
Last edited:
With the Teensy, you might need to add separate pull-up resistors between each of the SDA and SCL ports and 3.3v. IIRC, the typical value for 3.3v systems is 2.2K.
 
I'm not a good programmer and still trying to learn C and C++ so forgive me if I didn't do something right. I keep getting RTFM replies from others (not on this forum) but I can't find the FM to read!

Everyone starts as a beginner. We get that, and I believe everyone here wants to help you.

But we can't, and the reason is because you've not given us enough info, and the code you gave us is incomplete. So far, we *still* don't even know which display you actually have. That can matter, because there are dozens of different ones on the market which require different software. Many are similar (because so many companies tend to copy whatever Adafruit does). Still, can you see how we're struggling here due to lack of info?


That IS the exact and complete code I used and nothing else.

No, it can't possibly be the exact & complete code. You said "It compiles & loads okay". Anyone with the Arduino software can simply copy that code into a new window and click Verify to plainly see it doesn't compile. I even showed you a screenshot when I tried it.

Look, it's ok, really. You're human. Everyone makes mistakes. But if you want useful help, insisting you did everything correctly when clearly you made a simple mistake isn't helping.


The only library I used was the one I was told to use by someone elsewhere. That library is "i2c_t3" and I was told that was the only way I could use Wire2.

Long ago, this was true. But if you have the latest software, indeed the normal Wire library is all you need. You do not need to use the more complex and not-so-beginner-friendly i2c_t3 library.


BTW, I followed your forum rules to the letter, I thought and the code I posted IS what I was trying to make work.

The "forum rule" we have here isn't meant to be strict. The idea is we can help you much better, much faster, using much less of everyone's limited time, if you compose a detailed question with the actual code and info about what you're doing.

Again, you gave us code that doesn't even compile when copied into Arduino. You can check this yourself, even as a beginner, since all you have to do is copy and paste from your original message and then click Verify.


Sorry if I offended anyone.

No offense here, but the reality is you're making it harder and frustrating for all of us who want to help you.

Please, let us help you. Open Arduino, bring up your code and check that you have a complete copy by clicking Verify before you copy it to clipboard. Then when you finish your reply, open a blank Arduino window and copy it back. Make sure it really does compile. Maybe even check the numbers Arduino prints about the memory used, since they should be identical to the Verify you did before copying it. You don't need to be a C++ expert to do this. All that's required is a little more attention to detail.

The complete code will have at least one more #include line. It will be for some library that didn't come with Teensyduino. There too, we need you to be specific, with the actual place where you downloaded it. This too does not require any knowledge of C++. But you do need to be careful to give us accurate info. Some of us will spend time looking at whatever library code you say you're using. We occasionally see questions on this forum where someone is sloppy, giving the wrong link. Maybe they just used google to search again and then copied whatever link they found without any care to make sure it really was the same one they really used before to get the code. Please, don't send us on a wild goose chase.

We really can help you. But at this point, after a dozen messages, we still don't even know exactly which display you bought, which 3rd party library you installed, nor have we see your code that compiles but doesn't work.

I know this stuff can be frustrating. Please try to understand we too get frustrated when we want to help, but the key details are a guessing game!
 
Well fellers, it appears I WAS using the right library, i2c_t3. I mispoke in the original post that it compiled & loaded fine - that was in reference to the original source (which I lost somewhere along the line) for that "test" program, MY BAD.

Quite by accident, I found a thread on this forum from back in 2013, post# 21680-New-I2C-library-for-Teensy3 that gave the full instructions for using that library.

Once I get that listing printed out and studied, I fully suspect I'll be able to come up with a routine that DOES work.

Jim Sheldon
 
Problem solved.

Found a local programmer that was so kind as to modify the original LiquidCrystal_I2C library to work in conjunction with the "Wire2" functions in the i2c_t3 teensy library. and allow LCD operation along with other stuff on (implied Wire2 from the Library's name). A paste of the working source code is below but the modified library isn't available so you won't be able to compile it but the process works fine for me and my original problem HAS been solved. I can't share the modified library (which only works with Wire2) at this time but will try to make it available later if someone needs it. I have to get my programmer friend's permission before it can be shared and he may decide not to as he's a professional programmer.

Jim Sheldon
___________________________________________________________
#include <i2c_t3.h>
#include <LiquidCrystal_Wire2_I2C.h>
LiquidCrystal_Wire2_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

void setup() {
lcd.begin(20,4);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Hello to the");
lcd.setCursor(0,1);
lcd.print("great big");
lcd.setCursor(0,2);
lcd.print("wonderful world");
lcd.setCursor(0,3);
lcd.print("of programming.");
}
_____________________________________________________
void loop(){
}
 
Last edited:
Nice it is working. IIRC I edited an Adafruit library using Wire.h by just putting this at the top to use Wire2:: #define Wire Wire2

… but LiquidCrystal is different
 
Last edited:
Status
Not open for further replies.
Back
Top