dieki-n / Octoprint-Filament-Scale

48 stars 31 forks source link

Plugin values continuously read "Sensor Not Connected" #3

Open pandaabe101 opened 5 years ago

pandaabe101 commented 5 years ago

When connecting the breakout board to the load cell, every minute or so the plugin on OctoPrint would read "Sensor Not Connected", even while there was no external interference given before or after the faulty reading. I am using female to female jumper wires to connect a Pi 3B+ to the HX711 breakout board, and the given female connectors to the breakout board. The Pi is running OctoPi 0.15.1.

pandaabe101 commented 5 years ago

I am connecting to OctoPi via WiFi through a router to a laptop running Windows 10. I am accessing OctoPi through Opera version 58.0.3135.65.

ali1234 commented 5 years ago

I am seeing the same thing, and also occasional incorrect readings of 40x the actual value. It does not happen when I use the sensor with other libraries such as https://github.com/tatobari/hx711py

ali1234 commented 5 years ago

Seems that the reason I don't get this with the other library is because it takes 5 readings and then takes an average. I would suggest instead taking 5 readings and discarding the one with the most deviation, and averaging the other four.

dieki-n commented 5 years ago

I used to take average of 5 readings, but I switched to single readings to improve performance. Some older PIs are already running close to their limit on OctoPrint and taking all those readings every few seconds overwhelmed them.

When I get time I'll probably add it back as an option, since modern PIs don't have a problem with it.

mark-hahn commented 5 years ago

I would suggest instead taking 5 readings and discarding the one with the most deviation, and averaging the other four.

That is almost a median filter. A median filter is the best for throwing out outliers. You sort the five readings and report the middle value. They work great, much better than a mean filter for this type of application.

mark-hahn commented 5 years ago

Can you mark this as a feature request to use a median filter? It needs to be a median since it not only gives connect errors but also reports the giant number which would throw off any mean filter.

Of course finding the source of the connection error would also be nice. I have two setups that do the same thing.