dieki-n / Octoprint-Filament-Scale

48 stars 31 forks source link

Plugin not getting a reading from the sensor #11

Open abrenoch opened 4 years ago

abrenoch commented 4 years ago

Hey there, I followed the guide here, substituting the pins of course, but I am not able to get this plugin to read anything from the sensor. I tried the example code in that link, and that appears to function as expected.

When octoprint starts it simply says 'loading', and when trying to tare/calibrate it will go to 0g but I never get an actual reading from it. Can confirm I am using the correct pins as well.

Does anyone have any advice for me before I start trying to dig into the plugin code? Thanks!

Running the latest octoprint (1.4.2) on a raspberry pi 3 b+

In the logs I am seeing:

2020-08-22 14:48:36,620 - octoprint.plugin - ERROR - Error while calling plugin filament_scale
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint_filament_scale/__init__.py", line 58, in on_startup
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint_filament_scale/hx711.py", line 18, in __init__
abrenoch commented 4 years ago

I was able to get a little more info on this:

Traceback (most recent call last):
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/plugin/__init__.py", line 230, in call_plugin
    result = getattr(plugin, method)(*args, **kwargs)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint_filament_scale/__init__.py", line 58, in on_startup
    self.hx = HX711(self.PD_SCK, self.DOUT)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint_filament_scale/hx711.py", line 18, in __init__
    GPIO.setmode(GPIO.BCM)
ValueError: A different mode has already been set!

Seems like it is an issue of BCM vs BOARD mode... Another plugin I assume is using the GPIO in BOARD mode causing the issue? I'll try switching that out manually.

cybercorey commented 3 years ago

Looks like Im facing the same or simular issue:

2020-09-22 09:33:04,249 - octoprint.plugin - ERROR - Error while calling plugin filament_scale
Traceback (most recent call last):
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/plugin/__init__.py", line 230, in call_plugin
    result = getattr(plugin, method)(*args, **kwargs)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint_filament_scale/__init__.py", line 48, in on_startup
    self.hx = HX711(20, 21)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint_filament_scale/hx711.py", line 18, in __init__
    GPIO.setmode(GPIO.BCM)
AttributeError: 'module' object has no attribute 'setmode'

Its seems that the plugin cannot setup the mode. (im no python expert) I have however managed to run the code from https://github.com/tatobari/hx711py which is working via ssh.

cybercorey commented 3 years ago

Solved my issue with a octopi reinstall :)

BzowK commented 3 years ago

Hey Guys -

Had the same issue and figured out a solution. Seems to be that plugin conflicts with another installed one in the way it references pins (GPIO number via actual pin number) as you can only reference them one way. Below are the steps to resolve:

  1. Connect via SSH
  2. Execute (or browse to) "cd /home/pi/oprint/lib/python2.7/site-packages/octoprint_filament_scale/"
  3. Execute "sudo nano init.py"
  4. Edit line 48 and change the two GPIO pins referenced from GPIO numbers to pin numbers (If 20, 21 change to 38, 40)
  5. Ctrl-O to save then Ctrl-X to exit
  6. Execute "sudo nano hx711.py"
  7. Edit line 18 and change "GPIO.setmode(GPIO.BDM)" to "GPIO.setmode(GPIO.BOARD)"
  8. Ctrl-O to save then Ctrl-X to exit
  9. Restart OctoPrint and it should work

Enjoy!

parsko41 commented 3 years ago

Hi,

I installed my HX711, manually installed the plugin. I had to make changes mentioned in another issue to get the plugin to activate and be visible in the settings menu. That was successful. But, I have gone through and made the changes listed above, and I am not able to see any values in the plugin. No Taring, nothing. I did also change another line, earlier than line 48 in step 4 above, where the default pins are set. I changed that as well.

I am only now able to see the "red slash" over the Current Reading box. I'm assuming it's failing reading it. I have not dug into the python code behind this. I have another python driver I use with the HX711 I may play around with substituting it. I use it for work, and pulled it from Github somewhere (I don't have that reference offhand which one it is).

@BzowK did you do anything else?

ghost commented 3 years ago

I've made the changes the suggested and my scale still doesn't work :( Anyone know of any other leads as to what we can do it get it operational?