Help with lcd interfacing to arduino nano board

Hello,
I'm new to this forum. I'm posting this message on behalf of my son who is doing a project for his school. He wants to interface a soil moisture sensor with an LCD display through an ESP 32 board. From what i understand the sensor works and he is able to read the values online however he is not able to interface these values to a LCD screen. He has used the below circuit

https://images.app.goo.gl/TChP9ghJUuNYw9kx9

and has basically used the same code. Problem is that he is getting a blank screen. He also tried using a nano board with same results.

I'm not from the arduino school of thought and prefer discrete electronics.
Any help is welcome.

He is also a member here with a junior id and might directly reply.

It shows how to connect to a nano, not an ESP32.

basically used the same code

I don't see any code

Try this tutorial:

1 Like

Thank you for your reply.
I am going to be using the arduino nano bord insred of the esp32 as it has a bad usb socket.
I had referred to the same tutorial before but it still did not work. This is the list of events-

Bord- arduino nano, i2c board and 162a lcd.
Problem- does no work no matter what .
First used esp32 without i2c board- did not work.
Tried multiple codes - did not work.
Bought a new LCD thinking the old one was faulty- did not work.
Bought i2c board and used multiple codes - did not work .
Used arduino nano - did not work.

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x3F for a 16 chars and 2 line display

void setup() {
  lcd.init();
  lcd.clear();         
  lcd.backlight();      // Make sure backlight is on
  
  // Print a message on both lines of the LCD.
  lcd.setCursor(2,0);   //Set cursor to character 2 on line 0
  lcd.print("Hello world!");
  

The below link explains how to get help on this forum

Post your code using code tags so we can review it. It may be something simple. You may need to install a more robust I2C LCD library.

Do you know how to install a library from the Library Manager?

Try including wire:
#include Wire.h
Also try address 0x3F

This is what works for me on the Uno and Nano:

Install the LCD_I2C library using Library Manager

Load this code

#include <LCD_I2C>

LCD_I2C lcd(0x27, 16, 2);  // set the LCD address to 0x3F for a 16 chars and 2 line display

void setup() {
  lcd.begin(); // initialize the lcd
  delay (500);
  lcd.clear();
  lcd.backlight();
  
  // Print a message on both lines of the LCD.
  lcd.setCursor(2,0);   //Set cursor to character 2 on line 0
  lcd.print("Hello world!");
  

If that doesn't work, load and run this I2C Scanner code to determine the LCD I2C address

#include <Wire.h>

// Set I2C bus to use: Wire, Wire1, etc.
#define WIRE Wire

void setup() {
  WIRE.begin();

  Serial.begin(9600);
  while (!Serial)
     delay(10);
  Serial.println("\nI2C Scanner");
}


void loop() {
  byte error, address;
  int nDevices;

  Serial.println("Scanning...");

  nDevices = 0;
  for(address = 1; address < 127; address++ ) 
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    WIRE.beginTransmission(address);
    error = WIRE.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");

      nDevices++;
    }
    else if (error==4) 
    {
      Serial.print("Unknown error at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");

  delay(5000);           // wait 5 seconds for next scan
}

Let us know if this solves your problem

@srini1785 I modified your code, see if it works

#include <LiquidCrystal_I2C.h>
#include <Wire.h>

LiquidCrystal_I2C lcd(0x3F,16,2);  // set the LCD address to 0x3F for a 16 chars and 2 line display

void setup() {
  lcd.init();
  lcd.clear();         
  lcd.backlight();      // Make sure backlight is on
  
  // Print a message on both lines of the LCD.
  lcd.setCursor(2,0);   //Set cursor to character 2 on line 0
  lcd.print("Hello world!");

I neglected to mention the I2C Scanner will display information on the Serial Monitor at 9600 baud so set that up as well.

Don't forget to adjust the contrast pot on the back of the LCD at each attempt to see if that is the issue.

Thank you. i have installed the i2c library as a zip file from the web , not from library manager as i wasn't able to find it.

I used the exact code and it showed address as 0*27

Are you buying the I2C board and LCD display separately? If so, are you soldering the connections? Just sticking header pins/jumpers into the holes to make connection is highly unreliable.

Are you using the classic Nano board, with the atmega328 chip?

Lets try something a bit different, in the IDE, go to the library manager and install the "hd44780" library by Bill Perry.

Run the sketch File>Examples>hd44780>ioClass>hd44780I2Cexp>I2CexpDiag, making sure the serial monitor is set to 9600 baud.

If that library cannot find the display, there is something very wrong.

Thank you for your suggestions . i have bought the display and i2c board separately and i have soldiered the connections. i am not aware of the type of Arduino nano , but it is running on he mega328p chip. as for the library, i will definitely try it out.

How to use Library Manager:

Tools >> Manage Libraries ...
image

This window will appear. It may take some time for it to load, be patient.
Enter the target library in the search window and click Enter. Give it time to search.
Scroll down to find your library of interest. Click in that area and an "Install" button will appear.
Click it.

You're getting conflicting suggestions so I'll step aside for now.

Did your code load on the Nano without error?
Can you run the "Blink" program on the Nano, found in Files >> Examples >> Basics >> Blink?

i used the library and here is the result


it is recognizing the i2c driver but is saying that the memory test has failed.

Yes ,the blink program runs without issues.

can you post clear pictures of the solder connections, on the LCD display, I2C board, and Nano?

Check to make sure the I2C Backpack isn't touching the black metal tabs on the back of the display.
If it is, slide a business card or some sort of isolator between them to separate them.

I bend two of the tabs down prior to installing the backpack to assure they don't touch.