I’ve been tinkering, reading watching for weeks and been able only make little progress. First off I have zero knowledge about Python coding (did some ABAP 18 years ago). I’m trying to help my son to get a home build wind tunnel up and running. We have attached 2 load cells to capture drag and li…xorgCem@jsotola thanks, adding the “` in a blank like did it ugh…had them straight before and after the code. tlfong01The runtime error msg says your pin numbering is wrong: RuntimeError: Please set pin numbering mode using GPIO.setmode(GPIO.BOARD) or GPIO.setmode(GPIO.BCM).So you need to set either Board mode or BCM mode, and make sure you hardware pin numbers match you set mode. Cem42@Milliways, thx for replying. The main approach incl. the connections were taken from here tutorials-raspberrypi.com/…sorry seem not to be able to comment..ugh age is catching up..I have edited my post, hope it makes more sense@tlfong01 the GPIO.setmode is done in HX711.py which is called in example.py and mode is set to BCM hence I use the GPIOs and not the pins but yeah I don’t know why it’s complaining about that tlfong014756I read the code you are running: “HX711 tatobari/hx711py Python GitHub program hx711.py (Using threading, mutex)”: github.com/tatobari/hx711py/blob/master/hx711.py. and found that it has the following statement: “GPIO.setmode(GPIO.BCM)“. In other words the program set BMC mode. so you need to match the BCM pin numbers to your pins used. BTW, tatobari github’s code is a bit advanced, using scary things like “threading” and “mutex”, which are hard to debug. / to continue, …I would suggest to use a simple version like this: HX711 Python Library hx711 188.8.131.52 pip install hx711 – pypy.org pypi.org/project/hx711. For this simple library, you can start testing just one channel. And that you don’t need to use any load cell for initial testing. Put away the load cell, Just test one channel with input connected ground, and to Vcc.@Cem, Ah there is some confusion here. HX711 is using the Rpi GPIO pins directly (I mean not through I2C, SPI, or UART). So you connect HX711 to Rpi GPIO pins, which have two schemes of numbering, BCM and BOARD. In other words, any one pin might be numbered “x” in BCM scheme, but “y” in BOARD scheme. This is a top 3 Rpi newbie error or sorrow.I might have remembered things wrongly. So I am reading the datasheet to make sure.HX711 Datasheet – Avia Semi
cdn.sparkfun.com/datasheets/…tlfong01475615:38Now let us look at the HX711 datasheet below.
As I suggested earlier, you only need to test one channel for initial testing. Using the pink differential channel for example, (1) Connect INNA to one end of load cell, Connect IPNA to another end of load cell (2) Put load cell aside, just test if Channel A can convert 0V to all 24 0-bits (raw results) , and (2) convert 3V3 to 24 1-bits. Good luck and cheers.Ah, MY BIG APOLOGYErrata – (1) INNA and INPA are load cell inputs to one channel of the HX711(2) INNB and INPB are the Channel B inputs to the HX711(3) It is the terminals/pins PD_CLK (Power Down and Clock) and DOUT (Digital Out) to connect to two separate Rpi GPIO pins.(4) Rpi uses two GPIO pins to interface with HX711’s two channels.(5) So forget what I said earlier to put aside the load cell, you need the load cell to do the testing (You might break away load cell output and use Gnd to connect to INNA, 0V or 3V3 as input to connect to INPA. But this make things confusing, so I won’t try it now)To make sure I am not going to make more errors, I am reading my old testing notes and copy and paste some notes to refresh my memory, and also for your reference.
(removed)I learnt HX711 from SparkFun some two years ago. You might also read SparlkFun’s tutorial.Now, my programming notes:HX711 Summary Notes for programming and debugging V0.2 tlfong01 2020oct26hkt1611
(1) ***Analog Inputs***
Channel A differential input is designed to interface directly with a bridge sensor’s differential output. It can be programmed with a gain of 128 or 64. The large gains are needed to accommodate the small output signal from the sensor.
When 5V supply is used at the AVDD pin, these gains correspond to a full-scale differential input voltage of ±20mV or ±40mV respectively.
Channel B differential input has a fixed gain of 32. The full-scale input voltage range is ±80mV, when 5V supply…(see full text)(2) ***Output Data Rate and Format***
When using the on-chip oscillator, output data rate is typically 10 (RATE=0) or 80SPS (RATE=1).
The output 24 bits of data is in 2’s complement format.
When input differential signal goes out of the 24 bit range, the output data will be saturated at 800000h (MIN) or 7FFFFFh (MAX), until the input signal comes back to the input range.(3) ***Serial Interface***
Pin PD_SCK and DOUT are used for data retrieval, input selection, gain selection and power down controls.
When output data is not ready for retrieval, digital output pin DOUT is high. Serial clock input PD_SCK should be low.
When DOUT goes to low, it indicates data is ready for retrieval.
PD_SCK high min = 0.2uS, max 50uS (1/50uS = 20kHz) (typ 1uS)
PD_SCK low min = 0.2uS (typ 1uS, 1MHz)
By applying 25~27 positive clock pulses at the PD_SCK pin, data is shifted out from the DOUT output pin.(see full text)Cem4216:21Hi tlfong01, first really appreciate your feedback and help. I’m close to give up 🙂 after browsing the web up and down. All the stuff is beyond my oldish brain can chew. There is a lot out there with arduino which seems to work better. But couldn’t find anyone using multiple HX711 on a Rpi. The simple code example you shared doesn’t work at all for me with error message from indentation to not defined variables (was about to try to install .GPIO.RPI in python 3.I was thinking to bypass all this hassle by just using first one load cell, save the values, disconnect and connect the other and do the readings with the second load cell and finally just combine them. Does that make sense ? tlfong01I also google my old HX711 photos to make sure my wiring scheme is still OK. Cembtw I think my wiring is correct after I tried to understand this BCM and Board thingy and BCM refers to GPIO numbering whereas Board to pin numbering. correct ? tlfong01Ha, your clarification confuses me. Let me try my broken English. (1) BOARD scheme refers to the physical numbering of the 40 pin header. (2) BCM means what BoardCom designer who denotes their GPIO pin number, which is “logical”, and has not correspondence to “physical” layout. (Only 50% sure. :)) Cemhaha I think we speak the same language, that confirms my understanding hence I chose BCM and the “logical” numbering tlfong014756Good. I should also said that “BOARD” refers to the printed circuit BOARD. So no problem about pin numbering. Let us move on, before you finally give up.Yes, I am not surprised that you said the following: (1) All the stuff is beyond my oldish brain can chew. (2) There is a lot out there with Arduino which seems to work better. (3) But couldn’t find anyone using multiple HX711 on a Rpi.Let me the OK boomer make a couple of suggestions: First One (1) You sit back and watch what the OK boomer is now struggling along. I will try to do the following: (a) Install the package/library I recommended earlier, (b) Try it on my HX711 module which is lying in a junk box, collecting dust for two years now. Cem16:41nice – watching 😉 tlfong014756I suggest you to sit back and watch, because there are quite a lot of stumbling blocks and mental barriers for newbies to do HX711. It is not that newbies are stupid, but the developers are dwelling in the Tower of Barbel. Without wasting more time, let me start.You don’t need to follow closely. You can come back from time to time, or tomorrow, to see if I am still going, or already given up! 😦 I am a Lonely Planet programmer, very comfortable going solo, without asking anybody questions for a long while. You might have questions when I go along, but you might not need to ask questions for now, because later when you look back my whole journey, then most your too afraid to ask questions might then disappear. Cheers. Cemlol at least thanks having chuckle here solo tlfong01475617:22(removed)H1. Now I am going to start installing the following package:
hx711 184.108.40.206 pip install hx711, A library to drive a HX711 load cell amplifier on a Raspberry Pi – PyPi.Org
H2. I am writing a reading log.
This library allows to drive a HX711 load cess amplifier with a Raspberry Pi. It just provides the capabilities:
to set channel an gain and
to read raw values
Getting started Just install by pip3 install HX711. A basic usage example is given below: #!/usr/bin/python3 from hx711 import HX711 try: hx711 = HX711( dout_pin=5, pd_sck_pin=6, channel='A', gain=64 ) hx711.reset() # Before we start, reset the HX711 (not obligate) measures = hx711.get_raw_data(num_measures=3) finally: GPIO.cleanup() # always do a GPIO cleanup in your scripts! print("\n".join(measures))
(see full text)Note H2:
The tutorial has this first statement in the demo program.
This a newbie scary cryptic CLI (Command Line Interface) shorthand statement, usually for linux experts to work crazily fast in BASH command line mode. But the OP is using newbie friendly Thonny python IDE. So I will not follow the package guide closely, and start with the newbie Thonny. (By the way, I am using Rpi4B buster.)Now I am keeping the HX711 installation record for later reference.
tlfong01475618:04Next is to run the demo program using Thonny IDE. There is no real hx711 module in hand. So I just did a fake run. So far so good.(removed)
So far so good. Now I know Thonny python can import the hx711 module and create a hx711 module object. Thonny python can create the object even though there is no real hx711 connected, because the object creation just blindly set GPIO pins as input or output, without caring if the GPIO pins are connected to any thing. In other words, I am more or less cheating the hx711m01 object.Next is to search my junk bin for the old hx711 module board which has been collecting dust there for two years.Ah, locking down jogging and supper time! See you late this evening or tomorrow. Cheers.Ah, I forgot my old hx711 module is red, green, or purple. So I searched my old photo gallery to refresh my momory.
Cem4218:20oh are we in same time zone ? My wife is preparing dinner too …my HX711 is the green one but I just noticed I’m struggling with some basics. pipe3 command doesn’t work, when I try to install it says it’s there… when I check my python version it’s 2.7xy even so the other day I spent 8 hoers installing 3.8 just to find out there is 3.7 installed already.So when I try sudo pipe3 install HX711 it’s kind half baked thing but maybe I’m missing something. When I go to the 3.7xy library there are 2 HX711 folders…hm you don’t get any error messages. Need to read how to make python 3 standard I guess that’s one issue 4 hours later… tlfong01475622:27Ah, you remind me the first time I try to upgrade my Rpi1 or Rpi2 from default python 3.5.3 to python 3.7.3. It took me about 3 hours before I gave up. I knew I did not have the prerequisite linux knowledge and tools, to locate the problem. I made a mess of the directories. I still do not know what are “alias” directories, and I am not keen to learn, because the new buster GUI tools including the new install/upgrade tools solve almost all my install problems.I still remember trying “curb”, “NMB” (not sure if I spell correctly) and a couple of otherinstallation tools. The problem is the following:Important advice to newbies(1) When your package is supposed to run in python 2.7, then you should almost always use “pip”, which means by default “pip2”. If you wrongly use “pip3”, the package is installed in a directory for python3. Often you can try to “pip” again to install the package in a directory for python 2.7. Now the default “path” command would be changed to python3 to python 2 directory.But if you are using python3 now and python2 some other time, then no one will automatically change the path config files for you, with the result of a big mess.What I said is the “Tower of Barbel” is that some python packages are ported from Ubantu or other linux variants, by so many hackers in different places at different times, and they might have left their gitHub package unsupported, and other new hackers come along and “fork” new versions of the old package.The most disgusting or criminal thing is that some hackers (they call themselves “developers”) when forking a new version of the old package, do not following the standard of moving the directories for pip/pip3 etc, with the following horrible result:In some rare cases, when you first wrongly use “pip3”, find it does not work, and try your luck using “pip”, it is too late, because the auto config thing won’t bother to take care of going back to pip2. The only solution I know, at least for me newbie, is the following.When trying new things, always keep the working image as a backup, and make a test/work SD image to try the new things, and as you go smoothly, make work image #2 and move on, then #3 and move on etc. When you have trouble using say, work 15, them fall back to work 14, and still no luck, fall back further to #13. And if #13 ok, then make #14a and move on.This is a general troubleshooting technique called “swapping” test/troubleshooting. Of course many people said it is just common sense, no big deal. But then I learn the following in a hard way: The difference between a pro and a non-pro is that a pro makes backup.Bed time. Call it a day. See you tomorrow. PS – I found my old hx711 module proto board in the junk bin. Might try it tomorrow.