I would like to print a value to a screen

Hello,
I have a load cell. This bring diferent variations of numbers. I wanna to reproduce this numbers to a screen.
Thank you a lot.
LIBRARIES DOWN BELLOW

#include <HX711_ADC.h>
#include <EEPROM.h>

//HX711 constructor (dout pin, sck pin):
HX711_ADC LoadCell(3, 2);

const int eepromAdress = 0;

long t;


/////////////////////CANVI

//YWROBOT
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <LiquidCrystal_I2C.h>

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

void setup()
{

 float calValue; // calibration value
 calValue = 696.0; // uncomment this if you want to set this value in the sketch 
 #if defined(ESP8266) 
 //EEPROM.begin(512); // uncomment this if you use ESP8266 and want to fetch the value from eeprom
 #endif
 //EEPROM.get(eepromAdress, calValue); // uncomment this if you want to fetch the value from eeprom
 
 Serial.begin(9600); delay(10);
 Serial.println();
 Serial.println("Starting...");
 LoadCell.begin();
 long stabilisingtime = 2000; // tare preciscion can be improved by adding a few seconds of stabilising time
 LoadCell.start(stabilisingtime);
 if(LoadCell.getTareTimeoutFlag()) {
   Serial.println("Tare timeout, check MCU>HX711 wiring and pin designations");
 }
 else {
   LoadCell.setCalFactor(calValue); // set calibration value (float)
   Serial.println("Startup + tare is complete");
 }
 //////////////////////CANVI
  

 lcd.init();                      // initialize the lcd 
 // Print a message to the LCD.
 lcd.backlight();
 lcd.setCursor(3,0);
 lcd.print("Hello, world!");
 lcd.setCursor(2,1);
 lcd.print("Ywrobot Arduino!");
  lcd.setCursor(0,2);
 lcd.print("Arduino LCM IIC 2004");
  lcd.setCursor(2,3);
 lcd.print("Power By Ec-yuan!");

 
}


void loop()
{

//update() should be called at least as often as HX711 sample rate; >10Hz@10SPS, >80Hz@80SPS
 //use of delay in sketch will reduce effective sample rate (be carefull with use of delay() in the loop)
 LoadCell.update();

 //get smoothed value from data set
 if (millis() > t + 250) {
   float i = LoadCell.getData();
   Serial.print("Load_cell output val: ");
   Serial.println(i);
   t = millis();
 }

 //receive from serial terminal
 if (Serial.available() > 0) {
   float i;
   char inByte = Serial.read();
   if (inByte == 't') LoadCell.tareNoDelay();
 }

 //check if last tare operation is complete
 if (LoadCell.getTareStatus() == true) {
   Serial.println("Tare complete");
 }

/////////////CANVI

// lcd.clear();
// lcd.setCursor(0,0);
// lcd.print(millis()/1000.0);
// delay(200);
 //
}

libraries.zip (280 KB)

Post your code using code blocks.

What have you tried. It looks like you have initialized the LCD. Do your LCD print statements work?

Please read the sticky post at the top of the forum about how to properly post your code using code tags. It helps people help you.

If you want to print the scale value on the lcd, then move all your lcd.print() statements into the your if() statement so that the value will be available. You could also pick a better name for your variables rather than 'i' and 't'

#include <HX711_ADC.h>
#include <EEPROM.h>

//HX711 constructor (dout pin, sck pin):
HX711_ADC LoadCell(3, 2);

unsigned long lastTime;

#include <LiquidCrystal_I2C.h>

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

void setup()
{
  float calValue; // calibration value
  calValue = 696.0; // uncomment this if you want to set this value in the sketch

  Serial.begin(9600); delay(10);
  Serial.println();
  Serial.println("Starting...");
  LoadCell.begin();
  const unsigned long stabilisingtime = 2000; // tare preciscion can be improved by adding a few seconds of stabilising time
  LoadCell.start(stabilisingtime);
  if (LoadCell.getTareTimeoutFlag()) {
    Serial.println("Tare timeout, check MCU>HX711 wiring and pin designations");
  }
  else {
    LoadCell.setCalFactor(calValue); // set calibration value (float)
    Serial.println("Startup + tare is complete");
  }

  lcd.init();                      // initialize the lcd
  // Print a message to the LCD.
  lcd.backlight();
  lcd.setCursor(3, 0);
  lcd.print("Hello, world!");
  lcd.setCursor(2, 1);
  lcd.print("Ywrobot Arduino!");

  /* you only have 2 lines on your lcd so you
      can't move to lines 3 and 4

    lcd.setCursor(0, 2);
    lcd.print("Arduino LCM IIC 2004");
    lcd.setCursor(2, 3);
    lcd.print("Power By Ec-yuan!");
  */

}


void loop()
{
  LoadCell.update();

  //get smoothed value from data set
  if (millis() - lastTime >= 250) {
    float scaleValue = LoadCell.getData();
    Serial.print("Load_cell output val: ");
    Serial.println(scaleValue);
    lastTime = millis();
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print(millis() / 1000);
    lcd.setCursor(0,1);
    lcd.print(scaleValue,2);
  }

  //receive from serial terminal
  if (Serial.available() > 0) {
    char inByte = Serial.read();
    if (inByte == 't') LoadCell.tareNoDelay();
  }

  //check if last tare operation is complete
  if (LoadCell.getTareStatus() == true) {
    Serial.println("Tare complete");
  }
}

Yes it works, and the load cell give me the numbers, but I cant show the numbers to the screen.
Thanks

I did, but doesnt work, please help me.

but I cant show the numbers to the screen.

Because of this?

// lcd.clear();
 // lcd.setCursor(0,0);
 // lcd.print(millis()/1000.0);

Please remember to use code tags when posting code

No, that was a test. I would like to show the values that give me the load cell, you know?
Thanks.

Start at the beginning.
Do the messages in setup() show in the LCD?

@pepo177

Other post/duplicate DELETED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum in the future.
Other general help and troubleshooting advice can be found here.

Ok, thanks.
Yes are showed.
But the truth is that i have the code of the load cell ( is like a weighing machine) and it works, I could see the numbers of the data. This was the code
and also I have the code of the screen (is down ) but I cant mix the two codes.

//-------------------------------------------------------------------------------------
// HX711_ADC.h
// Arduino master library for HX711 24-Bit Analog-to-Digital Converter for Weigh Scales
// Olav Kallhovd sept2017
// Tested with      : HX711 asian module on channel A and YZC-133 3kg load cell
// Tested with MCU  : Arduino Nano, ESP8266
//-------------------------------------------------------------------------------------
// This is an example sketch on how to use this library
// Settling time (number of samples) and data filtering can be adjusted in the config.h file

#include <HX711_ADC.h>
#include <EEPROM.h>

//HX711 constructor (dout pin, sck pin):
HX711_ADC LoadCell(3, 2);

const int eepromAdress = 0;

long t;

void setup() {
  
  float calValue; // calibration value
  calValue = 696.0; // uncomment this if you want to set this value in the sketch 
  #if defined(ESP8266) 
  //EEPROM.begin(512); // uncomment this if you use ESP8266 and want to fetch the value from eeprom
  #endif
  //EEPROM.get(eepromAdress, calValue); // uncomment this if you want to fetch the value from eeprom
  
  Serial.begin(9600); delay(10);
  Serial.println();
  Serial.println("Starting...");
  LoadCell.begin();
  long stabilisingtime = 2000; // tare preciscion can be improved by adding a few seconds of stabilising time
  LoadCell.start(stabilisingtime);
  if(LoadCell.getTareTimeoutFlag()) {
    Serial.println("Tare timeout, check MCU>HX711 wiring and pin designations");
  }
  else {
    LoadCell.setCalFactor(calValue); // set calibration value (float)
    Serial.println("Startup + tare is complete");
  }
}

void loop() {
  //update() should be called at least as often as HX711 sample rate; >10Hz@10SPS, >80Hz@80SPS
  //use of delay in sketch will reduce effective sample rate (be carefull with use of delay() in the loop)
  LoadCell.update();

  //get smoothed value from data set
  if (millis() > t + 250) {
    float i = LoadCell.getData();
    Serial.print("Load_cell output val: ");
    Serial.println(i);
    t = millis();
  }

  //receive from serial terminal
  if (Serial.available() > 0) {
    float i;
    char inByte = Serial.read();
    if (inByte == 't') LoadCell.tareNoDelay();
  }

  //check if last tare operation is complete
  if (LoadCell.getTareStatus() == true) {
    Serial.println("Tare complete");
  }

}


and then I have the code of the screen (That it works)

[code]
//YWROBOT
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <LiquidCrystal_I2C.h>

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

void setup()
{
  lcd.init();                      // initialize the lcd 
  // Print a message to the LCD.
  lcd.backlight();
  lcd.setCursor(3,0);
  lcd.print("Hello, world!");
  lcd.setCursor(2,1);
  lcd.print("Ywrobot Arduino!");
   lcd.setCursor(0,2);
  lcd.print("Arduino LCM IIC 2004");
   lcd.setCursor(2,3);
  lcd.print("Power By Ec-yuan!");
}


void loop()
{

  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print(millis()/1000.0);
  delay(200);
}


But I cant mix the two codes
Thanks a lot

[/code]

Why can't you mix them? What have you tried?
Show that code.

Is the first one I posted.

The first code you posted doesn't print anything to the LCD after setup(), so maybe that could be part of the problem.

yes, I know that is the problem, thats why Im asking here.

So what have you tried?

const int eepromAdress = 0;

long t;


/////////////////////CANVI

//YWROBOT
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <LiquidCrystal_I2C.h>

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

void setup()
{

 float calValue; // calibration value
 calValue = 696.0; // uncomment this if you want to set this value in the sketch
 #if defined(ESP8266)
 //EEPROM.begin(512); // uncomment this if you use ESP8266 and want to fetch the value from eeprom
 #endif
 //EEPROM.get(eepromAdress, calValue); // uncomment this if you want to fetch the value from eeprom
 
 Serial.begin(9600); delay(10);
 Serial.println();
 Serial.println("Starting...");
 LoadCell.begin();
 long stabilisingtime = 2000; // tare preciscion can be improved by adding a few seconds of stabilising time
 LoadCell.start(stabilisingtime);
 if(LoadCell.getTareTimeoutFlag()) {
   Serial.println("Tare timeout, check MCU>HX711 wiring and pin designations");
 }
 else {
   LoadCell.setCalFactor(calValue); // set calibration value (float)
   Serial.println("Startup + tare is complete");
 }
 //////////////////////CANVI
  

 lcd.init();                      // initialize the lcd
 // Print a message to the LCD.
 lcd.backlight();
 lcd.setCursor(3,0);
 lcd.print("Hello, world!");
 lcd.setCursor(2,1);
 lcd.print("Ywrobot Arduino!");
  lcd.setCursor(0,2);
 lcd.print("Arduino LCM IIC 2004");
  lcd.setCursor(2,3);
 lcd.print("Power By Ec-yuan!");

 
}


void loop()
{

//update() should be called at least as often as HX711 sample rate; >10Hz@10SPS, >80Hz@80SPS
 //use of delay in sketch will reduce effective sample rate (be carefull with use of delay() in the loop)
 LoadCell.update();

 //get smoothed value from data set
 if (millis() > t + 250) {
   float i = LoadCell.getData();
   Serial.print("Load_cell output val: ");
   Serial.println(i);
   t = millis();
 }

 //receive from serial terminal
 if (Serial.available() > 0) {
   float i;
   char inByte = Serial.read();
   if (inByte == 't') LoadCell.tareNoDelay();
 }

 //check if last tare operation is complete
 if (LoadCell.getTareStatus() == true) {
   Serial.println("Tare complete");
 }

I don't see any references to the LCD in loop().

I don't know bro, I'm a noob. Thanks for your time by the way I apretiate

You can see from setup that you can print to the LCD.

I'm really struggling to see your problem.

Where you do this:

   Serial.print("Load_cell output val: ");
   Serial.println(i);

Add some lcd.prints of the same information. No doubt it will be a nasty mess.

You will then need to set cursor positions or clear the lcd or overwrite some area with spaces, but at least you'll have something showing, it's just a matter of cleaning it up.

You already know about cursor positioning - you're using it in setup.