Servo.h and HX711.h seem to interfere - any idea?

Hi there,

I am working on an electric drive for a Stand Up Paddling board. The thruster T200 from Blue Robotics has a brushless motor and is controlled by an ESC using servo signals as provided by servo.h.

For the development I have built a test stand with a load cell so that I can measure the thrust of the motor in kg.

The setting of the speed/power with the servo library works well - and I can also read a meaningful weight (that is thrust) signal using HX711.

However, I observed an intermittent problem: every once in a while I observe a sudden and short increase in RPM of the Motor. This takes only a split second - but at medium speeds it rally causes the setup to shake - it really gives the motor strong push. The behavior shows up in irregular intervals, every 5 to 20 seconds, no systematics visible in the occurrence. The behavior shows up also in idle mode (servo set to midpoint 1500) - in this case, the motor accelerates for a split second every once in a while.

The whole sketch is quit long as it includes a display, three button control, … but I isolated the problem by deleting everything possible and below you find the bare minimum sketch that reproducibly reproduces the error.

As you can see: the sketch is extremely short: just defining the pins for servo and load cell, including the two libraries, followed by initializing of the load cell and the servo (setting to midpoint) in the setup-part and the loop does nothing but reading the load cell.

With this minimum sketch to problem shows up as described above. If I comment out the reading of the load in the loop, the problem disappears. So, I would conclude that the command ThrustCell.get_units() sometimes slows down the servo output (resulting in acceleration of the motor).

Is this a known issue?

Are there any workarounds?

Thanks a lot for any help,


#define Pin_ServoOut 5

#define Pin_Thrust_Clk 16
#define Pin_Thrust_Data 17

#define ThrustFactor -232000

#include <Servo.h>
Servo Servo_1;  // create servo object to control the motor

#include <HX711.h>
HX711 ThrustCell; // Creates load cell object for thrust measurement on test stand

float Thrust; //kg

void setup() {
  Servo_1.attach(Pin_ServoOut);  // attaches the servo on Pin_ServoOut to the servo object
  Servo_1.writeMicroseconds(1500); // neutral position

  ThrustCell.begin(Pin_Thrust_Data, Pin_Thrust_Clk);

void loop() {
  Thrust = ThrustCell.get_units(); // If I comment this line out the interference does not occur

I'm not shure whether your problem is connected to the blocking nature of many HX711 libraries,
but you could try a non-blocking variant GitHub - whandall/NBHX711: A non-blocking Avia HX711 library for Arduino,