Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 18 of 18

Thread: I2C LCD Suggestions?

  1. #1

    I2C LCD Suggestions?

    Hi all,

    I'm looking to experiment with an I2C LCD display using the the PCF8574 I/O expander and a Teensy 3.2. Basically I'm out of pins and this would let me experiment with adding a display before figuring out if I need a redesign.

    Two questions:

    1. Has anyone found a library that works with Teensy 3.2? I don't have much test equipment with me at the moment, so starting with software that someone else has verified as working would be a huge help.

    2. Do I need pull ups on both SDA and SCL? I believe this might be true but I'd love to double check.

    Thank you!

    Josh

  2. #2
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,151

    Cool

    I've used the Dig-ole displays (mostly the 0.96" OLED mono displays, but I have also used the color OLED displays, and one of their older mono LCDs). I tend to use them with the serial port, but if you set a solder jumper, it will work in i2c mode. Note, dig-ole uses their own protocol, and not PCF8574. There is an Arduino library, and there was some minor tweaking that was needed for Teensy.


    I believe you need separate pull-ups on both SDA and SCL.
    Last edited by MichaelMeissner; 06-29-2016 at 03:21 PM.

  3. #3
    Hi Michael,

    Thank you for the reply. I should have stated I'm looking at standard character LCDs, in this particular case a 16x2 module. I like the little OLED displays, but for this purpose they are just too tiny.

    Thank you!

    Josh

  4. #4
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,151
    Well they do have 320x240 2.4"/2.6"/etc. displays.

    Adafruit does have some 16x2 displays: https://www.adafruit.com/products/716.

    Here is the Adafruit library: https://github.com/adafruit/Adafruit...Shield-Library.

    In the past, I have used this display (with the Adafruit library). Note, the version I got a few years ago was 5v only, but they claim that the new ones are 3.3v/5v safe: http://digistump.com/products/79.

  5. #5
    Senior Member adrian's Avatar
    Join Date
    Oct 2015
    Location
    Wellington, NZ
    Posts
    504
    I just go one of these oleds (2 days ago!) ..... I think it might be too small for you but it has good big fonts, and is very easy to read .... very bright and works in i2c mode ....it is 5 v / 3.3v too. Its soo easy to use, with the libraries (and examples) part of the teensyduino distribution etc.

  6. #6
    @ MichaelMeissner : I meant to put this post as a reply to you:

    https://forum.pjrc.com/threads/35271...l=1#post121643

    Do you mind elaborating on the tweaks....I am trying to use <i2c_t3.h> and having issues.

  7. #7
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,151
    Quote Originally Posted by 1bit View Post
    @ MichaelMeissner : I meant to put this post as a reply to you:

    https://forum.pjrc.com/threads/35271...l=1#post121643

    Do you mind elaborating on the tweaks....I am trying to use <i2c_t3.h> and having issues.
    Sorry, I've never used the i2c nor spi modes when I've used the digi-ole displays. I've always used the serial mode. The only tweaks I did to the library was to add Teensy support to the #ifdef's.

    However, on the issue of i2c, you NEED to have external pull-up resistorss on the i2c bus. On other systems like the Arduino Uno, you can use the internal pull-up resistors, but on the Teensy, the pull-up resistors are not strong enough for the i2c. There are various factors that go into deciding what pull-up resisters to use. For simple i2c buses, people tend to use 2.2K resistors for 3.3v systems like the Teensy 3.x/LC and 4.7K resistors for 5v systems like the Uno. Pull-up resistors are wired between each of the two pins (SDA, SCL) and 3.3v power. If something else already has pull-up resistors on the i2c bus, you don't need to use additional pull-ups.

  8. #8
    @MichaelM Thanks for the reply....I do have resistors. I am not having trouble with I2c electrically on this setup...I can run the whole bus with the Digole on it physically.
    The problem comes from the digole library not playing well with the i2c_t3.h. In the past I have had all these devices coexist with this code on the same bus and have the digole get/receive commands....I wanted to set the speed on the buss in case these devices cannot talk as fast as the teensy can go so I tried the i2c_t3. h library in order to use that functionality of setspeed(800000); so that I could be sure that i wasn't out clocking the other devices...there are three arduino slaves on the network to control steppers in speed mode with accellstepper on them and one sparkfun 7 segment arduino display display of sequence status.. They work, my code is running with all slaves functioning.


    I just cannot get the Digole library to compile with the i2c_t3.h in my main program...maybe I should just try seeing how fast the bus can run by adjusting the set speed until I get problems and then compiling for the cpu frequency that corresponds to that as a maximum. When I know that then I can go back to not include of i2c_t3.h and revert to the wire library with the digole??

    I just wish the Digole library got along with the i2c_t3 stuff....Any advice is great....

  9. #9
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,151

  10. #10
    That works but I feel so unclean doing it that way.... thanks.

    HTML Code:
    #ifndef _WIRE_SPOOF_I2C_T3_
    #define _WIRE_SPOOF_I2C_T3_
    
    #include <i2c_t3.h>
    
    typedef i2c_t3 TwoWire;
    
    #endif[HTML]
    [/HTML]

  11. #11
    Senior Member
    Join Date
    Jun 2015
    Posts
    229
    Hi 1bit

    Can you recall exactly what you did to get the digole library working with i2c_t3.
    I've followed the links & used teh suggestions but it wont compile.Feel I'm missing something

  12. #12
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,151
    Quote Originally Posted by bossredman View Post
    Hi 1bit

    Can you recall exactly what you did to get the digole library working with i2c_t3.
    I've followed the links & used teh suggestions but it wont compile.Feel I'm missing something
    One issue with i2c_t3.h is it is incompatible with Wire.h. Unfortunately, this means changing the Wire.h to i2c_t3.h in your .ino/.pde sketch (simple), and tracking down all libraries that use Wire, and clone them and change the Wire.h to i2c_t3.h (harder). It would help if you cut+paste the errors so we can tell you what is wrong.

  13. #13
    Senior Member
    Join Date
    Jun 2015
    Posts
    229
    Oh OK - I thought (mistakenly) from reading the posts on that subject that teh "simple" changes made avoided having to modify other libraries

  14. #14
    Senior Member
    Join Date
    Jun 2015
    Posts
    229
    Errors are:

    In file included from C:\Users\Medion\Documents\Arduino\_Sketches_TEENSY _36_MFC_TFT_FP_OLED\AxeFX2_MFC__OLED_rev02\AxeFX2_ MFC__OLED_rev02.ino:36:0:

    C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire/Wire.h:104:16: error: conflicting declaration 'TwoWire Wire'

    extern TwoWire Wire;


    In file included from C:\Users\Medion\Documents\Arduino\_Sketches_TEENSY _36_MFC_TFT_FP_OLED\AxeFX2_MFC__OLED_rev02\AxeFX2_ MFC__OLED_rev02.ino:35:0:

    C:\Users\Medion\Documents\Arduino\libraries\i2c_t3/i2c_t3.h:998:15: error: 'Wire' has a previous declaration as 'i2c_t3 Wire'

    extern i2c_t3 Wire;

    AxeFX2_MFC__OLED_rev02:58: error: no matching function for call to 'DigoleSerialDisp:igoleSerialDisp(i2c_t3*, char)'
    DigoleSerialDisp mydisp0(&Wire, '\x21'); //dummy declaration of 0


    C:\Users\Medion\Documents\Arduino\_Sketches_TEENSY _36_MFC_TFT_FP_OLED\AxeFX2_MFC__OLED_rev02\AxeFX2_ MFC__OLED_rev02.ino:58:43: note: candidates are:

    In file included from C:\Users\Medion\Documents\Arduino\_Sketches_TEENSY _36_MFC_TFT_FP_OLED\AxeFX2_MFC__OLED_rev02\AxeFX2_ MFC__OLED_rev02.ino:37:0:

    C:\Users\Medion\Documents\Arduino\libraries\Digole Serial/DigoleSerial.h:34:7: note: DigoleSerialDisp:igoleSerialDisp()

    class DigoleSerialDisp : public Print, public Digole {


    C:\Users\Medion\Documents\Arduino\libraries\Digole Serial/DigoleSerial.h:34:7: note: candidate expects 0 arguments, 2 provided

    C:\Users\Medion\Documents\Arduino\libraries\Digole Serial/DigoleSerial.h:34:7: note: constexpr DigoleSerialDisp:igoleSerialDisp(const DigoleSerialDisp&)

    C:\Users\Medion\Documents\Arduino\libraries\Digole Serial/DigoleSerial.h:34:7: note: candidate expects 1 argument, 2 provided

    C:\Users\Medion\Documents\Arduino\libraries\Digole Serial/DigoleSerial.h:34:7: note: constexpr DigoleSerialDisp:igoleSerialDisp(DigoleSerialDisp&&)

    C:\Users\Medion\Documents\Arduino\libraries\Digole Serial/DigoleSerial.h:34:7: note: candidate expects 1 argument, 2 provided

    AxeFX2_MFC__OLED_rev02:58: error: cannot declare variable 'mydisp0' to be of abstract type 'DigoleSerialDisp'
    DigoleSerialDisp mydisp0(&Wire, '\x21'); //dummy declaration of 0


    In file included from C:\Users\Medion\Documents\Arduino\_Sketches_TEENSY _36_MFC_TFT_FP_OLED\AxeFX2_MFC__OLED_rev02\AxeFX2_ MFC__OLED_rev02.ino:37:0:

    C:\Users\Medion\Documents\Arduino\libraries\Digole Serial/DigoleSerial.h:34:7: note: because the following virtual functions are pure within 'DigoleSerialDisp':

    class DigoleSerialDisp : public Print, public Digole {


    In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/Stream.h:24:0,

    from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/HardwareSerial.h:238,

    from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/WProgram.h:16,

    from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/Arduino.h:1,

    from C:\Users\Medion\AppData\Local\Temp\arduino_build_5 21480\sketch\AxeFX2_MFC__OLED_rev02.ino.cpp:1:

    C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/Print.h:53:17: note: virtual size_t Print::write(uint8_t)

    virtual size_t write(uint8_t b) = 0;

  15. #15
    Senior Member
    Join Date
    Jun 2015
    Posts
    229
    Hmmmm

    So 2 things.

    1] Ref
    Create a Wire library in your sketchbook folder, with a Wire.h file in it:
    doh - I hadn't put that in the correct folder. Finally realised that when I noticed I wasn't getting the Warning for Mulitple libraties found.
    Fixed that - so now get that warning.

    But sketch would still not complie.

    2] Not sure why - guess I was just experimenting at this point - but I changed the order or these lines of code.

    From:
    Code:
        #include <i2c_t3.h>
        #include <Wire.h>
        #include <DigoleSerial.h>
    
        #define _Digole_Serial_I2C_
        #define Ver 42
    to

    Code:
        #define _Digole_Serial_I2C_
        #define Ver 42      
    
        #include <i2c_t3.h>
        #include <Wire.h>
        #include <DigoleSerial.h>

    Bingo (well not quite) - it now compiles. No errors.
    It even appears to load to the Teensy.
    But it doesnt. The code does not run.

    I cant even just reload my previous version of the sketch which just uses the std Wire lib.
    I have to delete the newly created Wire in <sketchbook>/libraries/

    Talk about confused.

  16. #16
    Senior Member
    Join Date
    Jun 2015
    Posts
    229
    OK - by total luck I found what was causing the code to not run after uplaoding to Teensy.

    I had this is line in my Void Setup()
    Code:
    Wire.setClock(400000);
    It was left over from my original fumblings at trying to speed up the i2c whilst still using just the Wire library.

    Code compiles, loads & now runs.

    Doesnt appear to be any faster at the moment though.
    Will need to find things to "twaek".

  17. #17
    Senior Member
    Join Date
    Jun 2015
    Posts
    229
    Oh well - I've just spent the last 3 hrs reading up on this i2c_t3 library & tbh - I can't make head nor tail of what I need to do to increase the speed.
    Nothing I do seems to change anything.

    Do i have to declare the operating mode with a "BEGIN" (eg
    Code:
    Wire.begin(I2C_MASTER, 0x27, 0x34, I2C_PINS_18_19, I2C_PULLUP_EXT, 800000);
    )
    DO I have to declare all my displays address in this command too?
    For my setup of 1 Teensy sending data to 8 Displays - is that a MSTER or SLAVE setup/mode.

    WOuld apprecaite any help pls & my head is battered.

  18. #18
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,151
    Unfortunately, the author of the i2c_t3 library (nox771) doesn't seem to have posted to the Teensy forums since December 2018. So I don't know if the library is still being maintained, or not. Until I looked it up, I didn't realize he/she had not been posting here recently.

    As of 1.47 beta 4 release, i2c_t3 did not work at all on the Teensy 4 beta.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •