Experimenting with the HX711

Place your projects here
User avatar
cicciocb
Site Admin
Posts: 2195
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 470 times
Been thanked: 1461 times
Contact:

Experimenting with the HX711

Post by cicciocb »

Hi all,
I'm playing a little bit with the HX711 module and an associated load cell.
For that I did a very fast and dirty mechanical support just to start using it.
I implemented the support into Annex32 for this module and I did a little demo with this video


I'm very surprised of the stability and the repeatability of the measurements with a so simple installation.
It will be in next release
Monki
Posts: 42
Joined: Mon Feb 27, 2023 12:56 pm
Location: Berlin
Has thanked: 10 times
Been thanked: 6 times

Re: Experimenting with the HX711

Post by Monki »

Hallo cicciocb,
Das ist genau das was ich für mein Boot zur Messung des Tankinhaltes brauche.
Vielen Dank, wann wird es verfügbar sein?
Grüße
Monki
User avatar
PeterN
Posts: 403
Joined: Mon Feb 08, 2021 7:56 pm
Location: Krefeld, Germany
Has thanked: 193 times
Been thanked: 225 times
Contact:

Re: Experimenting with the HX711

Post by PeterN »

Isn't the displayed weight a bit dependent on the current (left/right) position on the long beam?
Or is the beam a bridge and therefore also supported at the right end?
User avatar
cicciocb
Site Admin
Posts: 2195
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 470 times
Been thanked: 1461 times
Contact:

Re: Experimenting with the HX711

Post by cicciocb »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Fri Mar 24, 2023 2:33 pm Isn't the displayed weight a bit dependent on the current (left/right) position on the long beam?
Or is the beam a bridge and therefore also supported at the right end?
No, the weight is independent of the position on the long beam as it is attached only on the load cell side.
User avatar
PeterN
Posts: 403
Joined: Mon Feb 08, 2021 7:56 pm
Location: Krefeld, Germany
Has thanked: 193 times
Been thanked: 225 times
Contact:

Re: Experimenting with the HX711

Post by PeterN »

ok .... but then I would expect a greater force the further to the right you go? Law of leverage?
User avatar
cicciocb
Site Admin
Posts: 2195
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 470 times
Been thanked: 1461 times
Contact:

Re: Experimenting with the HX711

Post by cicciocb »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Fri Mar 24, 2023 2:41 pm ok .... but then I would expect a greater force the further to the right you go? Law of leverage?
There will be probably an effect if the strip is very long and the weight is very high.
In the test I did the differences are negligible
The final design should be different using a plate in the middle.
User avatar
cicciocb
Site Admin
Posts: 2195
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 470 times
Been thanked: 1461 times
Contact:

Re: Experimenting with the HX711

Post by cicciocb »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Fri Mar 24, 2023 2:13 pm Hallo cicciocb,
Das ist genau das was ich für mein Boot zur Messung des Tankinhaltes brauche.
Vielen Dank, wann wird es verfügbar sein?
Grüße
Monki
Soon
User avatar
cicciocb
Site Admin
Posts: 2195
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 470 times
Been thanked: 1461 times
Contact:

Re: Experimenting with the HX711

Post by cicciocb »

For who want test, this is a "work in progress" version that includes the support for the HX711.

The function is very simple
ret = AH711(data_pin, clk_pin [,resolution])

the optional parameter resolution can be:
0 -> Input A GAIN 128 (default)
1 -> Input A Gain 64
2 -> Input B Gain 32

I'm using a load cell with a full scale range of 20 KG
You can find here a mechanic example of installation http://electroniqueamateur.blogspot.com ... duino.html

This is a demo code I'm using for the tests:
The offset and scale must be adapted in function of the load cell; you can start setting offset to 0 and the scale to 1 and then found your numbers using an object with "known" weight as reference

Code: [Local Link Removed for Guests]

dat = 32
clk = 26
dim sample(30)
weight = 0
offset = 100671 ' must be adapted to the specific load cell
scale = 0.009663 ' must be adapter to the specific load cell
samples = 5
gosub webpage
onHtmlReload webpage
while 1
  media = 0
  for r = 1 to samples
    sample(r)= hx711(dat,clk)
  next r
  'computes the average removing the lowest and the highest value
  max=sample(1)
  min=sample(1)
  sum=0
  for i= 1 to samples
    sum = sum + sample(i)
    if sample(i) > max then max=sample(i)
    if sample(i) < min then min=sample(i)
  next i
  avg = (sum - max - min) / (samples-2)
  w = avg - offset
  weight = fix(w * scale)
  wlog weight, avg

  'pause 500
wend
end

tare:
offset = avg
return

webpage:
cls
a$ = ""
a$ = a$ + CSSID$("wgt", "width:300px; font-size:150px; border:none; pointer-events:none;")
a$ = a$ + CSSID$("bt", "width:300px; height:50px")
a$ = a$ + "weight (g): " + textbox$(weight, "wgt") + "<br>"
a$ = a$ + button$("Tare", tare, "bt") + "<br><br>"
a$ = a$ + "scale: " + textbox$(scale) 

html a$
autorefresh 200
return

You do not have the required permissions to view the files attached to this post.
User avatar
Oli
Posts: 47
Joined: Tue Feb 09, 2021 10:07 am
Location: Germany, Meissen
Has thanked: 13 times
Been thanked: 45 times
Contact:

Re: Experimenting with the HX711

Post by Oli »

I wanted to ask you about the HX711.
I build an energy measuring device for DC,
I have to measure the ampere very well, and at the same time the medium exactly the volt.
It only has to work on an EPS8266.
I would be very happy about a beta-.bin
User avatar
Oli
Posts: 47
Joined: Tue Feb 09, 2021 10:07 am
Location: Germany, Meissen
Has thanked: 13 times
Been thanked: 45 times
Contact:

Re: Experimenting with the HX711

Post by Oli »

this is my testing in BascomAVR:

Config Portc = Output
Config Lcd = 20 * 4
Config Lcdmode = Port
Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5 , E = Portc.1 , Rs = Portc.0

cursor off
cls

SCK Alias Portd.4 'I use pin D.4 as output Clock
DT Alias Pind.3 'I use pin D.5 as input Databit
Config SCK = Output
Config DT = Input
'Dim Count As Long
Dim Count As long
Dim Count1 As Long
Dim Count2 As Long
dim i As Byte
dim a as Byte

anf:

For A = 1 To 5 '8 mal werte lesen
Count = 0 'reset variable
While DT = 1 'warte bis adc bereit
Wend

' 25 bis 27 pulse beim lesen bestimmen den eingang und auflösung der nächsten messung
Shiftin DT , SCK , Count , 1 , 25 , 1 'Count= -2567483648 bis +2147483392
'count = count / 262143
'count = count / 131071 '15bit Count
'count = count / 65536 '16bit Count= -32768 bis +32767
count = count / 32767 '17bit Count= -65538 bis +65538
'count = count / 16383 '18bit Count= -131080 bis +131080
count2 = count
count1 = count1 + count
next
count = count1 / 5 'die 8 werte vermitteln

home
lcd count ; " "
lowerline

lcd count1 ; " "
thirdline
count1 =0

lcd count2 ; " "


goto anf

end
Post Reply