ggurov / hx711 Goto Github PK
View Code? Open in Web Editor NEWraspberry pi hx711 weight scale interface
raspberry pi hx711 weight scale interface
To get ride of this warning and get the program running I've to add in hx711.c the line:
" #include <unistd.h> "
we need a "close(mem_fd)" at last, don't we?
Hi,
I use your code for some time with success, weighting bee hives using Raspberry Pi B+, hx711 and low-cost weight sensors. So far, so good. But now I found out, that if something goes wrong with (probably) my wiring (Pi to hx711), cpu of Raspberry goes to 100% and is almost not responding etc...
How can one modify hx711.c for such a case? I tried to find out myself, but my programming skills are not good enough to manage it ;-)
After some testing I think that problem is in/near reset_converter(); just before reading first bunch of data...
Can someone help me, please?
Thanks. #kabjar
I can read my load cell on channel A. But I want to read a pyranometer on channel B simultaneously.
How can I read two things at once? I do not get to read anything on channel B
Thank you
Is there a way to read the HX711 using a python? I'm reading via i2c a ADS1115 and also sending a PWM with a PCA9685, so, it makes sense having all working on python, I was wondering about the possibility of reading the HX711 with a python script.
cheers!
Howdy,
I read through your README file and I noticed the part the explains how to change the data rate
To switch to 80 samples per second, one has to desolder the RATE pin from the pad it's soldered to, lift it and solder it to +vcc on HX711 shield (pin 15).
By default, this pin is grounded, which sets HX711 to run at 10 samples per second
But I am confused as to where the RATE pin is on the HX711. And then also where exactly to solder on the VCC pin. Pictures would be great.
Thanks
Karl
Hi.
I just connected the hx711 model to the P5 header but are unable to read any data.
I just try with 2 different sensor from 2 different manufacturer, but all time say "no data to consider".
Also I compile que hx711.c with different pinout:
But the response is the same all time.
I attach the picture of my raspberry and the sensor
Any help?
Hi,
I've connected an HX711 to my Pi, CLOCK on BCM pin 20 (J8-38) and DATA to BCM pin 16 (J8-36). I keep getting mostly what seems to be random reads, full of '1's, like this:
0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 n: -2 -
0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 0 1 1 1 1 1 1 1 n: -12546 -
0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 n: -262154 -
0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 0 0 0 0 n: -28704 -
The application then displays the "No data to consider", as expected due to the randomness of the reads.
The code has been changed accordingly (when I tried without updating the code, my Pi just hang and I had to disconnect the power supply to restart it).
I'm using a Raspberry Pi B+ and the exact same hardware configuration (HX711+Load Cell) works fine with Arduino.
Any idea of what could be wrong?
Regards,
Luiz
Your code has trouble with timing the communication with the HX711 and you make a heroic effort to clean up the dirty readings. Timing is a tricky problem to solve but it has been solved very well in the pigpio library which can be used directly from c but also via a daemon and from other languages. There's even a an example HX711 reader written in python.
When I used your code it mostly worked but gave quite slow and erratic readings. When I used the pigpio code it was absolutely rock solid - and fast (frequent completion of readings) too.
So the issue: can you modify your code to use the pigpio library? It'll provide the timing-sensitive functions while your code already does the higher-level work.
Hi! Thanks for sharing this great project! I'm also a big fan of hivetool as a whole!
I'm getting the following errors after cloning the project to local folder and running make:
gcc -o hx711 hx711.c gb_common.o hx711.c: In function ‘main’: hx711.c:127:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat=] printf("%d\n", (tmp_avg2 / j) - offset); ^ hx711.c: In function ‘read_cnt’: hx711.c:215:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat=] printf("n: %10d - ", count - offset); ^ /usr/bin/ld: gb_common.o: Relocations in generic ELF (EM: 40) gb_common.o: error adding symbols: File in wrong format collect2: error: ld returned 1 exit status make: *** [hx711] Error 1
I'm using make
correctly? Can I solve this issue by changing the int variables to long int ones?
Thanks in advance!
EDIT: I've managed to "make" it with gcc inside raspberry pi. It compiled as well. You can close this thread. Next step is to see why I'm getting "No data to consider errors". But I'm still trying to see if I've connected the pins the right way (still a bit confused using BCM I/Os on Rasp2 model B v1.1.
EDIT2: I've realized that pins in .c code were in "Board Numbering System", instead of "BCM Numbering system". On a raspberry 2 I've managed to wire the Dout and Sck into 12 and 11 board pins, respectively. Instead of "No data to consider" message, I'm receiving no output. The command line simply awaits for the command to respond. I think those pins are used for other thing on raspberry pi interface, which I'm going to use 37 and 38 Board pins, instead, to confirm that.
EDIT3: Implemented the commit from ComSubVie, which contained changes for the Raspberry PI. Now, all implementations and wirings just output "no data to consider". I feel that now I'm getting there.
here:
for(i=0;i<24 ; i++) {
SCK_ON;
b++;
b++;
b++;
b++;
if (DT_R > 0 ) { count++; }
SCK_OFF;
b++;
b++;
b++;
b++;
count = count << 1;
}
the Code read DT_R on rising edge, but hx711 datasheet says data availiable on falling edge, so read DT_R should put behind SCK_OFF.
And shift count should put before count++, or last bit will always be 0 and count doubled.
Another bug is
for (i=32;i;i--) {
printf("%d ", ((count-offset) & ( 1 << i )) > 0 );
}
when you shift 32 times, you get 33rd bit in count.
Hello, I have got two data versions when I use it:
Is there any way to filter one version and keep only the second?
Warning: Unable to set high priority
0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 1 1 0 0 0 n: -8288208 -
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 1 1 0 1 n: 100378 -
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 1 1 0 1 0 1 n: 100458 -
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 1 0 0 1 0 1 n: 100426 -
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 n: 100352 -
0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 n: -8288192 -
0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 1 0 1 1 1 1 n: -8288162 -
0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 1 1 1 1 0 n: -8288196 -
0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 1 1 1 0 1 0 n: -8288140 -
0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 1 0 1 0 1 n: -8288214 -
No data to consider
Is it because it uses 100% of one core?
I saw you poll on DT_R like following:
while( DT_R );
That's so bad for CPU usage.
You should at least insert a wait instruction inside the cycle in order to let the CPU free for other tasks.
But there's a better way: using WiringPi library you can use interrupts on data pins, so you can register a function for being called when the pin DT_R changes state with likely no CPU overhead.
I think i'll have to rewrite this library using WiringPi. That's a pity :(
I have a problem that when i run program on my rpi model 2 result is only 0 0 0 0 0 0 0 0 0 0 0 0 any ideas how to fix this? connections were good.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.