You are reading a single comment by @AaronB and its replies. Click here to read the full conversation.
  • Hello,

    I am trying to get the HX711 IC to work with espruino. I have had some issues with getting it to work and would be very grateful if someone could advise me. The datasheet can be found at­ors/ForceFlex/hx711_english.pdf

    My code so far:

    // Strain Gauge Program for HX711
    // By: Aaron Button
    // Date: 16/05/16
    //User settable variables
    //Set Gain 1= 128, 2=32, 3=64.
    var gain = 1;
    //Calibration factor
    var calFac = -100;
    // Pin Number for strain gauge SCK
    var sgSend = C12;
    // Pin Number for strain gauge DOUT
    var sgRecieve = C10;
    //Calculated Variables
    var strain = 0;
    var weight = 0;
    var bitValue  = 0;
    var tareStrain = 0;
    //Strain Gauge
    //Define the function for the strain gauge
    function strainGauge(){
      print("running strainGauge Routine");
      //Check if the HX711 Controller is ready to transmit
      if (digitalRead(sgRecieve) === 0){
        //Run the following code 24 times
        print("sgRecieve = 0");
        for (var i=24; i>1;i--){
        digitalPulse(sgSend,1,0.001);//pulse on for 1us
        if (digitalRead(sgRecieve) == 1)//check if HX711 output if logic 1
          bitValue = Math.pow(2, i);//calculate bit value
          print("bitValue =" + bitValue);     
          strain = strain + bitValue;//add the value to the total
          print("strain =" + strain);
        // set the gain for the next transmission
          for (var o=0; o<gain;o++)//repeat the code as defined by gain
            digitalPulse(sgSend,1,0.001);//pulse on for 1us
          }// End of gain statement
          weight = (strain*calFac);
          print("weight =" + weight);
        } // End for statement
      } // End if ready to transmit function
    }// End Function strainGauge
    // Set the unladen strain to 0
    function tare(){
    // Power down the strain gauge
    function powerdown()
      digitalWrite(sgSend,1);//pulse on for 60us
    }// End of powerdown function
    // Power up after sleeping
    function powerUp()

    I am trying to measure the torque from a bicycle by measuring tension of the chain. A load cell will be cantilevered off of the frame and a idler wheel will pull the chain up by around 10 deg. I am thinking that the force pulling the pulley down will be around 20% of the total force in the chain. I would then like to use the measurement to drive a electric motor.

    I may also use it to weigh our fat cat...

    Thank you in advance


Avatar for AaronB @AaronB started