Nhd-0420d3z-nsw-bbw-v3 displaying vertical lines after every character in a sentence

Hello!
For my internship project I have to use the nhd-0420d3z-nsw-bbw-v3 20x4 LCD display to display pressure and temperature.
The display is connected via I2C with an Arduino uno.
When I run my code (still only displays press: and temp: while refreshing every 2 seconds) the words have a vertical line inbetween every character (picture included).
Has anybody experienced a problem like this or a solution?
Thanks!

#include <Wire.h>

#define LCD_I2C_ADDRESS 0x28

void setup() {
  Wire.begin();
  pinMode(A4, INPUT_PULLUP);
  pinMode(A5, INPUT_PULLUP);
  delay(200); // Wait for the LCD to initialize (at least 100ms according to the datasheet)
  sendCommand(0xFE, 0x41); // Turn on display
  setBrightness();
  delay(100);
  clearScreen();
}

void loop() {
  // Set cursor position to the beginning of the second line (row 1)
  // Display "Hello, World!" on the LCD
  displayText("Press: ", 0x00);
  displayText("Temp: ", 0x40);

  delay(2000); // Wait for 2 seconds
  clearScreen(); // Clear the screen for the next message
  delay(1000); // Wait for 1 second before repeating the loop
}

void sendCommand(byte prefix, byte command) {
  Wire.beginTransmission(LCD_I2C_ADDRESS);
  Wire.write(prefix);
  Wire.write(command);
  Wire.endTransmission();
  delay(1); // Delay to ensure commands are processed properly
}

void setCursor(byte pos) {
  sendCommand(0xFE, 0x45); // Set cursor command
  delayMicroseconds(100);
  sendCommand(pos, 0x00); // Set cursor position
  delayMicroseconds(100);
}

void clearScreen() {
  sendCommand(0xFE, 0x51); // Clear screen command
  delay(1500); // Wait for the screen to clear
}

void displayText(const char *text, byte pos) {
  setCursor(pos); // Set cursor position
  while (*text) {
    sendCommand(0x00, *text); // Display character command
    delayMicroseconds(100); // Wait for the character to be written (adjust delay if necessary)
    text++;
  }
}

void setBrightness() {
  sendCommand(0xFE, 0x53);
  sendCommand(0x08, 0x00);
}

You need to solder the wiring to the display, or it will never produce reliable results.

I just soldered the wiring and connected 6k ohm resistors to the SDA and SCL lines but the problem still persists

It seems likely that you are sending incorrect commands to the display. Post a link to the display data sheet.

Here is a link to the datasheet.

NHD-0420D3Z-NSW-BBW-V3.pdf (newhavendisplay.com)

What happens if you send only the character, without a preceding 0x00?

The code can't compile because it needs a command (0x00) in front of it

This can't be true. The compiler knows nothing about which command is needed for display.
Please show an exact error message


It is unfortunately

Where did you get this from? There are no commands starting from 0x00 in the datasheet.

The cause of the error is because your code for displaying text is incorrect. . No commands are needed to display characters. You just send character after character, that's all. See the example linked in the datasheet on page 14.

I Thought the 0x00 in the description would act as the command.
I'm new the whole arduino coding so sorry if I make some dumb mistakes
Capture

Where exactly did you find this in the example code?
Could you maybe send a screenshot?

Printing the text "Serial LCD Demo" at the cursor position 0x40:

lcd_cursor(0x40);
delay_ms(100);
	
	for (i = 0; i < 16; i++) {	//"Serial LCD Demo"
		tx_packet[i] = text7[i];
	}
	
send_packet(16);

As you can see, the text transferred char by char without any commands between it.
You can just to copy the procedures lcd_cursor() and send_packet() to your code.

As for me, this table row means that the both command and prefix are not sended

Are you sure this is code for the arduino because I get a whole bunch of errors when I add this to my code

Stage\Arduino\LCD_press_test\LCD_press_test.ino: In function 'void loop()':
Stage\Arduino\LCD_press_test\LCD_press_test.ino:17:3: error: 'lcd_cursor' was not declared in this scope
   lcd_cursor(0x40);
   ^~~~~~~~~~
Stage\Arduino\LCD_press_test\LCD_press_test.ino:17:3: note: suggested alternative: 'setCursor'
   lcd_cursor(0x40);
   ^~~~~~~~~~
   setCursor
Stage\Arduino\LCD_press_test\LCD_press_test.ino:18:3: error: 'delay_ms' was not declared in this scope
   delay_ms(100);
   ^~~~~~~~
Stage\Arduino\LCD_press_test\LCD_press_test.ino:18:3: note: suggested alternative: '_delay_ms'
   delay_ms(100);
   ^~~~~~~~
   _delay_ms
Stage\Arduino\LCD_press_test\LCD_press_test.ino:20:10: error: 'i' was not declared in this scope
     for (i = 0; i < 16; i++) { //"Serial LCD Demo"
          ^
Stage\Arduino\LCD_press_test\LCD_press_test.ino:21:7: error: 'tx_packet' was not declared in this scope
       tx_packet[i] = text7[i];
       ^~~~~~~~~
Stage\Arduino\LCD_press_test\LCD_press_test.ino:21:22: error: 'text7' was not declared in this scope
       tx_packet[i] = text7[i];
                      ^~~~~
Stage\Arduino\LCD_press_test\LCD_press_test.ino:24:3: error: 'send_packet' was not declared in this scope
   send_packet(16);
   ^~~~~~~~~~~

exit status 1

Compilation error: 'lcd_cursor' was not declared in this scope

The arduino code uses C/C++ language, this code is C language too. Perhaps you have a slightly adapted it to work with arduino libraries.

Hmm looks difficult but I'll give it a try.
The thing which I don't understand is, why would the lcd screen still print these characters in the original code, just in a weird way

Of course, you must declare all variables, create all the specified procedures and data structures in your code.
But you always have to do this when you add someone else’s code to your program; Arduino has nothing to do with it.

Because the display treated 0x00 as a character and printed it between other letters. Codes from 0x00 to 0x07 are reserved for special characters that can be changed. Apparently under code 0x00 you have a symbol "||"

6 posts were split to a new topic: The ChatGPT war rages on