I designed a standalone WiFi weight sensor for filament

Full write up with code and steps on how to put it together. If you know basic soldering it is super easy to put together. And the parts can all be bought for less than $7 in parts.

Write now I have it setup where one URL simply returns the weight left without any other HTML code. I was hoping to use that for OP to be able to pull the weight down. Maybe code some logic to pull that info live into the Filament Manager plugin. I might fork that one to do so. I don’t know any python though so I have no idea how well that will work.

Let me know what you guys think.

UPDATE: I added the BME280 sensor as well. Along with MQTT support. I created a new blog post for that so I can leave the old code up for people that don’t want the new features.

3 Likes

You may want to work with @OllisGit and his SpoolManager plugin...

Thanks. Looks like you’ve tagged him. He can chime in and see if he thinks it’s something that would work with his setup. I haven’t used that plugin yet.

Brilliant work.

I was working with someone who wanted me to spinup an automated IoT weighing project, did all the research and then the project just fell through the cracks. So I almost ended up building something like this within the warehouse space.

Ive worked with these ESP8266 devices so much the IOT part of it was fairly easy. It took me longer to measure and design the spool holder part of it. I probably should have just used the designs people had already made, but I didn’t want to wait for the bearings to come in the mail :slight_smile:

1 Like

Would we need to know the empty spool weight first? Some.manufacturers include that in the 1kg of filament you buy, so you don't really get 1kg of filament

1 Like

The empty spool weight is technically known as "tare" weight, for what it's worth.

Yes. You would need the empty spool weight. I coded a setting in there to account for that.

There is a site that has the weight of many common spools.

Let me know what you guys think.

Hmm. Also perfect to detect knots at the filament and... filament what is fixed at the spool.
If current VAL > shutdown Val = pause print.

That’s a good idea.

Hi @simpat1zq,
I like the idea very much and an integration to my spool-manager plugin should be easy to do (still in development, not released yet).

Do you think it is possible to detect also movement? Or better "no movement". That would be super-duper, because I am looking for a better run-out-sensor as my "microswitch" and "rotary-encoder" approach.
Maybe something like this:

1 Like

It should definitely be able to tell when the spool is being pulled. But not with any sort of accuracy. You won’t be able to tell how much filament was passed through from that measurement. But really, the printer/OctoPrint know better as to when the printer is using filament.

Edit. I guess I should have clicked the link. That should definitely be fairly easy to get readings from it using my project. With little to no changes to my code.

I don't think I'd necessarily start grafting on new functionality (like spool immobility) to a simple scale plugin. If it were me, I would just start a new plugin which does this given that the currently-printed plastic design could accommodate this.

@Ollisgit I'm fond of this approach to completely replace all filament-delivery problems. I've just been so busy with work that I haven't finished it yet.

Another approach could be to have bearings in the thing which holds the spool and to transfer the movement to a detector.

@OllisGit I've got my FilaWeigher, as I call it, fairly close to complete. I added a BME 280 to it, so it also tells you the temperature, humidity, and pressure. I've got it setup so that if you access the FilaWeigher at http://ip_address/json, it returns all the values in JSON format, like below:

{"weight":"265.55","temperature":"25.58","humidity":"23.82","pressure":"97822.56"}

Is this something you might be able to integrate into your plugin? I've tried to take a look at your code, but unfortunately, I know VERY little Python and I can't wrap my head around the code at all. I know enough about other languages enough to say that it likely isn't hard to take that JSON and use that for your values instead of reading the values from the Pi. But alas, I don't know enough Python to even get started doing that.

I believe all you would need is a setting for the plugin to use the FilaWeigher, and provide an IP address to it.

I've integrated a similar approach into the tasmota plugin when there is a sensor attached.

Are you using MQTT for that by any chance? Because I also have MQTT working on this thing. I know that the MQTT plugin has hooks in it that would allow other plugins to subscribe to an MQTT topic.

I'm just having hard time figuring out how I would grab this data and pull it into OP. Do you have any very simple plugins that would be a good starting off point to learn this stuff, pretty much from scratch? I just need to know how a plugin creates a settings page. And how to use those settings to display something on the OctoPrint webUI.

This is exactly what the Hello World plugin does. Check out the plugin tutorial here. My current 0.8.9 dev branch of the web based Tasmota plugin does show how to create a tab and display json data in a graph though.

I have not made the changes for sensor data to the TasmotaMQTT plugin yet, just the web based one for Tasmota devices. That TasmotaMQTT plugin does show how to use the MQTT plugin's helpers to create connections, subscriptions and such though.

@jneilliii Thanks for that pointer to the hello world plugin. I think that should be what I need. That said, I'm not able to get the very basic version of that plugin to load.

EDIT AS I WAS TYPING THIS POST: It turns out that if you copy a file over to the Linux Subsystem folder from Windows Explorer, or any Windows tool, the Linux install won't see it. I access the windows files vs /mnt/c and copied it over inside of ubuntu. Just posting this in case someone else runs into this problem.

OK. I think I'm close to getting the weight via MQTT. I am able to display it in the logs. But I can't seem to get it into the navbartemplate. I can make the navbar display 'helloworld', using the following code:

	def get_template_vars(self):
		return dict(htmlWeight = "helloWorld")

Then I reference that htmlWeight variable in the .jinja2 file. But, if I use the following code, it doesn't show in the navbar:

def get_template_vars(self):
        return dict(htmlWeight = weight)

Weight is a global variable. And I update it everytime a MQTT message is published. When I use this code, I get an error message in the logs saying "2020-01-27 02:52:07,223 - octoprint.server.views - ERROR - Error while retrieving template data for plugin helloworld, ignoring it"

Any ideas on what I need to change to make this work?

Hi @simpat1zq,
IMHO you need to change "a lot".

  • How do you define your global-var? Maybe inside the class, then you need to use self.weight.

Just using get_template_vars is not enough, because the value is only read once the browser opens the octoprint homepage.
So, you need to decide if you want to push the new weight-value from octoprint-server to the frontend or pull the value via javascript-call.