tlfong014766Mon 18: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.
Cem52Mon 18: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… tlfong014766Mon 22: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. 11 hours later… tlfong014766Tue 10:22My old hx711 module on proto board does not seem to have collected too much dust. But I have forgotten which wires for which use. So I need to browse my photo gallery again.
Cem52Tue 11:00good morning (still kinda), again I really appreciate your support and taking the time to explain the stuff and I understand better but I understand also that this most likely simply doesn’t work hence there is no one out there who used 2 HX711 at the same time with a Rpi.The more I fiddle (this morning another 3 hours) there in a mess I end up.
Currently none of the example.py’s run, somehow after making python 3.7 the default and installing HX711 I have another folder under usr/local/lib/ with hx711-1.1.23 which is different to what have in another HX711 folder, this new is reading the mean… but any py I try to run I get Attribute erros for HX711. I will attempt 2 last tries but with the goal to use only one load cell and one hx711 module at a time: 1. default back to python 2.7 use the “old” example py I had modified (tried to modify) if things are stil…(see full text)CemTue 11:12reinstalling Rpi OS ggrrrr tlfong014766Tue 11:24@Cem You said “no one out there who used 2 HX711 at the same time with a Rpi“. Well, at least one crazy hobbyist programmer in this Lonely Planet is using more than two HX711’s. If you search rpi-org-forum you might find some one was using ESP8266-12 LUA to control a couple of MCP23017’s each of which has 16 GPIO ports, each pair of ports control one HX711 module.So the other crazy guy is controlling 4 x mcp23017 (can be up to 8) each of which is controlling 8 x hx711, each of which is controlling two load cells. So it is 4 x 4 x 8 x 2 = 128 load cells (note: my dodgy calculations is not proofread. )@Cem Ah, this is what I am doing: “the goal to use only one load cell and one hx711 module at a time …”. This is called the Occam Razor approach – Make the thing as simple as possible, but not simpler.”You might have heard that StackOverflow did a survey a year ago, telling the whole planet the results that SCALA is the most money making language for the programmers. Scala means “A scalable language”, which means that once you know how to talk to one hx711, you can talk to as many as hx711’s as you like, …Yes, I am not using Scala, but you don’t need to use Scala to do Scala, You can use LUA C#, or F#, or Python to do Scala. Of course you can also use stupid C/C++ to do Scala, but that would take 100 times longer, and still end up a big mess. By the same token, I am doing OO programming without OO languages, Agile development without using Agile tools (Google Uncle Bob to know more of what I am talking). So I sometimes call myself a “be water programmer“, … 🙂 tlfong014766Tue 12:14Now I am making a 500g load cell testing rig.
Ah, locking down lunch time! See you late this afternoon or evening. Cheers. tlfong014766Tue 12:28Before I go, I would recommend you to watch an Uncle Bob’s talk. He is talking about Future Programming. I forgot to mention I am trying to write my programs Future Proof. In other words, I am also a ***Future Programmer***. ***Uncle Bob Martin The Future of Programming*** – 2016may18, 1,530,276 views
youtube.com/… 8 hours later… CemTue 20:26Occam Razor approach – I like that. btw I’m in Singapore though from Germany (been now 16 years here). reinstalled OS, putting things together, calibrated one load cell, tomorrow next and then hopefully final wind tunnel tests which will probably last a day with 4 month research and preparation… enjoy the evening tlfong014766Tue 20:45Ah, I also just calibrated the 500g load cell, with results shown below.
Next is to upgrade the hx711 test program from v0.1 to v0.2. Now I am going to connect Rpi to the real thing, the hx711 module, and see if it can measure something, at least can reset itself. Two years ago this time I used ESP8266/Rpi3B+ stretch LUA/python MCP23017 to try to talk to hx711, but ended up a mess. So I gave up.This time I don’t have much confidence and dare not to write my own program (actually not that difficult, if using python, but at that time Rpi3B+ I2C was buggy, and couldn’t change frequency, only flat 100kHz. (OK my excuse 🙂 😦 ).Anyway, Rpi4B I2C is bug free now. Moreover, the PiPy library I am trying now is in python, and I peeked inside and found the logic simple: just send 20 something bytes and read back the 24 bit raw result and convert it to decimal. As usual, I won’t write the tedious 2’C compliment to decimal myself, I just steal the conversion code from somewhere. 🙂 2 hours later… tlfong014766Tue 22:33Now I have upgraded my very simple hx711 test v0.1 program to also very simple v0.1. The Rpi to hx711 is also as simple as possible:Only the right hand side 4 pin connector are used, from top to bottom:Vcc – connected to 3V3hx711 Data to Rpi pin 14 (TxD)hx711 Clock to Rpi pin 15 (RxD)hx711 Ground to Rpi GroundThe 5 pin of the left side connected is left Not Connected (NC)The only upgrade function added is just to reset hx711. Last hx711 was connected, excuting reset would hang the program. This time the reset function executes smoothly, verifying Rpi can talk to hx711 and ask it to do something like reset. I have not tried the get raw data yet. I am a humble guy, I dare not to go too fast. The v0.2 program, with sample output, is listed below.
# Program description # hx711test02a.py tlfong01 2020oct27hkt2109 # System Config # Rpi4B 2GB Thonny python 3.7.3 # HX711 PyPi Library Install # pi@raspberrypi:~ $ date Tue 27 Oct 2020 09:14:01 PM HKT # pi@raspberrypi:~ $ pip3 install hx711 # Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple # Requirement already satisfied: hx711 in ./.local/lib/python3.7/site-packages (188.8.131.52) # *** Imports *** import RPi.GPIO as GPIO from datetime import datetime from hx711 import HX711
(see full text)(removed)Almost bed time. Call it a day. Carry on tomorrow.Carry On Till Tomorrow with LYRICS►Cheers. tlfong014766Tue 22:58
11 hours later… tlfong014766yst 9:58I read the comments of the 2017 tutorial you are following. It appears that there are comments about your hx711 unreliability problem, you might like to read them to see the comment are helpful to solve you problem. I also found another gitHub python 3 only library you might try.(1) Felix – Build a digital Raspberry Pi Scale (with Weight Sensor HX711) – 2017
(2) Gandaf15 – hx711 gandalf15 python 3 library – 2019jan02
github.com/gandalf15/HX711/… 2 hours later… tlfong014766yst 11:53I also found that the pyPi hx711 python3 library I am using is based on gandaf15. Also that your green module is different from mine, which has rate pin jumpers. Gandaf15 has a tip to set rate, as shown below.
3 hours later… tlfong014766yst 14:45Now I am going to calibrate the 5kg load cell. My test plan is the following.(1) Test 1 hx711 module with 2 channels each of which handling 1 load cell.(2) Test 2 hx711 modules, each Channel A handles one load cell.
Now I am searched for my old calibration record of the 5kg Load Cell.(1) HX711 Forum Discussion Notes 1/4
(2) HX711 Forum Discussion Notes 1/4
(3) HX711 Forum Discussion Notes 1/4
1kg = 3.2mV
(4) HX711 Forum Discussion Notes 1/4 (calibration Notes)
raspberrypi.org/forums/…(see full text)A very rough summary of the 5V load cell calibration results is the following:For Vcc = 5V:(1) It is about 5mV for 5kg max load,(2) Or 1mV/V sensitivity (I forgot what this exactly means! 🙂My rough rult of thumb is the following:Either Vcc = 3V3 or 5V0. The voltage output for max loading, either 500g or 5kg, is about 5mV. In other words, the HX711 load cell amplifier should be set to the following:gain factor = 3V3 / 5mV = 3300 / 5 ~= 600. This 600 gain factor is what I am going to set in the coming Hx711 ADC test.The calibration record for 5kg load cell:
2 hours later… tlfong014766yst 17:08Now I have connected the 500g load cell bridge output (wht, grn) wires to HX711, and ready to use the PiPy hx711 load cell amplifier library function to amplify a couple of mV to a couple of Volts.
Ah, locking down jogging and supper break time. Will come back late this evening or tomorrow.One thing I forgot to mention is that: (1) What is an “airfoil”? (2) I googled and know it is just the “wing” of an aeroplane. (2) But how can the wing lift the plane? So I googled the following Youtube: How Does A Wing Actually Work? 2012aug03, 1,224,732 views
youtube.com/…. See you later. 3 hours later… Cem52yst 19:55
airfoil is more like mimicking a wing or “flying object”. Anyway the whole experimetn is rather a disaster and tomorrow I’ll be taking everything apart, enough.Too many mistakes and wrong choices were made. My tests are completely useless. I also have 5kg load cells and they barely register any force. So ideally they should have been more 1 or 2kg cells but worse the rod used is made of brass which way too soft meaning before any force is send to the load cell the brass rod will nullify it by bending plus the fan we use is waaay too weak.I get an average wind speed of 4 m/s. Nonetheless many lessons learned from choosing right tools, hardware (next time arduino) to coding which I almost enjoyed most hahaha 3 hours later… tlfong014766yst 22:38(1) About load cell spec – Just now I used a 12V 0.7A CPU fan to blow my 500g load cell (5mV full scale), and found there was not any noticeable different in DMM reading. I at once gave up trying any bigger fans. I guess you need a 100g load cell to do your experiments. My 500g load cell is from this dirt cheap weight scale:AliExpress Mini Digital Weight Scale 100g ~500g, 0.01g ~ 0.1g – US1 ~ US$4
pt.aliexpress.com/item/…(2) Falling back to Arduino – I very much agree you return to Arduino, because Rpi python has too steep a learning curve for you now. You remind me two years back, I over ambiguously thought I could learn ESP8266 and LUA quickly. But I did not know that LUA is event driven and perhaps easy for GUI design.But very surprisingly it took me more than 100 hours to learn the IDE and another 10 hours just to blink a LED. For Arduino it took me less than 30 minutes to read the example and blink a LED. My conclusion was that I did not have the prerequisite knowledge to do NodeMCU LUA event driven programming.So I cut loss and gave up and went back to Rpi. That is why I think your case is very similar to mine (choosing the wrong tool). Learning a new language seems easy, but there are many things you don’t know that you don’t know. Cheers. 14 hours later… tlfong01476612:33Postmortem of my 5 minute Wind Tunnel experiment.(1) 12V 700mA CPU fan wind speed is too low.(2) 500g Load Cell not sensitive enough. Should consider 100g Load Cell next time.
tlfong01476613:02Now I am going back to my hx711 test program v0.3. I found the first bug in the PyPi hx711 library. It appears to be a typo error. But as the wise man *Warren Buffett says, “There ain’t be just one cockroach in the kitchen. So I am expecting more bugs or incompatibility of the PyPi library with the Rpi Thonny library. So I am read the library more closely, just in case I need to troubleshooting:This is the full listing fo the pypi hx711 library. It is less than 300 line long. So should be easy to debug.
# ****************************************************************************************** # Program description # hx711test03.py tlfong01 2020oct28hkt2201 # System Config # Rpi4B 2GB buster Thonny python 3.7.3 # HX711 PyPi Library Install # pi@raspberrypi:~ $ date | Tue 27 Oct 2020 09:14:01 PM HKT # pi@raspberrypi:~ $ uname -a | Linux raspberrypi 4.19.118-v7l+ #1311 SMP # Mon Apr 27 14:26:42 BST 2020 armv7l GNU/Linux # pi@raspberrypi:~ $ pip3 install hx711 # Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
(see full text)tlfong0113:16I am also making a penzu pypi hx711 library reading and testing log.penzu.com/p/340557f4tlfong01476613:39I am also considering the Arduino Library of HX711. I don;t have much confidence on the PyPi hx711 Library, because I already found a bug in the demo program. Now I googled the Arduino Library to check out if it is good. The links are listed below.(1) HX711 Arduino Library – Arduino CC
(2) HX711 Arduino Library – GitHub
github.com/bogde/HX711One thing I worry about the Arduino hx711 library is the following remark in the documentation:Blocking mode – The library is usually used in blocking mode, i.e. it will wait for the hardware becoming available before returning a reading.This might be a program for me using more that two hx711 modules. The Rpi version can use multi-threading and can execute two hx711’s in parallel, therefore should be more time efficient.The Arduino hx711 library is compatible to the following architectures:(a) ATmega328: Arduino Uno
(b) ESP8266: WeMos D1 mini, Adafruit HUZZAH
(c) Arduino core for ESP32 (ESP32 DEVKIT V1, Heltec WiFi Kit 32, Adafruit Feather HUZZAH32)
(d) Arduino core for STM32 (STM32 F1 (Cortex-M3): STM32F103C8T6 STM32 Blue Pill Board)I am particularly interested in (d), ie:Arduino core for STM32 (STM32 F1 (Cortex-M3): STM32F103C8T6 STM32 Blue Pill Board)But I only know Arduino UNO and nothing about STM32 (Though I know ESP8266 WeMos D1 Mini, but found its microPython a bit slow). So my contingency plan is to switch to STM32, in case I get stuck in PyPi hx711 library and have to give up.
Leave a Reply