• Hello,
    I'm trying to use the LCD Display Module HD44780 (with I2C adapter PCF8574T) with
    an ST NUCLEO-F401RE and the Espruino Web IDE.
    Running the sample code on the "HD44780 Character LCD" web page I get the following behavior \ error:

     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v93 Copyright 2016 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    >Uncaught InternalError: Timeout on I2C Write Transmit Mode 2
     at line 1 col 121
    ...|4,c|4,c,c,d,d,d|4,d|4,d,d]);
                                  ^
    in function "a" called from line 1 col 7
    a(51,1),a(50,1),a(40,1),a(12,1),a(6,1),a(1,1),{write:a,clear...
          ^
    in function "HD44780" called from line 1 col 150
    ...c|4,c,c,d,d,d|4,d|4,d,d]);});
                                  ^
    in function "connectI2C" called from line 1 col 45
    var lcd = require("HD44780").connectI2C(I2C1);
                                                ^
    >Uncaught Error: Field or method "print" does not already exist, and can't create it on undefined
     at line 1 col 4
    lcd.print("Hello World!");
       ^
    =undefined
    

    I have verified that the I2C interface is working on the same Nucleo board, the same LCD display, and the same SDA, SCL pin
    used in your example.
    The problem also arises with the previous Espruino version (1v92) in the same way
    Could you please help me to solve the issue?
    Thanks in advance for your support.

    Regards

  • Do you have pullup resistors on the I2C pins? That error occurs when there's a problem writing to I2C, so at least at that point, there's no software issue - it'll be some kind of electrical problem.

  • Hi Gordon,
    many thanks for your support.
    The configuration I'm trying to use is with no pull up resistors.
    By loading a simple "hello word" program, generated through another platform, I have verified the I2C interface works, with the same Nucleo board, the same display and same I2C pins of your "Hello world" example, as it is (perhaps with the internal weak pull-ups?).

    Generally I have never used additional pull up resistors with this kind of display and the NUCLEO-F401RE board.

    Is it possible that the FW\ interpreter has configured the internal device peripheral registers differently (e.g. with internal weak pull-up and pull-down resistors disabled)?

    Thanks in advance

  • You could try using software I2C, which will use the internal pullups I believe.

    I'm not 100% sure you can enable the pullups on the hardware I2C in Espruino at the moment - although you can always use poke to set them (or peek to check them) if you want.

  • Hello,
    for now I still have problems including pull up resistors (4.7K) between SDA and SCL and VCC, although the error is now slightly different (I2C Write BUSY instead of Time out).

    Interrogating the getPinMode() function, the B7 and B6 pins are configured as Analog input,
    but also changing pin state\mode through pinMode() function before calling connectI2C() does not change the negative result.

    Do you have another value of pull up resistor to suggest?


    | |_ ___ ___ _ ||___ ___
    | |_ -| . | _| | | | | . |
    |
    || || |_|||_|_|

          |_| http://espruino.com
    

    1v93 Copyright 2016 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate

    Uncaught InternalError: Timeout on I2C Write BUSY
    at line 1 col 121
    ...|4,c|4,c,c,d,d,d|4,d|4,d,d]);

                              ^
    

    in function "a" called from line 1 col 7
    a(51,1),a(50,1),a(40,1),a(12,1),a(6,1),a(1,1),{write:a,clear...

      ^
    

    in function "HD44780" called from line 1 col 150
    ...c|4,c,c,d,d,d|4,d|4,d,d]);});

                              ^
    

    in function "connectI2C" called from line 1 col 51
    var lcd = require("HD44780").connectI2C(I2C1, 0x7E);

                                                  ^
    

    Uncaught Error: Field or method "print" does not already exist, and can't create it on undefined
    at line 1 col 4
    lcd.print("Hello World!");
    ^
    =undefined

  • Hmm 4.7k pull ups woks fine for all i2c devices I have been using so far.

    Make sure you solder them like this:

    SDA - 4.7k - VCC
    SCL - 4.7k - VCC  
    

    to work as pull ups

  • Are you sure they're wired up to the correct pins, and that you've called I2C.setup?

    I notice you haven't posted your code - maybe if you did that we could get some ideas?

  • Hi,
    this is exactly the configuration I'm using (mounted on a breadboard, not soldered).
    Also testing different pull up values (e.g. 3.3K and 10K) the result does not change (OK with C-based "Hello Word" program, FAIL with Espruino "Hello Word" example).
    Moreover, when using such type of HD44780 LCD display and the same Nucleo board (or even an Arduino board) I have never had to connect any pull up resitor (always direct connection between the board and the LCD display).
    I think this is due also to the fact that also the I2C PCF8574T adapter mounted behind the display has its weak internal pull up resitors "aboard"...

  • Hi Gordon,
    for now I'm just using the "Hello Word" example contained in the Espruino web page for the LCD Display (http://www.espruino.com/HD44780).

    I2C1.setup({scl:B6, sda:B7});
    var lcd = require("HD44780").connectI2C(I2C1);
    lcd.print("Hello World!");

    The HD44780 module is downloaded locally.
    Any suggestion from you is welcome!

    Regards

  • Ok, can you use a led and a resistor to check that you use the correct pin
    by sending digitalWrite(<YourPinName>, 1); to switch the led on.

    Or use a multimeter and check the voltage for that pin.

  • Ok, it looks like the PCF8574 has different I2C addresses that are configurable on the LCD. That could be your problem?

    In the code that you found worked, what I2C address was being used?

  • Hi Gordon,
    I also suspect a problem with the I2C address.
    For the simple (and working) C++ program I'm using, the address is the following:

    #define SLAVEADDRESS 0x7E

    I have read that the address of the PCF8574 adapter can also be 0x4E or 0x7E.
    I replaced that address in the connectI2C () method, offered by the module for the HD44780 controller, that allows the connection by specifying a different I2C device address but the result has not changed.
    Perhaps we also need to modify the HD44780 module file?

    Thanks in advance

  • you can try i2cdetect to scan the bus for devices.

  • Hi,
    many thanks for the suggestion, however, I'm pretty sure I'm addressing the correct pins (scl:B6, sda:B7) as I did a test leaving the configuration board \ display \ pull up unchanged.
    Then first loading a sample code written in C++, the result = OK (e.g. Hello world displayed), and after using Espruino interpreter + IDE and "Hello world" example (the result = FAIL unfortunately).

    Regards

  • Have you tried:

    require("HD44780").connectI2C(I2C1, 0x3F);
    

    it seems you have a PCF8574A which have
    address 0x7E, shifted right it is 0x3F

  • Hi Frida,
    many thanks for the suggestion!
    Using the instruction you have suggested the "Hello World!" example works
    properly using either "direct connection" or pull up resistors between signal lines.

    Regards

  • Hi MaBe,
    thanks a lot for the suggestion.
    I tried the latest version of the I2C bus scanner and I was able to correctly recognize (reporting the relevant address) two different LCD displays.
    Regards

  • Great! Yes, I2C addresses are a bit strange. They're only 7 bits.

    On Arduino they seem to choose addresses to be 8 bits where the lower bit always has to be zero. On Espruino they're real 7 bit addresses (so they're shifter right by one bit)

  • Hi Gordon, all,
    thank you for your support.
    At the end, I found I2C address management in Espruino more smart than in other contexts...
    Now that I have two working displays, I can start more intense tests to turn some projects developed with other (native) platforms into Espruino.
    In case of problems I will try to ask for your support again...

    By the way, I find JavaScript an interesting and powerful language (although I am not much "in the matter" for the time being).
    I have read, for example, that it can be adapted to different programming paradigms...
    Could you suggest some tutorials (or other material) to understand this language deeply?
    Thanks in advance...
    Regards,

  • I can't recommend anything specific, apart from to say that everyone seems to recommend "JavaScript: The Good Parts".

    Other people on here may be able to recommend something better though?

  • Thanks a lot!
    A good book to start simultaneously with the experiments ...
    Regards

  • "JavaScript: The Good Parts" is for sure a good reference.

    The 'pinch of salt' comes by the application to the limited resources of a micro controller environment and the focus / band-with of the application.

    The language principles do not change... but some of the aspects are not to be applied in a micro controller environment because of different concerns.

  • The

    pinch of salt

    that is also the beauty of using a device with limited resources ...
    Thanks so much !

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

HD44780 Character LCD: problem with I2C and ST NUCLEO-F401RE

Posted by Avatar for Blizzard @Blizzard

Actions