Data not showing on LCD

I am using this sketch to show the temperature from a LM35 sensor. The data or readings is displayed in the serial monitor, but not the 16x2 lcd.

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float voltage = sensorValue * (5.0 / 1023.0);
  float temperature = voltage*100;
  // print out the value you read:
  Serial.println("Voltage : ");
  Serial.println(voltage);
  Serial.println("Temperature : ");
  Serial.println(temperature);
  lcd.setCursor(0,0);
  lcd.print("T :");
  lcd.print(temperature);
  lcd.print((char)223);
  lcd.print("C");
  delay(500);
}

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

Please post your sketch, using code tags when you do

Posting your code using code tags prevents parts of it being interpreted as HTML coding and makes it easier to copy for examination

In my experience the easiest way to tidy up the code and add the code tags is as follows

Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

Apologies, I forgot to do that but have now,

Thank you

Hi, @avalon66

Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

Please post your complete code.

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

Picture as requested. the yellow lead is SCL and the green lead is SDA
The other yellow lead is +Vcc and the black one is -Vcc

Hi,

And we need to see your full code.

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

+1
The code in post #1 is a snippet. We can't see what library you're using nor the LCD object creation.

Wiring looks ok, if the wires are firmly connected to the Uno and to the breadboard.

The full code or sketch is in my 1st post, unless you mean something else.

@Brazillino,
That is the the full code, which I got from here:

No, it's not. As presented in the opening post there is e.g. no setup() function, there is no declaration for the lcd object and probably a lot more that we don't know about.

Ok, fair dos then.
this one also does not show anything on the lcd screen:

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  lcd.init();
  lcd.backlight();
  lcd.print("LM35 Test");
  delay(1000);
}
// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float voltage = sensorValue * (5.0 / 1023.0);
  float temperature = voltage*100;
  // print out the value you read:
  Serial.println("Voltage : ");
  Serial.println(voltage);
  Serial.println("Temperature : ");
  Serial.println(temperature);
  lcd.setCursor(0,0);
  lcd.print("T :");
  lcd.print(temperature);
  lcd.print((char)223);
  lcd.print("C");
  delay(500);
}

The setup part of the sketch worked ok on Wokwi. So, my next hypotheses are:

  1. one or more wires are not ok. Re-check them all and test with a DMM if you have one;
  2. change the LCD adress to 0x3F and see if it works. If not, upload the I2C scanner sketch and see if it finds the LCD;
  3. this LCD or its I2C backpack is dead.

#include <LiquidCrystal_I2C.h>

I would recommend that you use the currently best available library for the i2c lcd modules which is Bill Perry's hd44780.h. It is available through the library manager.

It will auto configure the i2c address and the pin configuration. There is a comprehensive diagnostic sketch as part of the library if there are any issues. Reference material is here.

Install the library, using the library manager, and this sketch should work with your device. If not, run the diagnostic sketch I2CexpDiag and report the results.

#include <Wire.h>
#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Cexp.h> // include i/o class header for i2c expanders

hd44780_I2Cexp lcd; // declare lcd object: auto locate & config display for hd44780 chip

void setup()
{
// initialize LCD with number of columns and rows:
lcd.begin(16,2);

// Print a message to the LCD
lcd.print("Hello, World!");
}

void loop()
{
lcd.setCursor(0, 1);
lcd.print(millis() / 1000);
delay(1000);
}

The wires check out ok thanks. I've just run I2C scanner sketch which should display the address of the I2C lcd, but it can't find the device.. I only bought it yesterday, and it looks like it' faulty

Sad to hear that, but sometimes it just happens.
@cattledog gave a good tip on post #14. It worth a try before you return it back to the dealer.

I installed the HD44780 library in the sketch, but it made no difference, so the lcd is going back for another one.
thanks

Are these soldered?

Yes most defintly, I went over the pins again with my hot soldering iron