dieki-n / Octoprint-Filament-Scale

48 stars 31 forks source link

GPIO used #16

Open PierreGdrlt opened 3 years ago

PierreGdrlt commented 3 years ago

I want to connect my scale on GPIO 3 (DT) and GPIO 27 (SCK). How can change for use this GPIO instead of 20 and 21 ???

parsko41 commented 3 years ago

Line 48 of init.py

<self.hx = HX711(20, 21)>

You should be able to edit this via an editor. I'm not very good at giving advice as to exactly how, but that's where it is in the code. -Parsko

PierreGdrlt commented 3 years ago

I've changed the 3 lines in Init.py : 36 clockpin=27 37 datapin=3 50 self.hx = HX711(3,27)

and the plugin always give error "Error: No filament sensor detected" I've restart Octoprint, and Pi.

anything else ?

Edit : I've read the issue "Plugin not getting a reading from the sensor" I have changed in HX711.py the line 18 "GPIO.setmode(GPIO.BCM)" to GPIO.BOARD and changed my pins 3 for 5, and 27 for 13 in init.py. The error message has disappear, but the reading is always 0g.

parsko41 commented 3 years ago

Glad you made progress! There is a calibration process, if I recall. It's been a while since I've used mine, as I have been going through printer changes. There is a chance pins are backwards, or a connection issue exists.

-Parsko

PierreGdrlt commented 3 years ago

I checked that my sensor was working fine. I put an SD card with Raspbian in my Pi, and with a proven program (the one that runs another scale on another Pi), I was able to make sure my sensor was functional, and properly plugged in. . So I corrected the init.py file, and restart my Pi. The result is always the same. I have no reading in the settings of FSE. Where should I look for ?? Snapshot_1

parsko41 commented 3 years ago

Hi, It appears that someone is upgrading this. Can you have a look at the following link and see if that solves your problem? I've reviewed my own version of this where I changed my pin assignments, and I did not make any other changes than you have. Maybe you could also look at that. You may have Python 3 issues perhaps? I'm sorry I can't be further assistance.

https://github.com/OctoPrint/plugins.octoprint.org/pull/864

-Parsko

PierreGdrlt commented 3 years ago

Well. Here is the latest bad news. I have tried everything. I have re-installed Octoprint at least 4 or 5 times, a few times it works, and after a few minutes it doesn't work, and sometimes it doesn't work at all. I give up ... I will do more tests maybe in a few months, if the plugin stabilizes, or maybe other things will be released in the meantime.

Good continuation.

parsko41 commented 3 years ago

My experience with the HX711 chips is dodgy. They do not provide stable reading, simply put. I use them professionally, and can get them to work because I am writing the software. But, even then, they give me sporatic readings that are simply wrong. Using them with a Raspberry Pi is worse than a proper microcontroller. It's a pseudo I2C protocol. It's I2C, but does not work with I2C libraries, in my experience. I have not tried again since I've gained much more experience with it. I also haven't read the datasheet to get the exact timing between edges and such. I'm sure there is one to get it to read reliably, perfectly.

A proper way to do this, IMHO, is to have a sub micro, like a RP2040 QTPY do the reading and filtering, while also maintaining the communication with the Pi. Much cleaner and more reliable. It's on my LOOONG list of things to do in the next couple years.

If it's worth anything, mine isn't hooked up right now. I would really love this integrated with the spool manager. Another item on the list....

Good luck, stay safe.

PierreGdrlt commented 3 years ago

Thank's Parsko41