i am using HX711 module to get value from load cell.my projects is a tensile strength testing machine,which will increase the load gradually and break at its maximum capacity.therefore i need the maximum value at which the specimen breaks.and use that value in the code to calcuate the tensile strengh of the specimen using the formula(tensile strength=load/cross section area of specimen). Please help me with this and if possible ,i will be very gratefull if anyone can help me with the code too. Thank you

  • 1
    Please show us the code, that you already have. What is your problem with reaching the goal? Everytime, that the load increases, you measure with the load cell and save the result in a variable, but only, if it's greater, that the previous value. Sense the breaking of the specimen by checking for a large load decrease in your load cell. The saved value at this time is the absolute maximum, that was reached.
    – chrisl
    Jun 3, 2019 at 13:40
  • Thank you, i do not have any code for the project, i am new to arduino programming.i just know the basics.can you please help me with the code.? Jun 4, 2019 at 14:47
  • Thank you, The code should take the maximinum value from the load cell at which the specimen broke and use that value to calculate the tensile strengh using the formula given above i.e (maximum load÷cross section area) where cross section area is calculated by formula-((pi÷4)*(r^2)) and 'r' is entered by user which is the radius of the specimen. Jun 4, 2019 at 15:12

1 Answer 1


We won't write the code for you, since we are not a free coding service, but I will try to give you some hints, how you can do it.

  1. Timing of measurements: The measurements themselves can be done with one of the HX711 libraries, that are available on the web, but you may want to time them to get more regular measurements. This can be done in a non-blocking coding style like in the BlinkWithoutDelay example, that comes with the Arduino IDE. It involves the millis() function to measure the time since the last measurement and act accordingly. This is explained many times troughout the web and on this site.

  2. Saving the data and finding the maximum: This depends on what else you want to do with the data.

    • Saving all data for later processing: You might want to save all data (the load curve) for later use. In this case you have to define an array of appropriate length (the length depends on the duration and frequency of the measurement). Also define a position variable or pointer, that marks the current position in this array. Everytime when you do a measurement, you save the result to the array element at the saved position and increment the position variable after that. After the end of the measurement, you declare a value variable with the value of the first array element. Then you loop through all the following elements (for(int i=1;i<array_length;i++)). Inside the loop you calculate and save the maximum of 2 numbers: The value of the current array element and the saved variable. This can be done with saved_value = max(saved_value, array[i]);. When the loop is finished, you will have the maximum value in the saved_value variable.

    • No saving of data: You can also calculate a flying maximum without saving all data. Declare a variable (max_value), that will hold the maximum value, and set it to zero. Then, everytime when you do a measurement, you execute max_value = max(current_value, max_value); which calculates the maximum of the two numbers (current measurement and the previously calculated maximum). At the end of the measurement you will have the absolute maximum in the max_value variable.

  3. Sensing the end of measurement: You need to sense the end of the measurement (when the specimen breaks) (though this can be done manually if you like). For this I would suggest to calculate the speed in which the load changes. During the measurement the load will increase slowly. In the moment of breaking the load will decrease very fast. The speed between two load measurments is calculated by (value(x) - value(x-1))/measurement_interval. You can define a threshold of negative speed, so that every speed below it (faster negative decrease of load) will be sensed as breaking of specimen. You can check this on every measurement with a simple if statement, or you can calculate the speed over more than 2 consecutive measurements. That depends on the actual speed of load change and the frequency of load measurements.

  4. Calculating the tensile strength: This is just writing your formula into the code using the variable names, that you used in the previous code. Be sure to use the correct variable type for your needs. Most likely you would want to use float.

  5. Getting input from user: This depends largely on your planned means of interaction with the user. Is the Arduino connected to a PC and you use a serial terminal program? Then you can use this for user input (You might want to look at the SerialEvent example of the Arduino IDE, which shows how to work with messages and delimiter characters). Do you want to add a keypad and a LCD display? There are library available for these too, so it should not be very difficult to learn how to use then to get user input.

  • Thank you so much for the help. Jun 5, 2019 at 3:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.