-1

I am currently working on a IOT Project in which I am trying to interface Loadcell and Sparkfun's Qwiic Scale NAU7802 so that I can read Weight and Show it on Seven Segment Display.

For this I connected Following Pins :-

ESP32 Pin Qwiic Scale Pin
36 (GPIO 22) SCL
33 (GPIO 21) SDA
2 (3V3) 3V3
38 (GND) GND

First I Calibrated my Loadcell with 5 Kg Weight. After that I tried Fetching Weight From Qwiic Scale And Showing it on Seven Segment Display simultaneously using threading.
After Calibrating I placed same 5 kg weight on Loadcell to check readings, But I am getiing variable readings. I tried this loop of calibration and checking the output many many times but my output is still variable. Readings are very Fluctuating, around 50grams for 5kg.

4.985
5.015
4.965
4.99
5.025
5.04
5.025
5.025
5.025
4.995
5.025
5.01
4.99
5.01
5.01
5.05
4.99
5.03
4.985
5.015
5.015
5.015
4.995
4.96
5.01
5.01
4.995
4.995
4.995
4.995
4.995
5.015
4.985
5.0
5.0
5.025
5.04
4.985
5.01
5.025
5.025
5.045
5.03
5.005
5.005
5.005
5.005
5.025
5.005
5.005
4.975
5.025
5.045
5.005

Code I used >>

scale = QwiicScale() # Created Qwiic Scale Object
s = SevenSegment(scale) # Created Seven Segment Object

# Calibration code  
OF = scale.getZeroOffsetFromQwiic() # Get Offset From Loadcell without putting any weight
# Place Known Weight
KnownWeight = float(input('Enter Known Weight : ')) # Take input known Weight
cal = scale.getCalibrationFactorFromQwiic(KnownWeight) # Calculate Calibration Factor

#Created Thread for showing weight on Seven Segment Display
SevenSegmentThread = Thread(target=s.ShowOnSevenSegment)
SevenSegmentThread.start() #ran that thread here

# Loop continuously running to get weight and setting it to Seven Segment
while KeyboardInterrupt:
    Weight = float(scale.getWeightFromQwiicScale())
    print(Weight)
    Weight = str(int(Weight*1000))
    s.SetWeight(''.join(reversed(Weight)))

My Output without using threading >

4.995
4.995
4.995
4.995
4.995
4.995
4.995
5.01
5.01
5.01
5.01
5.01
5.01
5.01
5.01
5.01
5.01
5.01
5.01
5.01
5.01
5.01
5.01
5.01
5.01
5.01
5.01
5.01
5.01
5.01
5.01
5.01
5.01
5.01
5.01
5.01

Why does my output is variable, If I implement threading ?

Any Suggestion or help is much appreciated .....
Thanks in Advance...

BoGTx0705
  • 11
  • 1
  • 4
  • Seems to match what's shown on [the official guide](https://learn.sparkfun.com/tutorials/qwiic-scale-hookup-guide#examples), where it varies from 4.23 to 4.28 – gre_gor Jan 11 '22 at 14:31

2 Answers2

0

That's quite normal. Load cells create tiny changes in voltage, which get amplified by the chip measuring the H-bridge output. The amplification creates noise which gives you a slightly different reading each time. A fluctuation of less than 0.5% is a rather clean result, by the way. Welcome to measuring things in the real world.

Anyway, round it to about 1% and you're done. The measurement accuracy of cheap bathroom scale load cells won't give you much more resolution anyway.

Tarmo
  • 3,728
  • 1
  • 8
  • 25
  • Firstly, Thanks for Reply. but I am not using any cheap Bathroom Scale , I bought it from Industrial Loadcell Reseller having a range of 200 Kg. And it does gives me accurate reading if I remove every thread in ESP32. What my question here is, after implementing threading why is it giving me Variable readings ? – BoGTx0705 Jan 17 '22 at 05:59
  • The operation of reading the result could be sensitive to timing. Which sounds like a bit of a bummer, because you'd probably need a much more complex solution than a synchronous Python driver to complete the operation in an uninterrupted manner. – Tarmo Jan 17 '22 at 14:32
0

I came across this conversation while researching a different problem. I am going to suggest that the noise you see during multi-threading is due to small fluctuations in the supply voltage on the i2c bus to the QwiicScale board which, in turn, would cause a similar variation in V+ to the load cell. Thread switching on your ESP32 may cause a load condition that pushes the limits of the on-board voltage regulator. Digital circuits don't care about a 1% voltage swing but analog circuits would be quite sensitive to that! Try adding a capacitor to the load cell supply voltage line to see if that improves your results.

Alan
  • 1