MartinVerges / womolin-gaslevel

DIY project for propane GAS bottle weight
Other
2 stars 2 forks source link

Not getting the correct readings from hx711 #2

Closed AciDCooL closed 1 year ago

AciDCooL commented 1 year ago

Hi Martin, I finally got the right board, flashed your software with the webinstaller, connected it to my home wifi for testing purposes, then tried to calibrate the hx711. (Which I know works, because I can read values with my old esp8266 board on the console). I don't see any wiring diagram for the hx711 I used: https://storage.ning.com/topology/rest/1.0/file/get/3665560544?profile=original But since I know it works I measured and tested all of the the pins on the esp32, they are soldered properly. Even switched to the secondary pins. But when I lift my pack of sugar 1KG + a bottle of water with 700 grams it stays at the same values:

[WIFI][STATUS] Connected to known SSID: 'Krukkert-IoT' with IP 10.0.3.87.
[SENSOR] 1. sensor level is 48% (raw sensor value = 249)
[SENSOR] 2. sensor level is 84% (raw sensor value = 1700)
[SENSOR] 1. sensor level is 48% (raw sensor value = 249)
[SENSOR] 2. sensor level is 84% (raw sensor value = 1700)
[SENSOR] 1. sensor level is 48% (raw sensor value = 249)
[SENSOR] 2. sensor level is 84% (raw sensor value = 1700)
[SENSOR] 1. sensor level is 48% (raw sensor value = 249)
[SENSOR] 2. sensor level is 84% (raw sensor value = 1700)
[WIFI][STATUS] Connected to known SSID: 'Krukkert-IoT' with IP 10.0.3.87.
[SENSOR] 1. sensor level is 48% (raw sensor value = 249)
[SENSOR] 2. sensor level is 84% (raw sensor value = 1700)
[SENSOR] 1. sensor level is 48% (raw sensor value = 249)
[SENSOR] 2. sensor level is 84% (raw sensor value = 1700)
[SENSOR] 1. sensor level is 48% (raw sensor value = 249)
[SENSOR] 2. sensor level is 84% (raw sensor value = 1700)
[SENSOR] 1. sensor level is 48% (raw sensor value = 249)
[SENSOR] 2. sensor level is 84% (raw sensor value = 1700)
[WIFI][STATUS] Connected to known SSID: 'Krukkert-IoT' with IP 10.0.3.87.
[SENSOR] 1. sensor level is 48% (raw sensor value = 249)
[SENSOR] 2. sensor level is 84% (raw sensor value = 1700)
[SENSOR] 1. sensor level is 48% (raw sensor value = 249)
[SENSOR] 2. sensor level is 84% (raw sensor value = 1700)
[SENSOR] 1. sensor level is 48% (raw sensor value = 249)
[SENSOR] 2. sensor level is 84% (raw sensor value = 1700)
[SENSOR] 1. sensor level is 48% (raw sensor value = 249)
[SENSOR] 2. sensor level is 84% (raw sensor value = 1700)
[WIFI][STATUS] Connected to known SSID: 'Krukkert-IoT' with IP 10.0.3.87.
[SENSOR] 1. sensor level is 48% (raw sensor value = 249)
[SENSOR] 2. sensor level is 84% (raw sensor value = 1700)

Does it only work for higher numbers since on my esp8266 board with some sample code I was able to measure lower weight pretty accurately.

MartinVerges commented 1 year ago

Hello,

Please try out this wiring:

IMG_20230324_053743_464.jpg

The raw sensor value should definitely show each small little change of weight, however the level is calculated by substract the empty bottle weight configured in the UI (default 5.5kg, a 11kg Alugas bottle).

Please let me know if the wiring is as shown in my picture and please feel free to upload a picture of you setup, maybe I can see why it's not working.

By the way, the HX711 has 2 channels, one with fixed 32, and another with 64 or 128. In my Software, it's set to the 128 channel at https://github.com/MartinVerges/womolin-gaslevel/blob/6df275b9702c34f179d68c3a904ddce2090f0554/src/global.h#L46. Please make sure, that your load cells are connected to the correct channel of the hx711.

Regards Martin

AciDCooL commented 1 year ago

While calibrating I get either -1, 0 or 4294967295 as output, which is really weird. I changed the schematics to the one you provided which only changes the e- and the e+ around. But got the same result.

chrome_9XQg1dZCzE

20230326_010809 20230326_010845

Red is connect to VCC, Black to ground next to it. White to IO16 and Geen to IO17. But I needed to extend them to pins, and ran out of same color wire so white went to yellow and green to purple in the next picture. And connected purple on the underside because I didn't have a male's anymore and only females left.

20230326_010958

And to add to this I tested this setuup with the esp8266 board and some sample code from: https://randomnerdtutorials.com/esp8266-load-cell-hx711/

Got these readings after calibration and putting a waterbottle on it. So I know it should work. Can't figure out why it wont work on the esp32.

one reading: -1.7 | average: -1.78992 one reading: -1.9 | average: 10.78662 one reading: 653.9 | average: 651.15405 one reading: 652.6 | average: 652.84973 one reading: 651.8 | average: 653.41498 one reading: 653.1 | average: 652.80267 one reading: 653.3 | average: 652.75555 one reading: 653.4 | average: 652.70844 one reading: 652.9 | average: 653.03815 one reading: 654.1 | average: 653.03815 one reading: 654.7 | average: 653.22656 one reading: 652.4 | average: 653.79181 one reading: 654.3 | average: 652.47290

AciDCooL commented 1 year ago

So I just used these sample codes for the esp32, basically the same as what I did with my esp8266: https://randomnerdtutorials.com/esp32-load-cell-hx711/

Changed old code rtc_clk_cpu_freq_set(RTC_CPU_FREQ_80M); to setCpuFrequencyMhz(RTC_CPU_FREQ_80M); And changed the pins, so I don't have to reconnect my pins everytime for testing to:

const int LOADCELL_DOUT_PIN = 16;
const int LOADCELL_SCK_PIN = 17;

Calibration was:

Tare done...
Place a known weight on the scale...Result: -6182
Tare... remove any weights from the scale.
Tare done...
Place a known weight on the scale...Result: 21489
Tare... remove any weights from the scale.
Tare done...
Place a known weight on the scale...Result: 21551
Tare... remove any weights from the scale.
Tare done...
Place a known weight on the scale...Result: 21515
Tare... remove any weights from the scale.
Tare done...
Place a known weight on the scale...Result: 10
Tare... remove any weights from the scale.

And te final result by using calibration factor = (reading)/(known weight) 21500/1012

Scale with weight on it:
get value:              -24.00
get units:              1.7
Readings:
one reading:    -0.5    | average:      1.60038
one reading:    1013.3  | average:      1015.10937
one reading:    1421.7  | average:      1663.96790
one reading:    1667.8  | average:      1671.21667

So now I'm wondering what is different here, I installed womolin-gaslevel with the webinstaller, maybe now I have a bit of understanding how platform.io works I'll try and import your code and see if it behaves differently. Just need to take care of that littlefs part but doesn't seem like rocket science.

AciDCooL commented 1 year ago

Ok I have it working after I compiled it myself. Don't need the littlefs because it's already on the other partition as it seems. I'll figure out how to compile littlefs later when I need updates on that partition.

Anyway I reflashed it with the webinstaller "Gaslevel stable release full install (v3.1)", and same issue again, weird numbers that do not make sense. The I tried the development release "Gaslevel development release full install (v3.1-2-g6df275b)" through the webinstaller, and what do you know, problem solved.

So for now I will stick to the dev release which seem to work great. No need to compile it myself if you already did it I guess :). Easy fix would be update the stable release with a new stable which does not have this issue. Not sure where in the code it goes wrong but it sure does.

Now of to the barn to make a bracket in which the gas bottle fits so I can make my dad a happy camper, literally haha

MartinVerges commented 1 year ago

Thanks for figuring that out. Very strange, will look at it ASAP to figure out what got patched and then of course do a new stable release out of the current version.

MartinVerges commented 1 year ago

That's really strange. Just checked the commits, and between v3.1 and v3.1-2-g6df275b is just a change on the README.md file.

image

I will investigate more but so far can't find anything unusual that would lead to this behavior.