LCD light up but did not print out anything

Hi, I am new to Arduino. I need help with my project, I connected my circuit to my laptop and opened the Arduino IDE, uploaded the code, but the LCD won't print out anything. I don't know if there is any error. This is the wiring of the circuit.

This is the code.

#include "Arduino.h"
#include "DHT.h"
#include "ESP8266.h"
#include "NewPing.h"
#include "LiquidCrystal_PCF8574.h"
#include "HX711.h"


// Pin Definitions
#define DHT_PIN_DATA	4
#define WIFI_PIN_TX	11
#define WIFI_PIN_RX	10
#define GPS_PIN_TX	3
#define GPS_PIN_RX	2
#define HCSR04_PIN_TRIG	6
#define HCSR04_PIN_ECHO	5
#define SCALE_PIN_DAT	8
#define SCALE_PIN_CLK	7



// Global variables and defines
// ====================================================================
// vvvvvvvvvvvvvvvvvvvv ENTER YOUR WI-FI SETTINGS  vvvvvvvvvvvvvvvvvvvv
//
const char *SSID     = "WIFI-SSID"; // Enter your Wi-Fi name 
const char *PASSWORD = "PASSWORD" ; // Enter your Wi-Fi password
//
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// ====================================================================
char* const host = "www.google.com";
int hostPort = 80;
// There are several different versions of the LCD I2C adapter, each might have a different address.
// Try the given addresses by Un/commenting the following rows until LCD works follow the serial monitor prints. 
// To find your LCD address go to: http://playground.arduino.cc/Main/I2cScanner and run example.
#define LCD_ADDRESS 0x3F
//#define LCD_ADDRESS 0x27
// Define LCD characteristics
#define LCD_ROWS 2
#define LCD_COLUMNS 16
#define SCROLL_DELAY 150
#define BACKLIGHT 255
// object initialization
DHT dht(DHT_PIN_DATA);
ESP8266 wifi(WIFI_PIN_RX,WIFI_PIN_TX);
NewPing hcsr04(HCSR04_PIN_TRIG,HCSR04_PIN_ECHO);
LiquidCrystal_PCF8574 lcdI2C;
HX711 scale(SCALE_PIN_DAT, SCALE_PIN_CLK);
#define calibration_factor 2280 //This value is obtained using the SparkFun_HX711_Calibration sketch https://learn.sparkfun.com/tutorials/load-cell-amplifier-hx711-breakout-hookup-guide?_ga=2.77038550.2126325781.1526891300-303225217.1493631967


// define vars for testing menu
const int timeout = 10000;       //define timeout of 10 sec
char menuOption = 0;
long time0;

// Setup the essentials for your circuit to work. It runs first every time your circuit is powered with electricity.
void setup() 
{
    // Setup Serial which is useful for debugging
    // Use the Serial Monitor to view printed messages
    Serial.begin(9600);
    while (!Serial) ; // wait for serial port to connect. Needed for native USB
    Serial.println("start");
    
    dht.begin();
    wifi.init(SSID, PASSWORD);
    // initialize the lcd
    lcdI2C.begin(LCD_COLUMNS, LCD_ROWS, LCD_ADDRESS, BACKLIGHT); 
    scale.set_scale(calibration_factor); 
    scale.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0
    menuOption = menu();
    
}

// Main logic of your circuit. It defines the interaction between the components you selected. After setup, it runs over and over again, in an eternal loop.
void loop() 
{
    
    
    if(menuOption == '1') {
    // DHT22/11 Humidity and Temperature Sensor - Test Code
    // Reading humidity in %
    float dhtHumidity = dht.readHumidity();
    // Read temperature in Celsius, for Fahrenheit use .readTempF()
    float dhtTempC = dht.readTempC();
    Serial.print(F("Humidity: ")); Serial.print(dhtHumidity); Serial.print(F(" [%]\t"));
    Serial.print(F("Temp: ")); Serial.print(dhtTempC); Serial.println(F(" [C]"));

    }
    else if(menuOption == '2') {
    // ESP8266-01 - Wifi Module - Test Code
    //Send request for www.google.com at port 80
    wifi.httpGet(host, hostPort);
    // get response buffer. Note that it is set to 250 bytes due to the Arduino low memory
    char* wifiBuf = wifi.getBuffer();
    //Comment out to print the buffer to Serial Monitor
    //for(int i=0; i< MAX_BUFFER_SIZE ; i++)
    //  Serial.print(wifiBuf[i]);
    //search buffer for the date and time and print it to the serial monitor. This is GMT time!
    char *wifiDateIdx = strstr (wifiBuf, "Date");
    for (int i = 0; wifiDateIdx[i] != '\n' ; i++)
    Serial.print(wifiDateIdx[i]);

    }
    else if(menuOption == '3')
    {
    // Disclaimer: The Ublox NEO-6M GPS Module is in testing and/or doesn't have code, therefore it may be buggy. Please be kind and report any bugs you may find.
    }
    else if(menuOption == '4') {
    // Ultrasonic Sensor - HC-SR04 - Test Code
    // Read distance measurment from UltraSonic sensor           
    int hcsr04Dist = hcsr04.ping_cm();
    delay(10);
    Serial.print(F("Distance: ")); Serial.print(hcsr04Dist); Serial.println(F("[cm]"));

    }
    else if(menuOption == '5') {
    // LCD 16x2 I2C - Test Code
    // The LCD Screen will display the text of your choice.
    lcdI2C.clear();                          // Clear LCD screen.
    lcdI2C.print("  Circuito.io  ");                   // Print print String to LCD on first line
    lcdI2C.selectLine(2);                    // Set cursor at the begining of line 2
    lcdI2C.print("     Rocks!  ");                   // Print print String to LCD on second line
    delay(1000);

    }
    else if(menuOption == '6') {
    // SparkFun HX711 - Load Cell Amplifier - Test Code
    float scaleUnits = scale.get_units(); //scale.get_units() returns a float
    Serial.print(scaleUnits); //You can change this to lbs but you'll need to refactor the calibration_factor
    Serial.println(" Kg"); //You can change this to lbs but you'll need to refactor the calibration_factor
    }
    
    if (millis() - time0 > timeout)
    {
        menuOption = menu();
    }
    
}



// Menu function for selecting the components to be tested
// Follow serial monitor for instrcutions
char menu()
{

    Serial.println(F("\nWhich component would you like to test?"));
    Serial.println(F("(1) DHT22/11 Humidity and Temperature Sensor"));
    Serial.println(F("(2) ESP8266-01 - Wifi Module"));
    Serial.println(F("(3) Ublox NEO-6M GPS Module"));
    Serial.println(F("(4) Ultrasonic Sensor - HC-SR04"));
    Serial.println(F("(5) LCD 16x2 I2C"));
    Serial.println(F("(6) SparkFun HX711 - Load Cell Amplifier"));
    Serial.println(F("(menu) send anything else or press on board reset button\n"));
    while (!Serial.available());

    // Read data from serial monitor if received
    while (Serial.available()) 
    {
        char c = Serial.read();
        if (isAlphaNumeric(c)) 
        {   
            
            if(c == '1') 
    			Serial.println(F("Now Testing DHT22/11 Humidity and Temperature Sensor"));
    		else if(c == '2') 
    			Serial.println(F("Now Testing ESP8266-01 - Wifi Module"));
    		else if(c == '3') 
    			Serial.println(F("Now Testing Ublox NEO-6M GPS Module - note that this component doesn't have a test code"));
    		else if(c == '4') 
    			Serial.println(F("Now Testing Ultrasonic Sensor - HC-SR04"));
    		else if(c == '5') 
    			Serial.println(F("Now Testing LCD 16x2 I2C"));
    		else if(c == '6') 
    			Serial.println(F("Now Testing SparkFun HX711 - Load Cell Amplifier"));
            else
            {
                Serial.println(F("illegal input!"));
                return 0;
            }
            time0 = millis();
            return c;
        }
    }
}

Please help me :') Thank you.

Hi, @ndb_1500
Welcome to the forum.

Did you write this code all at once and then upload it?
If so can I suggest you do it in stages.

First stage is to write code that JUST tests the display, NOTHING else.

If it is a code you have just copied and pasted then can you please post a link to where you got it?

Thanks.. Tom.. :grinning: :+1: :coffee: :australia:

I use circuit.io to map out the circuit and copy the code from there. Here is the link, under Code section.
The Code

Hi,
Please describe what your project is?
What is it supposed to do?

Thanks.. Tom.. :grinning: :+1: :coffee: :australia:

I'm doing a project for a smart waste management system. The circuit contains a bunch of IoT sensors that collect data for the system, and it will be attached to a bin. The system that I built should be able to monitor garbage bin fill levels in real time and read the humidity and temperature of the surroundings.

To work properly the correct I2C address and LCD to I2C expander backpack pin mapping must be correct. The LiquidCrystal_I2C defaults may not be correct.

Get the LCD working by itself before adding extra complexities.

The hd44780 library (install with the IDE library manager) will automatically determine the address and pin mapping. Use the hd44780_I2Cexp class. Included with the library are examples, a diagnostic and Hello World sketches.

OK, but have you tried a "Hello World" example just with the display ?

There are examples of its use in the IDE

Have you tried adjusting the contrast pot on the display ?

Hi, @ndb_1500
Did you write this code?

Thanks.. Tom... :grinning: :+1: :coffee: :australia:

Yes, I already tried a "Hello World" example and it display on the LCD. I also tried adjusting the contrast pot on the display.

No, I copy it from here, under the Code section.

I already did the basic "Hello World" and it works, but when adding the complexities, it does not work.

At what point does it stop ?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.