Make a Filament sensor with load cell and buzzer.

“Good ideas are more likely to emerge in environments that contain a certain amount of noise and error.” 

― Steven Johnson, Where Good Ideas Come From: The Natural History of Innovation 

So...while running 3D printers, we encounter a small problem that our 3D printers run out filament without a notice. As we run so many printers with a tiny team, it is hard to "babysit" each one. Therefore, we are scratching our own itches by inventing a filament sensor which it will send us a notice before the filament running out. This article is to document our thought process how to build a filament sensor. 

Tho "T" Huynh

Mechanical Engineer & Co-Founder, Onset Engineering Inc.

First, we brainstorm ideas and research electrical components.

What sensor should be used to detect amount of filament?

As an engineer, there is no such a "perfect solution" ( thanks God there is still positions for engineering job market at all time) as we always have room to make improvement. In this case, there are many methods to measure how much filament left on the spool such as: 

Which load cell sensor is appropriate ?

There are variable of filament spool weight on the market from 1 kg to 2.5 kg. At our company we usually use 1 kg spool, so to be safe, I would use TAL220, which can measure up to 10 kg weight to start since I found that Sparkfun has the source code and full instruction for this sensor. So here you are: https://learn.sparkfun.com/tutorials/getting-started-with-load-cells/all#load-cell-basics

Prototyping 

Calibrate my load cell

After receiving my load cell, I follow instruction and wire load cell and the load cell amplifier as the diagram instructed https://learn.sparkfun.com/tutorials/getting-started-with-load-cells/all#load-cell-basics. ( I also changed the unit from lbs to gram) 

Download calibration code:  https://github.com/sparkfun/HX711-Load-Cell-Amplifier/tree/V_1.1

Assembly and Test sensor component

I tested how the weight increase as the filament is hang on the handle. Also I used the scale to compare the weight between the load cell handle and real weight for calibration. 

In Summary

Work Instruction


1. Components:

3. Upload the code to Arduino .  (The original code is from Sparkfun, it goes with the HX711. I modify it to add on the buzzer. )

[ Download Arduino Software: https://www.arduino.cc/en/Main/Software ]

/* Tho A Huynh *  Onset Engineering Inc. May 10, 2020 *  I did add on the buzzer on the original code from the load cell for the Project : Filament Sensor Spool System *//*Example using the SparkFun HX711 breakout board with a scaleBy: Nathan SeidleSparkFun ElectronicsDate: November 19th, 2014License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).This is the calibration sketch. Use it to determine the calibration_factor that the main example uses. It alsooutputs the zero_factor useful for projects that have a permanent mass on the scale in between power cycles.Setup your scale and start the sketch WITHOUT a weight on the scaleOnce readings are displayed place the weight on the scalePress +/- or a/z to adjust the calibration_factor until the output readings match the known weightUse this calibration_factor on the example sketchThis example assumes pounds (lbs). If you prefer kilograms, change the Serial.print(" lbs"); line to kg. The calibration factor will be significantly different but it will be linearly related to lbs (1 lbs = 0.453592 kg).Your calibration factor may be very positive or very negative. It all depends on the setup of your scale systemand the direction the sensors deflect from zero stateThis example code uses bogde's excellent library: https://github.com/bogde/HX711bogde's library is released under a GNU GENERAL PUBLIC LICENSE Arduino pin 2 -> HX711 CLK3 -> DOUT5V -> VCCGND -> GNDMost any pin on the Arduino Uno will be compatible with DOUT/CLK.The HX711 board can be powered from 2.7V to 5V so the Arduino 5V power should be fine.*/#include "HX711.h" //This library can be obtained here http://librarymanager/All#Avia_HX711#define LOADCELL_DOUT_PIN  3#define LOADCELL_SCK_PIN  2int pin = 4;HX711 scale;float calibration_factor = 219.5; //-7050 worked for my 440lb max scale setupvoid setup() {Serial.begin(9600); Serial.println("HX711 calibration sketch");  Serial.println("Remove all weight from scale");  Serial.println("After readings begin, place known weight on scale");  Serial.println("Press + or a to increase calibration factor");Serial.println("Press - or z to decrease calibration factor"); scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);scale.set_scale();scale.tare();  //Reset the scale to 0long zero_factor = scale.read_average(); //Get a baseline readingSerial.print("Zero factor: "); //This can be used to remove the need to tare the scale. Useful in permanent scale projects. Serial.println(zero_factor);}void loop() {scale.set_scale(calibration_factor); //Adjust to this calibration factorSerial.print("Reading: ");Serial.print(scale.get_units(), 1);Serial.print(" g"); //Change this to kg and re-adjust the calibration factor if you follow SI units like a sane personSerial.print(" calibration_factor: ");Serial.print(calibration_factor);Serial.println();  if (scale.get_units()<235){    tone(4,500);  }  if(scale.get_units()>235) {    noTone(4);  }  if(Serial.available())
  {
    char temp = Serial.read();
    if(temp == '+' || temp == 'a')
      calibration_factor += .1;
    else if(temp == '-' || temp == 'z')
      calibration_factor -= .1;
  }
}

So now whenever the filament goes low the buzzer will make a sound and we will come and change its spool.

This project will be upgrade by adding esp 32 so it can even send an email to us when load cell sense low weight on filament .