Load cell for rocket thrust – with Arduino

MATERIAL:

  • Arduino
  • Load cell (10 kg in my case)
  • Module HX711
  • Button + led (optional)
  • 3D printer for plastic stuff

CONNECTIONS:

In my case load cell have 4 wires (module connection): red (E+) black (E-) white (A+) green (A-). From the module you have to connect DT and SCK to Arduino digital pins (2 and 3). I added a button to start and stop the sampling, to do this you need to read another digital pin (6).

ARDUINO CODE:

hx711.h library

#include "HX711.h"

HX711 scale(2, 3); //DT pin 2 SCK pin 3
float scale_par;   //variable for calibration
float offset;
int inputPIN = 6;  //input button pin
int LED = 7;       //output led pin
void setup() {
  //STARTING CALIBRATION
  Serial.begin(9600);
 
  //scale.set_scale();
  //scale.tare();

  pinMode(inputPIN, INPUT); 
  pinMode(LED, OUTPUT);
  digitalWrite(LED, LOW); //set led pin to LOW
  
  Serial.println("offset 0gr press a key");
  while (!Serial.available()) {} //wait for an input character
  
  offset = scale.read_average(); //perform an averaged reading
  Serial.print("offset ");
  Serial.println(offset); 
  Serial.println("wight 200 gr and press a key");
  (void)Serial.read();           //need this for the next command
  while (!Serial.available()) {} //wait for an input character
 
  float cal = scale.read_average()-offset; 
  float peso = 200.0f;  
  scale_par = cal / peso;       //calibration coefficient
  
  Serial.print("cal: ");
  Serial.println(scale_par);
  Serial.print("weight: ");
  Serial.println(cal/scale_par); 
  Serial.print("Press a key to continue"); 
  Serial.println();    
  (void)Serial.read();
  while (!Serial.available()) {} //wait for an input character
  //END CALIBRATION
  
                
}

void loop() 
{
    float peso; //weight
    float time_start; 
    float time_end;
    int cont = 0;
    while(digitalRead(inputPIN) == HIGH)   //if button is pushed
    {
        if(cont == 0)
        {
          time_start = millis(); //start time recording
          digitalWrite(LED, HIGH); //led on
          cont = 1; //need for starting time recording only once time
          
        }
 
        peso = scale.read() - offset;  //reading weight
        
        Serial.println(peso/scale_par); //print weight
        
    }
    if(cont == 1)
    {
      time_end = millis();
      Serial.println("time [ms]:");
      Serial.println(time_end-time_start);
      digitalWrite(LED, LOW); //LED off
      cont = 0;
   }
} 

3D PRINT STUFF