Load Cell / Wheatstone Amplifier Shield with 12C LCD display?

I have been trying to get load cell values to display on a 12C LCD with no buttons using Robotshop Load Cell / Wheatstone Amplifier Shield.
I was using this code from the website:

strain_gauge_shield_and_lcd_arduino_uno_code

I tried to modify the code, and I have tried a few other codes as well with no luck.

I was able to see the values changing in the serial monitor with the “interface to serial code” and I can send messages to the LCD but I’m not having any luck getting it to actively display values.

any ideas how to get this to work?

I have no coding experience and I am brand new to this forum.

Thanks!

Hello @kyoboof and welcome to the RobotShop forum,

Are you able to see the values in the serial monitor using the strain_gauge_shield_and_lcd_arduino_uno_code?

Just in case you haven’t seen this tutorial this might help:

If not, are there any errors when you use the code?

Regards

Hello. Thanks for the link.

I am able to see the values in the serial monitor I can also send the LCD messages through the serial monitor by changing the code a bit, but it does not actively display anything. I do not have a LCD with the buttons and the same pin out as that one. I am using a LCD with only four connections. GND,VCC,SDA,SCL it has the 12c interface chip on the back.

I was hoping someone would be able to tell me how to make the " strain_gauge_shield_and_lcd_arduino_uno_code" code work with this set up.

I attached a photo of the back of the LCD and my current set up. Keep in mind the values displayed, are values in manually entered. The set up is not actually displaying those values.

This is the code that allowed me to send messages to the LCD and also allows me to see the values in the serial monitor. I tried to edit it abit to make it work, so it might be totally mangled.

/* Wheatstone Bridge Interface - Library */

/*
	This library was created by Sébastien Parent-Charette for RobotShop.
	It is meant to be used with the RB-Onl-38 from RobotShop.
	This product is available here: http://www.robotshop.com/en/strain-gauge-load-cell-amplifier-shield-2ch.html
	This library may work with other WheatStone bridge interface boards that use an analog pin for input.

	Changes history:
	2016-07-28
	v1.10-16
	Changed output to be on one line.
	Corrected default init of strain1 to be 1000 (instead of 750).

	2016-04-21
	v1.10-08
	Added reading and display of both load cells to the basic example.

	2015-10-08
	v1.0
	First release of the library. Basic functionality is available.
*/

#include <WheatstoneBridge.h>
/*
   Displays text sent over the serial port (e.g. from the Serial Monitor) on
   an attached LCD.
   YWROBOT
  Compatible with the Arduino IDE 1.0
  Library version:1.1
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

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


WheatstoneBridge wsb_strain1(A0, 365, 675, 0, 1000);
WheatstoneBridge wsb_strain2(A1, 365, 675, 0, 1000);

void setup()
{
  lcd.init();                      // initialize the lcd
  lcd.backlight();
  Serial.begin(9600);
  Serial.begin(9600);
  Serial.println("< Wheatstone Bridge Interface to Serial >");
  Serial.println("");
}

int val1;
int valRaw1;
int val2;
int valRaw2;

void loop()
{
  // Read strain 1
  val1 = wsb_strain1.measureForce();
  valRaw1 = wsb_strain1.getLastForceRawADC();
  Serial.println(">> Strain 1 << ");
  Serial.print("\tRaw ADC value: ");
  Serial.print(valRaw1, DEC);
  Serial.print("\t\t");
  Serial.print("\tCalculated force: ");
  Serial.println(val1, DEC);
  delay(100);

  // Read strain 2
  val2 = wsb_strain2.measureForce();
  valRaw2 = wsb_strain2.getLastForceRawADC();
  Serial.println(">> Strain 2 << ");
  Serial.print("\tRaw ADC value: ");
  Serial.print(valRaw2, DEC);
  Serial.print("\t\t");
  Serial.print("\tCalculated force: ");
  Serial.println(val2, DEC);
  Serial.println("");

  // Delay for readability
  delay(1000);
  // when characters arrive over the serial port...
  if (Serial.available()) {
    // wait a bit for the entire message to arrive
    delay(100);
    // clear the screen
    lcd.clear();
    // read all the available characters
    while (Serial.available() > 0) {
      // display each character to the LCD
      lcd.write(Serial.read());
    }
  }
}

/* Wheatstone Bridge Interface - Library */

What messages are you able to send to the LCD with this code?


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

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

WheatstoneBridge wsb_strain1(A0, 365, 675, 0, 1000);
WheatstoneBridge wsb_strain2(A1, 365, 675, 0, 1000);

void setup()
{
  lcd.init();                      // initialize the lcd
  lcd.backlight();
  Serial.begin(9600);
  Serial.println("< Wheatstone Bridge Interface to Serial >");
  Serial.println("");
}

int val1;
int valRaw1;
int val2;
int valRaw2;

// Timing management
long display_time_step = 1000;
long display_time = 0;

void loop()
{
  // Check if it is time to make a new measurement / update the display
  if(millis() > (display_time_step + display_time))
  {
    val1 = wsb_strain1.measureForce();
    valRaw1 = wsb_strain1.getLastForceRawADC();

    Serial.println(">> Strain 1 << ");
    Serial.print("\tRaw ADC value: ");
    Serial.print(valRaw1, DEC);
    Serial.print("\t\t");
    Serial.print("\tCalculated force: ");
    Serial.println(val1, DEC);

    val2 = wsb_strain2.measureForce();
    valRaw2 = wsb_strain2.getLastForceRawADC();

    Serial.println(">> Strain 2 << ");
    Serial.print("\tRaw ADC value: ");
    Serial.print(valRaw2, DEC);
    Serial.print("\t\t");
    Serial.print("\tCalculated force: ");
    Serial.println(val2, DEC);
    
    lcd.clear();
    lcd.setCursor(1, 0); lcd.print("Force 1: ");
    lcd.setCursor(9, 0); lcd.print(val1, DEC);
    lcd.setCursor(1, 1); lcd.print("Force 2: ");
    lcd.setCursor(9, 1);  lcd.print(val2, DEC);
    
    // Reset time counter
    display_time = millis();
  }
}

Does the code above work for you?

YES!!! This code works great! Thank you very much! Do you have any idea how to get it to display in LBS as well as zero it out? Thanks!

1 Like

Also, the force displays in negative values.

The negative values probably mean that you haven’t calibrated it, to do so you need to use the setup in the strain_gauge_shield_and_lcd_arduino_uno_code, however, as you mentioned you don’t have a screen with a button you will have to modify the code to have a different input, you could try using your keyboard. To zero it out or get the value in LBS you have to re-calibrate.

You can check this library to have a better idea of what I’m referring to:

Check the example at the end of this guide:
https://learn.sparkfun.com/tutorials/load-cell-amplifier-hx711-breakout-hookup-guide
PS: That library is just for reference

Thank you for all the help. Much appreciated :slight_smile:

1 Like