My First OctoPrint Plugin! It pulls in the data from the FilaWeigher, my filament weight/room temperature/humidity/pressure sensor

Here's a link to the FilaWeigher:

And here's a link to the plugin:

I'm not really sure how many of you have implemented the FilaWeigher in your setup, but if you have, please do me a favor and update it to the latest code, and then try out this plugin. Like I said, it's my first plugin, and I've literally only tested it on my main OP instance and a test one I spun in Ubuntu on WSL.

At this time, all this plugin does is grab the data from the FilaWeigher every x seconds, and displays the values on the sensors in OP, under the connection state.

Also, in my very biased opinion, it might be useful to look at this plugin if you are someone that is also writing their first plugin, and you aren't very strong with Python and JS. I tried to keep the code as slim as possible, and tried to put in a lot of comments.

Please let me know what you think.

4 Likes
  • It's probably a good idea to create/update your project's .gitignore file to include *.egg* and then git rm OctoPrint_Filaweigher.egg-info
  • I suppose this will work, I'm just not familiar with seeing it plugin_version = "2020.01.30.1"
  • I think I would check the IP address once in the init and store this under the main class as self.IPAddress (rather than looking it up every ten seconds)
  • Likewise, I would do something like this, too, in the init: self.isValid = self.is_valid_ipv4_address(IPAddress)... and then...
	def check_sensors(self):
		if self.isValid: #Check if it's a valid IP
			url = "http://" + self.IPAddress + "/json" #Create the URL string to use
			try: #Try connecting, and if it works, then send that data to the send_plugin_message

In this way, you've done a lookup (possibly from microSD) and a system call once at the beginning and then you're using that information for the duration of the print job. You'd have to test to see what happens if the filament sensor device goes offline during the print job, though.

Hi,

Thanks so much for the post, code and plugin. I tried posting this over on your blog but the captcha has been broken for some time.

I have a Stuva enclosure with a adjustable bearing roller on top, So I have drawn up a box to act as scales that I will then screw the roller on top of, I'll drill a hole into the enclosure to home the heat\temp senor inside. I am using a Full sized Wemos D1 as it was sitting in a drawer from an old project and I like the idea of having it separate from my Pi as that is mounted inside the printer at this stage.

I have it all working, just needed to adjust the pins for the full sized D1, The issue mentioned in a comment on your block with the BME280 being needed is you have a while loop is the status check for it, so it won't move on unless it is found, I removed that while I was testing just the load sensor.

I also noticed the value for pressure reported in the web\json is different from the value on the serial interface, I adjusted pressure = bme.readPressure(); to match the serial output (bme.readPressure() / 100.0F) to make it a little easier to read, still not sure pressure will have much value though.

It would be nice to have the setting for Spool Offset moved to Octoprint and maybe incorporated into another plugin like Filament Manager\Spool Manager, since each brand of filament has a different weight. OllisGit has an Enhancement planned for PrintJobHistory (https://github.com/OllisGit/OctoPrint-PrintJobHistory/issues/18#issuecomment-692380187) so I am looking forward to improved use of the output from this device.

Thanks again,
Beau

Thanks for the feedback, but I don’t think I will personally ever get around to adding controls into OP for this. I’m just not good enough at the python part of it.

And even then I don’t think there are that many people using it. If it got more popular I might actually think about doing stuff like that.

And yes, the pressure values are almost useless.

Can the plugin be updated as i cant run the plugin because of python dependencies

I assume you mean for Python 3 compatibility? Looking at the plugin, it seems three would be some necessary changes, as I don't think Python 3 supports urllib2. I had to convert my plugins to utilize requests instead for the easiest compatibility between both python versions. Then just needs to add the compatibility flag. It's not a trivial conversion, but pretty straight-forward. Here's an example of where I did it.

Honestly, I didn't think there were many, if any, people actually using my plugin. I actually haven't been using it since I moved octoprint over to python 3. I don't think my python skills are good enough for this upgrade.

Yea that she one

All good man no issues i have built one of these and am implementing it into home assistant with MQTT

ill look into MQTT Subscribe to allow me to pause the print when filament gets low.

My setup is similar i have an old linux box running octoprint and want to use this as a filament runout sensor and temperature monitoring for my enclosure.