techman83 / filament-scale-enhanced Goto Github PK
View Code? Open in Web Editor NEWThis project forked from dieki-n/octoprint-filament-scale
License: GNU Affero General Public License v3.0
This project forked from dieki-n/octoprint-filament-scale
License: GNU Affero General Public License v3.0
Hi,
is it possible to use other GPIO pins for connecting the load cell? 20 and 21 are already in use for me. Can I simply change the values in init.py or are these pins somehow "hardware-required"?
Thanks,
Christian
I am not able to get a constant load readings from my setup with this plugin. It fluctuates in a wide range. I did the following troubleshooting steps:
At this point I am pretty sure its not my equipment (of course it is the almost the cheapest stuff you can get) because it worked fine on the Arduino. I am thinking maybe it has to do something with the way the plugin reads the cell. Maybe it is the refreshing frequency? Or the calibration factor is a problem, I had to set some really high values on the Arduino setup.
If needed I could provide more information. I do not want to spam logs or anything else here without request :)
EDIT: I have hooked up a filament sensor and a relays module, too. Some other GPIO pins are in use.
I found only one "kind of" error in the log file:
2021-08-18 18:00:48,259 - py.warnings - WARNING - /home/pi/oprint/lib/python3.7/site-packages/filament_scale_enhanced/hx711.py:28: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
Hello, I have not seen this plugin before now, have been using Home Assistant & esphome for my scale and rfid tagging, was wondering if it would be a massive amount of work to set up an endpoint that home assistant could relay the current scale reading to? I didn't get a raspberry pi before they became solid gold so I have to rely on an esp32 to see what my current filament weight is. If it's way outside scope or a lot of work it's ok I don't expect to even get a response on this but just thought I'd give it a go, thank you!
the reading keeps fluctiation with 10/15g to more or less... we could have a more "inteligent"algoritm to discart strange readings.... assuming the printer takes slow portions in the printing...
Filament-Scale-Enhanced/filament_scale_enhanced/hx711.py
Lines 87 to 91 in ab7daf4
This line will behave differently under Python 3.5+. In older versions this will behave like time.sleep(0) and sleep for between 0.5 and 14 usec. In Python 3.5+ it will sleep for 60 to 100 usec (ie the minimum non-zero sleep). See pimoroni/blinkt#72 for details.
Since the delay is only while PD_SCK is low it should not cause spurious resets but I wanted to point it out anyway.
Raised in #20, it would be desirable to support more than one sensor.
Good Morning -
Just installed HX711 on Raspberry Pi 4 and successfully tested it using example.py from the hx711py library after editing script to use 20 & 21. Installed your plugin in OctoPrint, but always shows "Loading" in console. If I tear it in plugin config, it goes to 0g, but never shows any measurements.
Looked in octoprint.log and found the below:
2022-01-21 09:25:23,202 - octoprint.plugin - ERROR - Error while calling plugin filament_scale
Traceback (most recent call last):
File "/home/pi/oprint/lib/python3.7/site-packages/octoprint/plugin/__init__.py", line 271, in call_plugin
result = getattr(plugin, method)(*args, **kwargs)
File "/home/pi/oprint/lib/python3.7/site-packages/octoprint/util/__init__.py", line 1737, in wrapper
return f(*args, **kwargs)
File "/home/pi/oprint/lib/python3.7/site-packages/filament_scale_enhanced/__init__.py", line 50, in on_startup
self.hx = HX711(20, 21)
File "/home/pi/oprint/lib/python3.7/site-packages/filament_scale_enhanced/hx711.py", line 27, in __init__
GPIO.setmode(GPIO.BCM)
ValueError: A different mode has already been set!
Not a Python expert, but seems there's a conflict setting the mode as GPIO.BCM perhaps after a recent OP update? What may be done to address this?
UPDATE: Did see that another plugin, LED Strip Control; sets GPIO.BOARD which may be the conflict. That plugin works, though; and is used. Would potential fix be as easy as changing "GPIO.BCM" to "GPIO.BOARD" in hx711.py, then changing the 20, 21 values in init.py to board pin numbers? (In middle of long print currently, so can't test.)
Thank You
As noted in #16, having fixed pins means the only choice if you have already occupied 20/21, is to alter code.
Filament Sensor Simplified also has a UI for Pin Configuration, which we could also use as an opportunity to make it clearer about what wire goes to which pin.
To ease with transition, we should ensure a default of 20/21 is set.
Currently the library forces a board mode of BCM, which can make getting the right pins confusing and could impact configuration of other plugins.
Filament Sensor Simplified has a reasonable UI to config this, of which we could draw inspiration from.
To ease with transition, we should set this to BCM if we already have settings, otherwise GPIO mode should be the default choice presented.
Hi,
Python is a script language and not a good language for time-sensitive comms. The HX711 is a very simple device with little tolerance on its comms at 80hz. That's why python can never achieve that accurate timing to communicate with HX711 effectively.
I would propose looking that https://github.com/endail/hx711 C++ library with python bindings @https://github.com/endail/hx711-rpi-py.
Let C++ handle the time-sensitive stuff and the library returns the median reading of 3 readings. I think this will be more accurate than the python Hx711 library being used.
Sorry I am unable to do the integration because I don't know anything about the octoprint framework and I don't really have time to work on it, hope somebody with time to spare can work on this.
hi @techman83
is it posible to add another sensor with its own display in octoprint.
thanks
martin
hi sorry to be a pain but is there a way to add asimple display to the pi gpio's to display the weight in real time.
eg - TM1637 or a SH1106, SSD1306
thanks
martin
keep up the good work much apreciated
It seems that the plugin needs to be re-calibrated everytime the pi is rebooted.
Hi,
I am a noob at this. I installed the plugin in Octoprint with the link and it showed up in plugin manager. I activated it and nothing shows up under plugins. I have installed the wire as the link showed. Everytime I restart Octoprint the plugin is deactivated in plugin manager. Need help
Whilst there is text mentioning to save after certain actions, it's pretty easy to miss (I certainly have). With the client side framework in use, it wouldn't take a lot to have a save button appear next to an action when required.
Like many with older printers, mine continues to print after running out of filament. Adding the ability to pause printing when the reading reaches a predetermined weight would be brilliant.
when i start printing here, the scale receives more ห100g. probably, because of the force applied from pulling the material... whold be great two calibrations.... idle and printing.
Hi,
I have a dual extruder printer. Can I install 2 devices on the same raspberry pi to weight 2 spools?
I would like to know if there is an ioBroker export possible.
I have the octoprint adapter, and it whould be nice to have the actual weight in the objects (like in the "filament" folder)
When attempting to install plugin using the plugin manager on octopi 0.18 stable the following error happens:
2021-05-03 20:45:54,303 /home/pi/oprint/bin/python3 -m pip --disable-pip-version-check install file:///tmp/tmp_0eg9bt7/Filament_Scale_Enhanced.zip --no-cache-dir
2021-05-03 20:45:56,801 > Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
2021-05-03 20:45:56,802 > Processing /tmp/tmp_0eg9bt7/Filament_Scale_Enhanced.zip
2021-05-03 20:45:58,780 ! ERROR: Command errored out with exit status 1:
2021-05-03 20:45:58,781 ! command: /home/pi/oprint/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-hlp1on8u/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-hlp1on8u/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-iz4lm_4h
2021-05-03 20:45:58,781 ! cwd: /tmp/pip-req-build-hlp1on8u/
2021-05-03 20:45:58,781 ! Complete output (16 lines):
2021-05-03 20:45:58,782 ! Traceback (most recent call last):
2021-05-03 20:45:58,782 ! File "/tmp/pip-req-build-hlp1on8u/filament_scale_enhanced/hx711.py", line 5, in <module>
2021-05-03 20:45:58,782 ! import RPi.GPIO as GPIO
2021-05-03 20:45:58,782 ! ModuleNotFoundError: No module named 'RPi'
2021-05-03 20:45:58,783 !
2021-05-03 20:45:58,783 ! During handling of the above exception, another exception occurred:
2021-05-03 20:45:58,783 !
2021-05-03 20:45:58,784 ! Traceback (most recent call last):
2021-05-03 20:45:58,784 ! File "<string>", line 1, in <module>
2021-05-03 20:45:58,784 ! File "/tmp/pip-req-build-hlp1on8u/setup.py", line 5, in <module>
2021-05-03 20:45:58,785 ! from filament_scale_enhanced import __version__
2021-05-03 20:45:58,785 ! File "/tmp/pip-req-build-hlp1on8u/filament_scale_enhanced/__init__.py", line 7, in <module>
2021-05-03 20:45:58,785 ! from .hx711 import HX711
2021-05-03 20:45:58,785 ! File "/tmp/pip-req-build-hlp1on8u/filament_scale_enhanced/hx711.py", line 7, in <module>
2021-05-03 20:45:58,786 ! import Mock.GPIO as GPIO
2021-05-03 20:45:58,786 ! ModuleNotFoundError: No module named 'Mock'
2021-05-03 20:45:58,786 ! ----------------------------------------
2021-05-03 20:45:58,786 ! ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
A nice feature would be to have several slots to save empty spool weight and give them a name. You could then switch between them as you change filament.
Can you point me in the right direction on how I can get this info into Octodash, would love to mass out spools from dash .
The plugin can be installed now but it still doesn't work.
It works with Victor's version, and with the original standalone hx711py library.
hi @techman83
is there any way to send mqtt messages so i can connect a screen .
thanks
martin
The NAU7802 ADC is a pretty solid ADC that has one major advantage over the HX711: I2C communication. This allows for much more reliable reads (addressing #28) from higher-level code since it doesn't require any time-sensitive bit banging while still using only four pins.
The first downside is that the NAU7802 is a bit more expensive, but not prohibitively so. While HX711 breakouts can be found in the $1-5 range from a variety of vendors, NAU7802 breakouts are typically in the $5-20 range from only a few vendors.
Its also much more complex device to set up/manage than comparatively super-simple HX711. On the other hand, that makes it a lot more configurable for different use cases, and there are already some decent drivers to work with.
Driver options/examples:
Blinka
compatability layer on Raspberry Pi and other platforms to work with normal Python.Boards:
Pi's are really expensive rn, 200+ for a 4 and 100+ for a 3+. Having support for non pi boards would help reach this out to more people.
If this isn't an option, I know the Pico's are still relatively cheap. 14$ or so for one with sodered pins. running the sensor off of this and as a slave device over USB should be a viable alternative for those using anything other than Pi's
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.