No Display, No Errors - Temp, Humidity, and Weight on OLED

I’ve written this code as a kind of combination from the example code for the HX711 load sensor and the HTU21D-F Temp/Humidity sensor. The first iteration of code, I was able to get the temperature and humidity to display and continually update on the OLED, however I’m having trouble getting the third line with the current load to display.

I suspect it’s something with the way I’m defining the HX711. The previous iteration of this code, I had

// Include Libraries
#include <Arduino.h>
#include <HX711.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
#include <Adafruit_HTU21DF.h>

// Pin Definitions
#define scaledout 3
#define scaleclk 2
#define OLED_RESET 4
#define OLED128x3

Adafruit_SSD1306 display(OLED_RESET);
Adafruit_SSD1306 OLED128X32(OLED_RESET);
Adafruit_HTU21DF htu = Adafruit_HTU21DF();

// object initialization

HX711 scale;
#define calibration_factor 2280
#define SSD1306_LCDHEIGHT 32


void setup(){
  // Use of the serial monitor to print messages or data
  Serial.begin(9600);
  while (!Serial);
  Serial.println("start");

  Wire.begin();
  htu.begin();
  scale.begin(scaledout, scaleclk);
  scale.set_scale();
  scale.tare(); //Assuming no weight on teh scale at start up, reset to 0

  OLED128X32.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for 128x32)
  OLED128X32.clearDisplay(); // Clear the buffer.
  OLED128X32.display();

}

void displayTempHumidWeight(){
  delay (20);
  // Reading temperature or humidity takes about 250ms
  // Sensor readings may also be up to 2 seconds in lag


  float h = htu.readHumidity();
  // Read temperature in Celsius
  float t = htu.readTemperature();
  // Read temperature as Fahrenheit
  float scaleUnits = scale.get_units();
  // Read load as kilograms

  if (isnan(h) || isnan(t) || isnan(scaleUnits)) {
    display.clearDisplay(); 
    display.setTextColor(WHITE);
    display.setTextSize(1);
    display.setCursor(5,0);
    display.print("Couldn't read the sensor - FIX IT!");
    return;
  }
  display.clearDisplay();
  display.setTextColor(WHITE);
  display.setTextSize(1);
  display.setCursor(0,0);
  display.print("Humidity: "); 
  display.print(h);
  display.print(" %\t");
  display.setCursor(0,10);
  display.print("Temperature: "); 
  display.print(t);
  display.print(" C"); 
  display.setCursor(0,20);
  display.print("weight"); 
  display.print(scaleUnits);
  display.print("kg"); 
}

void loop(){
  displayTempHumidWeight();
  display.display();
}

I suspect it’s something with the HX711 define, originally I had it at

HX711 scale(scaledout, scaleclk);

instead of HX711 scale; but kept receiving the error below:

Temp-Humidity-Load-Display-Test-2:22:32: error: no matching function for call to 'HX711::HX711(int, int)'

 HX711 scale(scaledout, scaleclk);

                                ^

In file included from D:\Arduino\2-26\Temp-Humidity-Load-Display-Test\Temp-Humidity-Load-Display-Test-2\Temp-Humidity-Load-Display-Test-2.ino:3:0:

C:\Users\Brian Fischer\Documents\Arduino\libraries\libraries\HX711-master\src/HX711.h:30:3: note: candidate: HX711::HX711()

   HX711();

   ^

C:\Users\Brian Fischer\Documents\Arduino\libraries\libraries\HX711-master\src/HX711.h:30:3: note:   candidate expects 0 arguments, 2 provided

C:\Users\Brian Fischer\Documents\Arduino\libraries\libraries\HX711-master\src/HX711.h:19:7: note: candidate: constexpr HX711::HX711(const HX711&)

 class HX711

       ^

C:\Users\Brian Fischer\Documents\Arduino\libraries\libraries\HX711-master\src/HX711.h:19:7: note:   candidate expects 1 argument, 2 provided

exit status 1
no matching function for call to 'HX711::HX711(int, int)'

However the original example code has the same line “HX711 scale(scaledout, scaleclk);” but doesn’t show those errors.

However the original example code has the same line "HX711 scale(scaledout, scaleclk);" but doesn't show those errors.

On my IDE your code compiles. My guess is that the wrong library is included. Check the option "Show verbose output during compilation" in the IDE preferences. You get the location where the included libraries are found. Check if that matches your expectations.

pylon:
On my IDE your code compiles. My guess is that the wrong library is included. Check the option "Show verbose output during compilation" in the IDE preferences. You get the location where the included libraries are found. Check if that matches your expectations.

That's the thing, my code is compiling just fine. However, it's not displaying anything on the OLED.

Do a sanity check by writing a minimal sketch that simply reads from the HX711 and prints the value to the Serial Monitor, no code for the HTU21D-F or the LCD.

That's the thing, my code is compiling just fine. However, it's not displaying anything on the OLED.

It displays nothing? In this case the HX711 code is not responsible as you should see at least the constant text elements on the display.

No wait, why do you have two objects for the same display:

Adafruit_SSD1306 display(OLED_RESET);
Adafruit_SSD1306 OLED128X32(OLED_RESET);

Remove the second line and replace all occurrences of "OLED128X32" by "display".

pylon:
It displays nothing? In this case the HX711 code is not responsible as you should see at least the constant text elements on the display.

No wait, why do you have two objects for the same display:

Adafruit_SSD1306 display(OLED_RESET);

Adafruit_SSD1306 OLED128X32(OLED_RESET);




Remove the second line and replace all occurrences of "OLED128X32" by "display".

You are absolutely correct. Thank you, that has fixed my issue!