Set cursor command not working (i2c)

I'm been trying to use the set cursor command in I2c. The other command are working properly, I'm not sure what i'm doing wrong
Here the Set cursor fonction.
The model of the LCD is the LK204-25
Here what the datasheet is saying about that

2.7. Set Cursor Position
Sets the cursor to a specific position where the next transmitted character is printed.
Column 1 byte, value between 1 and 20
Row 1 byte, value between 1 and 4

//Set Cursor
void setCursor(int x, int y){

  Wire.beginTransmission(0x28);
  Wire.write(0xFE);
  Wire.write(0x47);
  Wire.write(x);
  Wire.write(y);
  Wire.endTransmission();
  delay(1000);

}

Thank you for any advice.

Thank you for any advice.

If you want to get back more than speculation then I would advise you to post your entire sketch and also include links to the hardware and to the library that you are using.

Don

Here the complete code

I'm just testing the lcd with the arduino right now.
here the link for the lcd
http://www.matrixorbital.com/product_info.php?products_id=25

#include <Wire.h>  //library for I2c
#include <Arduino.h>


#define LCD (0x28)

void setup() {
  
  Wire.begin();
  gpoOFF();
  clearlcd();
  cursorON();
  

}

void loop() {

  displayOFF();
  delay(100);
  displayON();
  delay(100);
  setCursor(2,2);
  delay(100);
  Wire.beginTransmission(0x28);
  Wire.write(" Hello World\n");
  Wire.endTransmission();
  delay(1000);
  

}

//Clear Screen
void clearlcd(){

  Wire.beginTransmission(0x28);
  Wire.write(254);
  Wire.write(88);
  Wire.endTransmission();
  delay(1000);

}

//Display ON
void displayON(){

  Wire.beginTransmission(0x28);
  Wire.write(254);
  Wire.write(66);
  Wire.endTransmission();
  delay(1000);

}

//Display OFF
void displayOFF(){

  Wire.beginTransmission(0x28);
  Wire.write(254);
  Wire.write(70);
  Wire.endTransmission();
  delay(1000);

}

//Underline Cursor
void cursorON(){

  Wire.beginTransmission(0x28);
  Wire.write(254);
  Wire.write(74);
  Wire.endTransmission();
  delay(1000);

}

//Go Home
void home(){

  Wire.beginTransmission(0x28);
  Wire.write(254);
  Wire.write(72);
  Wire.endTransmission();
  delay(1000);

}

//Set Cursor
void setCursor(int x, int y){

  Wire.beginTransmission(0x28);
  Wire.write(0xFE);
  Wire.write(0x47);
  Wire.write(x);
  Wire.write(y);
  Wire.endTransmission();
  delay(1000);

}

////General Purpose Output Off
void gpoOFF(){

  Wire.beginTransmission(0x28);
  Wire.write(254);
  Wire.write(56);
  Wire.endTransmission();
  delay(1000);

}

"The other command are working properly, I'm not sure what i'm doing wrong"
This means that your wiring, pull-ups, I2C address, etc. are correct.

I notice that your 'Set Cursor' function is different than all the rest in two respects:
(1) You have expressed the commands in hex rather than decimal.
(2) You have to pass parameters to the function.

I would concentrate my troubleshooting efforts on these differences. I don't know much about 'wire', but a quick search for the phrase arduino use hex with wire.write resulted in this --> Wire.write - Programming Questions - Arduino Forum

Don

I already try using the command with the decimal. same result...

And that same result is????
You haven't said what it is actually doing vs what you are expecting it to be doing.

Also, what version of the IDE are you using. The Wire library has had a few little
updates since 1.0

--- bill

Here a picture to show you what happen when I try to use the set cursor command.

I don't know why but after I remove this part of the code. the set cursor work perfectly

displayOFF();
  delay(100);
  displayON();
  delay(100);

The photo doesn't look like it is working (maybe that's what you meant?)
The sample code you posted attempts to set the text to start at column=2, row=2
by calling:

setCursor(2,2);

which according to their documentation is the 2nd position from the left and the 2nd
row down from the top, since they stated that their rows and columns are 1 based vs 0 based.
The text on the display in your photo does not look like it is column 2 row 2 and
then there is a "G" and two odd characters.
My guess is the "G" and those characters are from the setCursor() function
as 0x47 is a capital G, then the two "garbage" characters are the row and the column bytes which are
both the character 0x2 which is a custom character.
So the real question is why is the backpack is not properly interpreting your "Set Cursor"
character sequence?

One likely possibility is that you are getting out of sync with the backpack by not sending the proper
number of bytes on previous command(s).
This looks likely by your displayON() function. You are not sending the "minutes" parameter.
No telling what that does to the firmware in the backpack but
it might mean that the next byte received will be interpreted as the minutes parameter.
In you sample code that would be the 0xfe command code from the set cursor position.
Which if the photo you are showing is the non working state, that would explain
why the G and the 2 garbage bytes show up.
The 0xfe being sent for the set cursor command would be interpreted as the minutes
parameter and enable the display for 254 minutes which then changes the state
back to normal characters and the G and two 0x2 bytes then get displayed.

I'd recommend updating your displayON() function to send the minutes parameter.
If you don't want to send displayON() the value, i.e. displayON(minutes),
then send the backpack a zero byte which is supposed to leave it on forever.

--- bill

Other notes:
I see you are using i2c address 0x28, the default address seems to be 0x80 in the documentation.
Have you changed the default i2c address?

Maybe during some of your initial testing the device ended up in some strange state.
Have you tried doing the reset procedure to put everything back to defaults?

If you include the liquidCrystal_I2C library you can use commands like lcd.print and such. You won't have to use wire.transmit and endtransmission all the time.

Vtech:
Thank you for any advice.

Any advice? I'm prejudiced and REALLY like the back pack from inmojo.com. It makes all of this as simple as Serial.print and is reminiscent of my old MS-DOS basic days... but I'm waxing nostalgic...

That is my free advice for newbies (like me!); spend an extra few $ US and buy a back pack from inmojo.com.
Save yourself hours of frustration. I've been there and know how it feels... I don't work for inmojo or get paid to promote their products; just a customer...

I did look at your picture and it appears you are EXCELLENT at soldering; much better than myself!

groundfungus:
If you include the liquidCrystal_I2C library you can use commands like lcd.print and such. You won't have to use wire.transmit and endtransmission all the time.

Not any version I've ever seen (there are several different liquidCrystal_I2c libraries out there)
Nearly all the LiquidCrystal_I2C libraries out there are for a simple PCF8574 i/o expander chip.
This board is an intelligent backpack with its own custom messaging interface so the data
communication stream is totally different.

That said, it would be fairly simple to write a device layer class for this board using
fm's LiquidCrystal library replacement:
https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home
Going that route, the standard LiquidCrystal API could be used including support for backlight control with dimming.

--- bill

bperrybap:
Other notes:
I see you are using i2c address 0x28, the default address seems to be 0x80 in the documentation.
Have you changed the default i2c address?

Maybe during some of your initial testing the device ended up in some strange state.
Have you tried doing the reset procedure to put everything back to defaults?

For the i2c adress, 0x28 is the correct adress because I have to send 7 bits and not 8 bits for the adress.

For the library, I already check those options and decide it will be more simple to use the wire command directly.
Because the library that are for lcd i2c are not working properly with my lcd. And my lcd have already a backpack with i2c connection, rs232, and other connection.

So when you fixed the code in your displayON() function,
did it fix the problem?

--- bill

bperrybap:
So when you fixed the code in your displayON() function,
did it fix the problem?

--- bill

Yes it fix the problem, one byte was missing with the DisplayOn function.