Introduction: IoT Enabled Smart Filament Runout Switch

Many 3D printer firmware such as Marlin support filament runout sensor and can pause the print for filament change when the filament ran out or broke. However, the user has to be nearby to monitor the printer. Watching the filament running out so you can switch to a new roll is like watching the paint dry. Thanks for ESP8266 and Blynk APP, this IoT enabled filament runout switch will not only pause your 3D printer when the filament ran out but can also notify you using push notifications and email. So you can feel free to walk away from the printer and return to change the filament roll when it happens.

Step 1: Hardware Design

The project is designed around a WeMos Mini which is a mini wifi board with 4MB flash based on ESP-8266EX. It has a micro USB connection that makes the flashing the Arduino sketch easily.

This device contains a built-in filament runout switch that will monitor the breakage of the filament. The microswitch will change the state and switch from On to Off when the filament ran out. The D6 pin from the WeMos Mini is connected to the 3D printer control board Signal pin via a 1K ohm resistor as protection. The device works in the way as a regular filament runout switch would.

When there's filament, the microswitch will be triggered and connect to Low (GND), and the WeMos D5 pin will be low, the LED is off, and D6 pin is High at 3.3V. The MKS Base control board has a 10K pull-up resistor on the Servo signal pin, the control board will read 3.3v as HIGH, indicates the filament is present and the printer will work normally.

When filament run out, the microswitch will no longer be triggered and become open (null), thus the WeMos D5 pin will be High, the LED is on, and D6 pin becomes low which will let the control board sense the filament is out and the Marlin firmware will pause the print and enter filament change mode.

In the same time, the WeMos mini publishes the filament status to the Blynk App. It also sends the alert to Blynk to notify the user by email and push notification when the filament is low.

Step 2: Parts and Tools

The following are the parts and tools required to make this project. All the parts are available from online stores. A 3D printer and fine tip soldering iron and some soldering skills are required to make this project. You also need to know who to use Arduino IDE to upload a sketch.

Hardware components:

  • Wemos D1 Mini × 1
  • KW11-N micro limit witch (10x20mm) with roller arm. × 1
  • 3mm LED (generic) × 1
  • 220 ohm Resistor 1
  • 1k ohm × 1
  • 3 pin female servo connector x 1
  • Some wires and shrink tubing

Software tools:

  • Arduino IDE
  • Blynk account

Step 3: How to Make It

Enclosure

The enclosure is fully 3D printed. The physical design of the enclosure allows simple assembly of the device with no screws. It also has a specially designed filament movement and detection mechanism which will ensure the reliable operation of the microswitch as well as the smooth filament movement. Additionally, the enclosure also allows simple installation of the device to the printer extruder using a piece of regular PTFE tubing. For 1.75mm filament.

Print the cover with transparent filament since the blue LED onboard the WeMos is used as the indicator of power and internet status.

Wiring and assembly

The wiring is straightforward, follow the wiring diagram in the attachment.

Step 4: Blynk and Arduino

First of all, you need to set up a Blynk account and download the Blynk app to your phone. The Blynk app is available for both iOS and Android.

Once installed, open the Blynk app and click on 'Create New Project' to add the project, for example ‘Filament watch', and choose 'ESP8266' as the device type. The Blynk will send you the authentication token which you'll need for the Arduino sketch.

Fill in the WiFi credential and the Blynk authentication token to the code given in the ino file below. You also need to download the ESP8266WiFi.h, BlynkSimpleEsp8266.h and SimpleTimer.h libraries if you haven't done it before, there are many online tutorials to show how to install the Arduino libraries. I found the Instructables below are very helpful:

Programming the ESP8266 WeMos-D1R2 Using Arduino Software/IDE

Step 5: Enable the Filament Runout Function on the Printer

I used Marlin firmware on a MKS Base 1.4 controller board in this instructable. You may need to make changes to the printer firmware depending on the model you have.

To enable the filament runout sensor function on a MKS Base 1.4 board:

  • Enable the function in the Marlin firmware by uncommenting following line in the configuration.h
#define FILAMENT_RUNOUT_SENSOR
  • Change the pin assignment to the FIL_RUNOUT_PIN from 4 to 11. I added following lines in the pins_MKS_13.h since the servo1 port on the MKS Base 1.4 board is assigned to PIN 11. If you use regular RAMPS board, skip this step.
#undef FIL_RUNOUT_PIN
#define FIL_RUNOUT_PIN 11

Step 6: Install the Switch to Your Printer

Once complete the switch can be connected to the extruder with a 4mmx50mm PTFE tubing. The switch is bi-directional, you can also make a small adapter connects to the PTFE tubing to install the switch near your extruder or near the filament roll. Here I used a Titan extruder and a regular extruder on the TEVO Tarantula as examples.

The device is connected to the Servo port 0 on the 3D printer control board which also supplies the 5V to the WeMos Mini. Note that on the MKS board servo port the polarity of the +5V is switched.

Step 7: Final Configuration and Testing

Once all done and everything connected and powered up, you can go ahead configure the Blynk to show the filament status. The LED on the WeMos will start flashing once the internet connection is made and started monitoring the filament status. The LED mounted on the case will be turned as a visual indicator that the filament has run out which is helpful when you have multiple printers or extruders. The Smart Fillment Runout Switch will write to the Blynk virtual pin 1, you can add a LED in the app which will turn on when the filament is low.

When the filament runs out, the printer will pause the print with M600. In the same time, you'll receive a push notification as well as an email every 30 seconds to notify the filament is now until the filament is loaded.

Wireless Contest

Participated in the
Wireless Contest