ESP 32 + HX711 + LoadCell / 'yield' causes problems while uploading the sketch

Hi folks,

I try this setup for doing this project:

  • Arduino: 1.8.4 (Mac OS X)
  • Board: "DOIT ESP32 DEVKIT V1
  • HX711 load cell amplifiyer
  • hx711.h library from here
  • H20A load cell

Uploading this sketch...

#include "HX711.h"

// HX711.DOUT	- pin #A1
// HX711.PD_SCK	- pin #A0

HX711 scale(11, 12);		// parameter "gain" is ommited; the default value 128 is used by the library

void setup() {
  Serial.begin(38400);
  Serial.println("HX711 Demo");

  Serial.println("Before setting up the scale:");
  Serial.print("read: \t\t");
  Serial.println(scale.read());			// print a raw reading from the ADC

  Serial.print("read average: \t\t");
  Serial.println(scale.read_average(20));  	// print the average of 20 readings from the ADC

  Serial.print("get value: \t\t");
  Serial.println(scale.get_value(5));		// print the average of 5 readings from the ADC minus the tare weight (not set yet)

  Serial.print("get units: \t\t");
  Serial.println(scale.get_units(5), 1);	// print the average of 5 readings from the ADC minus tare weight (not set) divided 
						// by the SCALE parameter (not set yet)  

  scale.set_scale(2280.f);                      // this value is obtained by calibrating the scale with known weights; see the README for details
  scale.tare();				        // reset the scale to 0

  Serial.println("After setting up the scale:");

  Serial.print("read: \t\t");
  Serial.println(scale.read());                 // print a raw reading from the ADC

  Serial.print("read average: \t\t");
  Serial.println(scale.read_average(20));       // print the average of 20 readings from the ADC

  Serial.print("get value: \t\t");
  Serial.println(scale.get_value(5));		// print the average of 5 readings from the ADC minus the tare weight, set with tare()

  Serial.print("get units: \t\t");
  Serial.println(scale.get_units(5), 1);        // print the average of 5 readings from the ADC minus tare weight, divided 
						// by the SCALE parameter set with set_scale

  Serial.println("Readings:");
}

void loop() {
  Serial.print("one reading:\t");
  Serial.print(scale.get_units(), 1);
  Serial.print("\t| average:\t");
  Serial.println(scale.get_units(10), 1);

  scale.power_down();			        // put the ADC in sleep mode
  delay(5000);
  scale.power_up();
}

...causes the following problem:

Arduino: 1.8.4 (Mac OS X), Board: "DOIT ESP32 DEVKIT V1, 80MHz, 921600, None"

Archiving built core (caching) in: /var/folders/71/5csrzsms2ql656c5g1brxsyc0000gn/T/arduino_cache_248763/core/core_espressif_esp32_esp32doit-devkit-v1_FlashFreq_80,UploadSpeed_921600,DebugLevel_none_81022c23036f627a596faae2df69ec69.a
arduino.ar(esp32-hal-misc.c.o): In function yield': /Users/Michael/Documents/Arduino/hardware/espressif/esp32/cores/esp32/esp32-hal-misc.c:36: multiple definition of yield'
libraries/HX711-master/HX711.cpp.o:/Users/Michael/Documents/Arduino/libraries/HX711-master/HX711.cpp:7: first defined here
collect2: error: ld returned 1 exit status
exit status 1
Fehler beim Kompilieren für das Board DOIT ESP32 DEVKIT V1.

Dieser Bericht wäre detaillierter, wenn die Option
"Ausführliche Ausgabe während der Kompilierung"
in Datei -> Voreinstellungen aktiviert wäre.

I hope someone can help me with this issue, because I do notknow what to do with this information about "yield".

THX

Michael

This file contains a function named yield which conflicts with a function with the same name in the ESP32 support code. Change the name of the function to something else. Or try a different hx711 library that does not contain a yield function.

/Users/Michael/Documents/Arduino/libraries/HX711-master/HX711.cpp

As suggested when you move to ESPs. Modification of the HX711 library file will fix this. I suggested commenting out the lines in the hx711.cpp… see below. (unless you need to stay compatible with very old version of the compiler/Ardiuno).

/*
#if ARDUINO_VERSION <= 106
// “yield” is not implemented as noop in older Arduino Core releases, so let’s define it.
// See also: esp8266 - What is the secret of the arduino `yield()`function? - Stack Overflow
void yield(void) {};
#endif
*/