This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

HX711 with nRF52832

Hey all, I am bit late to the party but I was following Vidar's HX711 Library and was able to configure it to work after a long period of time (Pardon me, I am new to this).

I am currently using the 15.2 SDK and ADC measurement is populating as per normal.. However, I was not able to broadcast my output from ADC measurements to the nRF UART v2.0 android application, and I could not find a way to convert the 'measurements' into a desirable results in weight or kilograms. Another question I have is if there is a need to configure VDD pinout. I have not altered any codes besides the SCK and DOUT pins. Any help will be appreciated. Thanks all!

Parents Reply Children
  • Hello,

    Loadcells tend to be quite linear, so I think simple linear regression with 2 or more calibrations points should give you a fairly accurate conversion. The conversion may look something like this in your code:

    float weight;
    
    /* Convert ADC reading to a weight measurement */
    weight = (raw_sample * x + b) // 'x' and 'b' can be found using linear regression: https://stackoverflow.com/questions/5083465/fast-efficient-least-squares-fit-algorithm-in-c 

     

    Another question I have is if there is a need to configure VDD pinout.

    This is ok. You don't have to supply it through a GPIO.

    nRF UART v2.0 android application

     Recommend you use the UART app inside the nRF toolbox container app, or nRF connect. nRF UART v2.0 is deprecated. And remember that the received values will not be encoded as a ASCII text string, but the integer value.

    kennethaw said:
    Also, I have note that I will have to configure optimization level to at least level 1 in order to populate the results, else it will print 'ADC readout error' with a bunch of hexadecimals..

     The hx711.c needs to be built with optimization as you say. The program will not be able to read the GPIO input fast enough otherwise.

  • Hey Vidar, many thanks for your assistance and years of service. As you mentioned nRF UART v2.0 is deprecated hence I switched to nRF Toolbox but I was not able to get any results, Rx transmitted.. It only shows connected.

  • Hi,

    I'm happy to help:) Do you see any received data if you inspect the log? Screenshot below shows when the text string "hello" is received from the peripheral.

    Edit: Note that you can use sprintf or similar to convert the decimal value to a text string before you send it over BLE.

  • Hello, good afternoon to you..

    Attached is my data received, or the output received from peripheral.. Also, do you have any examples for sprintf? If it is possible, can you send a code snippet for the conversion on the application itself? Thank you Vidar!

  • Also, sometimes the connection with the peripheral is a bit odd, it often does not establish a connection and shows connecting for a long period of time..

Related