yield function????

Schematics, Example Code and Q&A
WingNut
Posts: 1
Joined: Wed Sep 05, 2018 7:14 pm

yield function????

Unread post by WingNut »

Hi,

I wrote some code for Arduino Uno, and it work great. I changed the board from the Uno to the ezSBC (ESP32) and now I get this error. I don't understand where the function is coming from as i use it or any Delay functions.

Code: Select all

#include "HX711.h"
#define DOUT  3
#define CLK  2
float seed = -385.95;

HX711 scale(DOUT, CLK);

void setup() {
  Serial.begin(9600);

  scale.set_scale(seed);

  scale.tare();
}

void loop() {
  scale.set_scale(seed);

  if (Serial.available()) {
    char z = Serial.read();

    if (z == '-') seed -= 0.1;
    if (z == '+') seed += 0.1;
  }

  Serial.print("Seed value: ");
  Serial.print(seed);
  Serial.print("\tWeight:\t");
  Serial.println(scale.get_units(10), 1);
  Serial.print("\tWeight:\t");
  Serial.println((scale.get_units(10), 1)/453.0f);
  Serial.println("\t lbs.");
}
Here is the compilation error I get:
C:\Users\LAB_BE~1\AppData\Local\Temp\arduino_build_697595/arduino.ar(esp32-hal-misc.c.o): In function `yield':

C:\Users\Lab_Bench\Documents\Arduino\hardware\espressif\esp32\cores\esp32/esp32-hal-misc.c:38: multiple definition of `yield'

libraries\HX711-master\HX711.cpp.o:C:\Users\Lab_Bench\Documents\Arduino\libraries\HX711-master/HX711.cpp:7: first defined here

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board ESP32 Dev Module.
Any ideas as to what this is about? More over, how to fix it?

Thanks
Daniel
Posts: 133
Joined: Tue Nov 13, 2012 2:10 pm

Re: yield function????

Unread post by Daniel »

I will investigate and see if I can replicate the issue.

It seems to be an error in the hardware support for the ESP32 code. Please make sure that you installed the ESP32 compilers and tools correctly. This video explains how its done
https://www.youtube.com/watch?v=DgaKlh081tU

Daniel

I replicated the issue and found that the HX711 driver has a bug that seems to be specific to the ESP32 support.

The fix is rather easy.

Find the following lines in the HX711.cpp file, very close to the beginning of the file.

#if ARDUINO_VERSION <= 106
// "yield" is not implemented as noop in older Arduino Core releases, so let's define it.
// See also: https://stackoverflow.com/questions/344 ... 5#34498165
void yield(void) {};
#endif

and delete them or simply comment out the
void yield(void) {};
line.

That fixes the issue.

Daniel
Post Reply