Weight Scale on ESP32-C3 on Liliygo T-Zigbee Board

TinTin
Posts: 3
Joined: Sat Jun 08, 2024 10:07 am

Weight Scale on ESP32-C3 on Liliygo T-Zigbee Board

Postby TinTin » Sat Jun 08, 2024 11:27 am

Hello,
i'm trying to build an weight scale with with the Liliygo T-Zigbee Board using an HX711 and 4x 50kg weight cells. I get different reading on every calibation and the reading dont really change as expeced on adding or removing weights on the cells and the measurement drifts.

I have rewired it multiple times already to make sure there are no mistakes there. I changed the the DT and SCK Pin connection to other GPIO-Pins without success.
I don't really know what else could be wrong. Could someone take a look and give me advice what i should change to get correct measurement and calibation.

The HX711 and the loadcells are wired like this


HX711 wiring.PNG
HX711 wiring.PNG (20.05 KiB) Viewed 609 times
The HX711 is currently connected to the board as follows

GND -> GND
DT -> GPIO08
SCK -> GPIO06
VCC-> 3.3V

And The Pins on the board are like this
PINMAP.PNG
PINMAP.PNG (322.66 KiB) Viewed 609 times
This is my current code
  1. #include <Arduino.h>
  2. #include "HX711.h"
  3. #include "soc/rtc.h"
  4.  
  5. HX711 scale;
  6.  
  7. uint8_t dataPin  = 8;
  8. uint8_t clockPin = 6;
  9.  
  10. void setup()
  11. {
  12.   delay(2000);
  13.   Serial.begin(115200);
  14.   Serial.println();
  15.  
  16.     rtc_cpu_freq_config_t config;
  17.     rtc_clk_cpu_freq_get_config(&config);
  18.     rtc_clk_cpu_freq_mhz_to_config(80, &config);
  19.     rtc_clk_cpu_freq_set_config_fast(&config);
  20.  
  21.   scale.begin(dataPin, clockPin);
  22. delay(2000);
  23.   Serial.print("UNITS: ");
  24.   Serial.println(scale.get_units(10));
  25.  
  26.   Serial.println("\nEmpty the scale, press a key to continue");
  27.   while(!Serial.available());
  28.   while(Serial.available())
  29.   Serial.read();
  30. delay(5000);
  31.  
  32.   scale.tare();
  33.   Serial.print("UNITS: ");
  34.   Serial.println(scale.get_units(10));
  35.  
  36.  
  37.   Serial.println("\nPut 1000 gram in the scale, press a key to continue");
  38.   while(!Serial.available());
  39.   while(Serial.available()) Serial.read();
  40. delay(5000);
  41.   scale.calibrate_scale(1000, 5);
  42.   Serial.print("UNITS: ");
  43.   Serial.println(scale.get_units(10));
  44.  
  45.   Serial.println("\nScale is calibrated, press a key to continue");
  46.   Serial.print("Scale:");
  47.    Serial.println(scale.get_scale());
  48.    Serial.print("OFFSET:");
  49.    Serial.println(scale.get_offset());
  50.   while(!Serial.available());
  51.   while(Serial.available()) Serial.read();
  52. Serial.println("");
  53. Serial.println("");
  54. Serial.println("");
  55.   Serial.print("UNIT");
  56.   Serial.print("\t;");
  57.   Serial.print("VALUE");
  58.   Serial.print("\t;");
  59.   Serial.println("READ");
  60.  
  61. }
  62.  
  63.  
  64. void loop()
  65. {
  66.   long UNIT = scale.get_units(1);
  67.   long VALUE = scale.get_value(1);
  68.   long READ = scale.read();
  69.   Serial.print(UNIT);
  70.   Serial.print("\t;");
  71.   Serial.print(VALUE);
  72.   Serial.print("\t;");
  73.   Serial.println(READ);
  74.  
  75. }
  76.  
The output and measurement i get while an 1000g wheight is on the scale is as follows
  1. UNITS: -158241.80
  2.  
  3. Empty the scale, press a key to continue
  4. UNITS: -111.80
  5.  
  6. Put 1000 gram in the scale, press a key to continue
  7. UNITS: 13139.30
  8.  
  9. Scale is calibrated, press a key to continue
  10. Scale:-0.01
  11. OFFSET:-158227
  12.  
  13.  
  14.  
  15. UNIT    ;VALUE  ;READ
  16. 3610    ;-81    ;-158274
  17. 802     ;-62    ;-158252
  18. -401    ;28     ;-158202
  19. 4312    ;-45    ;-158268
  20. 200     ;12     ;-158177
  21. -4312   ;14     ;-158238
  22. 2607    ;-43    ;-158222
  23. 2908    ;-37    ;-158332
  24. 17953   ;-106   ;-158299
  25. 17151   ;-174   ;-158385
  26. 14242   ;-168   ;-158421
  27. 17351   ;-242   ;-158470
  28. 16750   ;-132   ;-158338
  29. 14142   ;-172   ;-158376
  30. 16449   ;-118   ;-158285
  31. 6018    ;-135   ;-158279
  32. 7622    ;-78    ;-158302
  33. 11033   ;-102   ;-158320
  34. 9929    ;-59    ;-158316
  35. 12236   ;-111   ;-158337
  36. 5416    ;-72    ;-158386
  37. 9227    ;-75    ;-158308
  38. 8625    ;-140   ;-158386
  39. 12938   ;-129   ;-158337
  40. 11534   ;-168   ;-158348
  41. 5616    ;-20    ;-158273
  42. 8425    ;-100   ;-158285
  43. -200    ;18     ;-158138
  44. -9929   ;101    ;-158131
  45. -9628   ;143    ;-158042
  46. -23269  ;201    ;-158004
  47. -28886  ;216    ;-158027
  48. -18856  ;138    ;-158130
  49. -20260  ;240    ;-157978
  50. -20461  ;182    ;-157996
  51. -23169  ;203    ;-158000
  52. -26579  ;218    ;-158048
  53. -15145  ;143    ;-158126
  54. -7422   ;55     ;-158172
  55. -3510   ;27     ;-158168
  56. -1705   ;14     ;-158158
  57. -7923   ;23     ;-158220
  58. -13640  ;196    ;-158122
  59. -9829   ;139    ;-158056
  60. -22868  ;208    ;-157940
  61. -27983  ;300    ;-157925
  62. -30290  ;324    ;-157839
  63. -29989  ;312    ;-157896
  64. -30992  ;344    ;-157852
  65. -42326  ;429    ;-157781
  66. -37512  ;428    ;-157762
  67. -51052  ;572    ;-157584
  68. -67401  ;648    ;-157559
  69. -58575  ;615    ;-157517
  70. -71413  ;753    ;-157297
  71. -100199 ;1140   ;-156859
  72. -143529 ;1442   ;-156896
  73. -115345 ;1492   ;-156586
  74. -174020 ;1796   ;-156508
  75. -165795 ;1656   ;-156583
  76. -168403 ;1603   ;-156698
  77. -163087 ;1692   ;-156439
  78. -191071 ;1813   ;-156463
  79. -188664 ;1924   ;-156416
  80. -186959 ;1918   ;-156285
  81. -191974 ;1949   ;-156324
  82. -196487 ;1967   ;-156212
  83. -188664 ;1888   ;-156339
  84. -189065 ;1716   ;-156582
  85. -170911 ;1807   ;-156363
  86. -188664 ;1764   ;-156469
  87. -172917 ;1614   ;-156439
  88. -177330 ;1786   ;-156329
  89. -186758 ;1879   ;-156348
  90. -181843 ;1852   ;-156272
  91. -201903 ;2022   ;-156291
  92. -186457 ;1906   ;-156305
  93. -195384 ;1949   ;-156247
  94. -205815 ;2055   ;-156194
  95. -208022 ;2161   ;-156053
  96. -216748 ;2162   ;-156046
  97. -217751 ;2211   ;-156015
  98. -215745 ;2114   ;-156146
  99. -206517 ;2056   ;-156148
  100. -210329 ;2051   ;-156154
  101. -208924 ;2053   ;-156172
  102. -211933 ;2099   ;-156065
  103. -215444 ;2154   ;-156108
  104. -212134 ;2121   ;-156080
  105. -218453 ;2073   ;-156133
  106. -212435 ;2153   ;-156141
  107. -207119 ;2081   ;-156161
  108. -206216 ;2008   ;-156190
  109. -207420 ;2089   ;-156121
  110. -225073 ;2337   ;-155858
  111. -239115 ;2385   ;-155800
  112. -244130 ;2417   ;-155906
  113. -227179 ;2315   ;-155817
  114. -240920 ;2365   ;-155895
  115. -232796 ;2356   ;-155859
  116. -245333 ;2447   ;-155844
  117. -242525 ;2524   ;-155715
  118. -249546 ;2452   ;-155820
  119. -242324 ;2371   ;-155911
  120. -228383 ;2198   ;-155964
  121. -229386 ;2230   ;-155975
  122. -229787 ;2317   ;-155926
  123. -228182 ;2289   ;-155943
  124. -233498 ;2297   ;-155943
  125. -236407 ;2391   ;-155815
  126. -244631 ;2395   ;-155768
  127. -249747 ;2475   ;-155769
  128. -246637 ;2490   ;-155770
  129. -249646 ;2575   ;-155574
  130. -264992 ;2593   ;-155646
  131. -257169 ;2617   ;-155559
  132. -272314 ;2711   ;-155452
  133. -280037 ;2767   ;-155505
  134. -279837 ;2751   ;-155475
  135. -275624 ;2719   ;-155484
  136. -276125 ;2690   ;-155560
  137. -266798 ;2676   ;-155502
  138. -267801 ;2660   ;-155514
  139. -262485 ;2603   ;-155604
  140. -263889 ;2623   ;-155573
  141. -272414 ;2578   ;-155673
  142. -257068 ;2616   ;-155580
  143. -263287 ;2605   ;-155621
  144. -261883 ;2625   ;-155646
  145. -252354 ;2523   ;-155655
  146. -250750 ;2469   ;-155783
  147. -250148 ;2473   ;-155666
  148. -262986 ;2624   ;-155693
  149. -251251 ;2576   ;-155712
  150. -246336 ;2485   ;-155752
  151. -250649 ;2446   ;-155828
  152. -246035 ;2438   ;-155906
  153. -240720 ;2419   ;-155903
  154. -233899 ;2383   ;-155881
  155. -235103 ;2393   ;-155909
  156. -237410 ;2412   ;-155823
  157. -239215 ;2307   ;-155926
  158. -240419 ;2341   ;-155843
  159. -244732 ;2434   ;-155809
  160. -245133 ;2529   ;-155696
  161. -257670 ;2536   ;-155753
  162. -251753 ;2531   ;-155716
  163. -250850 ;2510   ;-155714
  164. -257369 ;2543   ;-155731
  165. -241221 ;2340   ;-155793
  166. -250047 ;2439   ;-155792

lbernstone
Posts: 791
Joined: Mon Jul 22, 2019 3:20 pm

Re: Weight Scale on ESP32-C3 on Liliygo T-Zigbee Board

Postby lbernstone » Sun Jun 09, 2024 6:13 pm

You should read the HX711 datasheet. I don't think it works the way you are thinking- it is intended to be a differential reading between two poles on a strain sensor, and provide 2 such inputs. If you just want to read multiple analog inputs, the esp32 can do that directly, or you can get a device like ADS1115.
https://cdn.sparkfun.com/datasheets/Sen ... nglish.pdf

TinTin
Posts: 3
Joined: Sat Jun 08, 2024 10:07 am

Re: Weight Scale on ESP32-C3 on Liliygo T-Zigbee Board

Postby TinTin » Mon Jun 10, 2024 8:53 am

Hello lbernstone,

yes i know that. Thats the reason the 4 halfbridge weight cells are forming a Wheatstone bridge so that on applying pressure on them the resistances change and the voltages on the inputs A+ and A- change accordingly. And the HX711 should amplify that input signal.

I took this as example for my setup
https://randomnerdtutorials.com/esp32-load-cell-hx711/
the difference to my setup there is that i use 4 halfbridge weight cells to form a full bridge weight cell and they use a different board. But it still uses an esp32 in that board.
And there are multiple setups there they use the same loadcells with the hx711 and the same wiring of the loadcells to the hx711 but instead with an arduino board and it works.

So i dont think I'm wrong in that part.
What i suspect is that maybe the internal ADC of the board trys to convert an alredy digital input. But that should not be it because i changed the pins to which the hx711 is connected to board.

Or its something i'm just to blind to see.

Who is online

Users browsing this forum: No registered users and 36 guests