I2C Display - Write Error 33281

Posted on
  • I feel like I am really missing something here. I have a 1602 display with an ic2 backpack. I am connecting it to a MDBT42Q Breakout, and using this doc: http://www.espruino.com/HD44780

    I have tried different pins. I have also added pull up resistors from vcc (5v) to scl and sda

    Here is the error I get. ...

    >Uncaught InternalError: I2C Write Error 33281
     at line 2 col 13
    in function "a" called from line 1 col 7
    in function "h" called from line 2 col 15
    in function "connectI2C" called from line 2 col 45
    var lcd = require("HD44780").connectI2C(I2C1);
    Uncaught Error: Cannot read property 'print' of undefined
     at line 3 col 4
    lcd.print("Hello World!");
  • The MDBT42Q is a 3.3V device, so it's possible that you won't be able to communicate with the 5V LCD.
    Maybe there is some solution for I2C level shifting?

  • Fri 2019.10.25

    re: 'Maybe there is some solution for I2C level shifting?'

    I posted a few links near page top used on other projects a while back:


    What value is being used for the pull-up resistor?

    @calebbrewer would you mind posting a simple table of the I2C Espruino >> LCD pinout please. (if different than example in tutorial page)

    or the code supporting the definition of I2C1. Have a hunch that I2C is not set up properly as seen by Espruino. (the position of the caret in L12 and L11 leaving L14 error as 'lcd' may never be created)

    Posting all the code would help us immensely. . . .

    What is the result of entering 'lcd' in Left-Hand console side of WebIDE after the above error? Would you please post, or is the value 'undefined' as my hunch should confirm?



    what is the output for each of the I2C pins?

  • I've actually used one of these with an MDBT42 so I know it works... There is no need for resistors (at least when I did it) - and as @AkosLukacs says the MDBT42Q isn't 5v tolerant so pulling up to 5v won't be good for the IO pins anyway.

    Stuff you could try though:

    • Is the LCD definitely running on 5v?
    • All the GND pins should be connected together.
    • Are you sure the I2C pins are the right way around? Maybe try swapping them just in case - it won't break anything if they're wrong.
    • Try var i2c = new I2C(); i2c.setup(...); require("HD44780").connectI2C(i2c); to use software I2c, just in case.
    • If all that fails, could you send us a picture of the back of the LCD? It's possible it's using a different IO expander to the usual ones.
  • Thank you so much for the responses! I am just now back at a computer to post this.
    I just realized that these are 5v. I have two of the same screens and backpacks.

    I have checked the connection many time, and I just tried flipping the pins.

    Here is my code.

    var i2c = new I2C();
    I2C1.setup({scl:D28, sda:D29});
    var lcd = require("HD44780").connectI2C(I2C1);
    lcd.print("Hello World!");

    I have tried with and without "var i2c = new I2C();"

    When I run: getPinMode(pin) I get "input_pullup" for both pins. That doesn't seem right

  • What error do you get when you use i2c = new I2C() instead of I2C1? And you're sure you changed all instances of I2C1 to i2c? It wouldn't be the same error message on software I2C.

    Your board does have 'jumpers' on it for the I2C address, so I don't know whether the default state is all pulled up or all pulled down. Maybe you could try:

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

    all the way from 0x20, 0x21 ... 0x27. And for some reason the example on the reference even gives 0x3F which might be worth trying - but I'm not sure where that comes from!

    Also could you tell us the top line of text on the chip on the PCB? I can't make it out on the picture but if it's not PCF8574 then the address could be different.

    edit: If you're using software I2C with i2c = new I2C() then input_pullup is what you'd expect. The pin state gets changed on the fly as it writes, but using the internal pullup means it doesn't need external resistors.

  • SWEET! That clicked in my brain! The chip os an pcf8574AT. It's default address is 0x3F. I thought I had actually tried that out of frustration, but I guess not.

    Thanks for the help! It is usually something simple I have over looked.

  • Mon 2019.10.28

    'default address is 0x3F. I thought I had actually tried that out of frustration, but I guess not.'

    Just in case you had actually tried 0x3F:

    'I have tried with and without "var i2c = new I2C();"'

    Wouldn't matter as described as follows:

    @calebbrewer if it hasn't been discovered yet, from post #5, L1 and L2 are not the same initialization. (e.g. function setup is not applied to var i2c)

    FYI me thinks that is what Gordon was pointing out in #6

  • Right. What I meant was that I thought I tried 0x3F for the address using hardware I2C (without var i2c = new I2C();).

    I realized the var names were different when using i2c = new I2C(); and changed them. This resulted in no errors, but the screen did not work. This of course was because the address was wrong.

  • Great! Glad you got it sorted! I'll update the docs to add a note about that.

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

I2C Display - Write Error 33281

Posted by Avatar for calebbrewer @calebbrewer