
As you may have seen in my previous projects, I am utilizing a Creality CR-6 SE to print the 3D models I designed. During some of my prints, I encountered malfunctions related to the movements of my 3D printer four times while I was outside or not observing my printer. Generally, a non-watertight model, a problematic STL file, or an unstable printed part jammed or shifted one of the printer axes. When an axis is jammed or shifted, it causes faulty prints or impedes the printing process for troubleshooting.
Since the Creality CR-6 SE does not have Wi-Fi or an early warning system to monitor the printer motions and status, I decided to create a device to track the printer’s lateral and vertical motions while printing so as to get informed of potential malfunctions related to the printer movements:
- X-Axis (the hot end)
- Y-Axis (the printer or heated bed)
- Z-Axis
To endow this device with the ability to track X-axis, Y-axis, and Z-axis movements, I decided to employ the HuskyLens AI camera to recognize tags (AprilTags) denoting the axis motion. Since I was trying to develop a budget-friendly IoT device, I decided to utilize Raspberry Pi Pico to obtain and transfer the detected printer movements by the HuskyLens AI camera. Although there are various methods to connect Raspberry Pi Pico to the Internet, I chose to use the Pico-compatible WIZnet Ethernet HAT utilizing W5100S Hardwired TCP/IP CHIP. Since my printer is very close to my router, I did not encounter any issues regarding connecting the Ethernet cable or positioning the device.
After connecting Raspberry Pi Pico to the Internet, I decided to utilize a Telegram bot to track the detected printer axis movements and get notified of malfunctions related to the printer motions. Since Telegram is a cross-platform cloud-based messaging service compatible with iOS and Android, the Telegram bot allows the user to monitor the printer movements and potential malfunctions on several devices. On Telegram, it is effortless to create bots with a command list unalike any other messaging application, which are special accounts that do not require an additional phone number to set up.
To be able to process the detected printer movements and send updates to the Telegram bot automatically, I developed a PHP web application. The web application obtains the printer movements from the Raspberry Pi Pico via HTTP POST requests, stores the received printer movements in the given MySQL database table, detects potential malfunctions related to the printer motions, and sends updates (also notifications) to the Telegram bot via the Telegram Bot API. After developing the web application, I employed a Raspberry Pi 3 to host a LAMP web server to run the application.
Lastly, to make the device as stylish and robust as possible while operating in my workshop, I designed a T-800 Terminator-inspired case with a removable top cover (3D printable).
Step 1: Designing and printing a T-800 Terminator-inspired case
Since I wanted to place the device towards my FDM 3D printer while printing 3D models in my workshop, I decided to design a complementing metallic case to create a robust and sturdy mechanism operating flawlessly. To make device connections more accessible, I added a removable top cover to the case. Then, I got inspired by The Terminator to add a T-800 replica to the device since it aims to track the movements of the printer and detect potential malfunctions to eliminate them 🙂
I designed the main case and its removable top cover in Autodesk Fusion 360. You can download their STL files below.



For the T-800 replica affixed to the removable top cover, I utilized this model from Thingiverse:
Then, I sliced all 3D models (STL files) in Ultimaker Cura.
Since I wanted to create a solid structure for the metallic case with the removable top cover and emphasize the T-800 theme, I utilized this PLA filament:
- eSilk Silver
Finally, I printed all parts (models) with my Creality CR-6 SE 3D Printer. Although I am a novice in 3D printing, and it is my first FDM 3D printer, I got incredible results effortlessly with the CR-6 SE 🙂
Step 1.1: Assembling the case and making connections & adjustments
First of all, I soldered female pin headers (11mm long legs) to the WIZnet Ethernet HAT and male pin headers to the Raspberry Pi Pico in order to connect them to the mini breadboard as shown below.


To recognize the learned tags (AprilTags) so as to track the printer motions (X-axis, Y-axis, and Z-axis), I connected the HuskyLens AI camera to the Raspberry Pi Pico by utilizing the I2C protocol. Also, I added a 10mm common anode RGB LED module (Keyes) and a buzzer to indicate the outcomes of operating functions.
Since the Raspberry Pi Pico operates at 3.3V, it is not able to power the HuskyLens AI camera and the RGB LED at the same time sufficiently. Therefore, I employed an external power source to supply the mentioned components: To elicit stable supply voltage, I connected a USB buck-boost converter board to a Xiaomi power bank.
After completing sensor connections and adjustments on mini breadboards successfully, I made the breadboard connection points rigid by utilizing a hot glue gun
Then, after printing all 3D parts (models), I fastened all components to the main case and connected the LAN Ethernet cable from my router to the WIZnet Ethernet HAT.
Finally, I inserted the removable top cover in its slot on the main case and affixed the T-800 replica to the top of it via a hot glue gun. Also, I attached the HuskyLens AI camera to the case via a screw.



Step 2: Building a Telegram bot with BotFather
I utilized BotFather to create a Telegram bot for this project. BotFather is an official Telegram bot that lets the user create and manage bots on Telegram without any coding required.
#️⃣ First of all, open BotFather on Telegram and enter /start to view the available command list and manuals.

Use the /newbot command to create a new bot. Enter the name of your bot when BotFather asks you for a name. It is displayed in contact details and elsewhere.
IoT 3D Printer Movement and Status Tracker
#️⃣ Then, enter the username of your bot. Usernames are 5-32 characters long and are case insensitive but may only include Latin characters, numbers, and underscores. They must end in ‘bot’, e.g. ‘tetris_bot’ or ‘TetrisBot’.
IoT_3D_printer_tracker_bot
#️⃣ After completing the steps above, BotFather generates an authorization token for your new bot. The authorization token is a string along the lines of 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11 that is required to authorize the bot and send requests to the Telegram Bot API. Keep your token secure and store it safely.
Also, you can change your bot’s profile picture by using the /setuserpic command.
Since I wanted to get only printer movements updates from the Raspberry Pi Pico, I did not need to establish an SSL connection to set a webhook for the Telegram Bot API to send information back to the web application.
However, I needed to obtain the chat id to be able to send updates to the Telegram bot via the Telegram Bot API directly without establishing an SSL connection or setting up a webhook.
To get the chat id, I utilized the getUpdates method, which shows incoming updates using long polling and returns an array of Update objects.
#️⃣ Navigate to this web page by using your bot’s authorization token:
https://api.telegram.org/bot<_token_>/getUpdates
#️⃣ Then, send a message to your bot and refresh the page. It will display an object list, including the chat id:
chat ➡ id ➡ 1496498083

Step 3: Developing a web application in PHP to send updates to the bot via the Telegram Bot API
After creating my Telegram bot successfully, I decided to develop a web application in PHP, named telegram_3D_printer_bot, so as to receive printer movements from the Raspberry Pi Pico, process them to detect malfunctions, and send updates to the Telegram bot.
As shown below, the web application consists of one file and has four parameters to create the required database table and obtain printer movements:
- index.php
Parameters:
- x_axis
- y_axis
- z_axis
- create_table
To run all functions successfully, I created a class named IoT_3D_printer_tracker. You can download and inspect the index.php file below.
⭐ In the __init__ function, define the required variables to execute the functions:
- token ➡ authorization token of the given Telegram bot
- web_path ➡ Telegram Bot API request server
- conn ➡ MySQL database connection settings
- table ➡ MySQL database table name
⭐ In the send_message function, the application sends the given text to the given bot via the Telegram Bot API by employing the bot’s authorization token.
Syntax: https://api.telegram.org/bot<token>/sendMessage?chat_id=<chat_id>&text=<string>
⭐ In the send_photo function, the application sends the given picture to the given bot via the Telegram Bot API by employing the bot’s authorization token.
Syntax: https://api.telegram.org/bot<token>/sendPhoto?chat_id=<chat_id>&photo=<link>&caption=<string>
Step 4: Setting up a LAMP web server on Raspberry Pi
Since I decided to host my web application on a Raspberry Pi 3, I needed to set up a LAMP web server.
#️⃣ First of all, open a terminal window by selecting Accessories ➡ Terminal from the menu.
#️⃣ Then, install the apache2 package by typing the following command into the terminal and pressing Enter:
sudo apt-get install apache2 -y
Step 4.1: Creating a MySQL database in MariaDB
Since I needed to log previous printer movements so as to detect potential malfunctions related to the printer’s lateral and vertical motions, I also set up a MariaDB server on the Raspberry Pi 3.
#️⃣ First of all, install the MariaDB (MySQL) server and PHP-MySQL packages by entering the following command into the terminal:
sudo apt-get install mariadb-server php-mysql -y

Step 4.2: Setting and running the web application on Raspberry Pi
As discussed above, I set up a LAMP web server on my Raspberry Pi 3 to run the web application, but you can run it on any server as long as it is a PHP server.
#️⃣ First of all, install and extract the telegram_3D_printer_bot.zip folder.

Then, move the application folder (telegram_3D_printer_bot) to the Apache server (/var/www/html) by using the terminal since the Apache server is a protected location.
sudo mv /home/pi/Downloads/telegram_3D_printer_bot /var/www/html/
Step 5: Updating and setting up the HuskyLens AI Camera
HuskyLens AI camera is capable of transferring the detection results of its built-in functions via the UART (serial) or I2C protocol. I decided to utilize the I2C protocol since it is much easier to get information with the I2C protocol on the Raspberry Pi Pico.
However, before proceeding with the following steps, I needed to update the HuskyLens firmware with the latest version to get more accurate results.
#️⃣ After connecting the HuskyLens AI camera to the computer (Windows) via a micro USB cable, click the General Settings to view the version number.
Step 5.1: Detecting tags (AprilTags) w/ HuskyLens
After upgrading the firmware, I trained HuskyLens to learn three different AprilTags from the figure below for each printer axis (X-axis, Y-axis, and Z-axis) so as to track the printer’s lateral and vertical motions.

After training HuskyLens to learn tags (AprilTags) for each printer axis, I fastened each learned tag to my Creality CR-6 SE 3D printer’s X-axis, Y-axis, and Z-axis without blocking its fans, sensors, or belts.


Step 6: Setting up Raspberry Pi Pico
Since I decided to program the Raspberry Pi Pico on Thonny, I needed to configure some settings and install MicroPython for Raspberry Pi Pico on Thonny.
#️⃣ First of all, download the latest Thonny IDE version, compatible with Windows, macOS, and Linux. If you are programming the Pico on Raspberry Pi, Thonny is already installed on the Raspberry Pi OS.
#️⃣ Then, find the BOOTSEL button on your Raspberry Pi Pico.
#️⃣ Press the BOOTSEL button and hold it while connecting the other end of the micro USB cable to your computer.

This puts the Raspberry Pi Pico into the USB mass storage device mode (Bootloader Mode).
#️⃣ Thonny should automatically open the installation screen. If not, at the bottom right-hand corner of the window, click on the Python version, choose Configure interpreter…, and select MicroPython (Raspberry Pi Pico).
#️⃣ Then, on the Interpreter Tab screen, click the Install or update firmware link.
Step 6.1: Modifying CircuitPython libraries for Raspberry Pi Pico and the WIZnet Ethernet HAT
Since the WIZnet Ethernet HAT requires Adafruit CircuitPython libraries, I needed to set and configure CircuitPython on Thonny. Plausibly, Thonny has a built-in file transfer feature that makes copying files and libraries to the Raspberry Pi Pico very easy.
However, while working on this project, I encountered many bugs, errors, and incompatibilities regarding CircuitPython libraries. Therefore, I had to modify nearly all libraries and files to rectify the occurring issues and bugs.
Below, I will explain how to set CircuitPython and fix the mentioned issues and bugs step by step. But, you can download the lib.zip folder and copy the lib folder directly to your Raspberry Pi Pico without replicating the steps below.
#️⃣ First of all, download the latest versions of Blinka and PlatformDetect modules to run CircuitPython libraries on MicroPython.
#️⃣ To install the PlatformDetect module to the Raspberry Pi Pico, copy the adafruit_platformdetect folder and upload it to the Pico under the lib folder.
#️⃣ To install the Blinka module to the Raspberry Pi Pico, copy everything inside the src folder and upload those files to the Pico under the lib folder.
#️⃣ To free up some space, remove the unnecessary files under the adafruit_blinka folder before uploading modules to the Pico.
To run the WIZnet Ethernet HAT, download the adafruit_bus_device and adafruit_wiznet5k libraries. Then, upload these libraries to the Pico under the lib folder.
#️⃣ If Thonny throws attribute errors like below, change the monotonic function with the ticks_cpu function in all files under the adafruit_wiznet5k folder.
Step 6.2: Reading results generated by HuskyLens with Raspberry Pi Pico
Since HuskyLens does not provide an official library for the Raspberry Pi Pico, I modified these functions to obtain tag recognition results from HuskyLens via the I2C protocol.
After modifying the functions, I uploaded them under the huskylib.py file to the Pico.
Then, I was able to get the learned blocks with IDs generated by HuskyLens for each detected tag (AprilTag) and process them to derive tag coordinates (tag positions).
#️⃣ When saving code files to the Raspberry Pi Pico, click the Save button and choose the Raspberry Pi Pico option on Thonny.



Step 7: Programming Raspberry Pi Pico
After uploading all required modules and libraries, I saved the following code in the main.py file to run it automatically when the Raspberry Pi Pico is powered up.
⭐ Define the IoT_3D_printer_tracker class and its functions.
⭐ In the __init__ function:
⭐ Define the PHP web application path.
⭐ Setup the network configuration settings with the WIZnet Ethernet HAT’s default MAC address:
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
⭐ Define the WIZnet Ethernet HAT pin settings.
⭐ Reset the WIZnet Ethernet HAT.
⭐ Initialize the Ethernet interface without DHCP.
⭐ Set the network configuration.
⭐ Print the WIZnet Ethernet HAT information.
⭐ Define the HuskyLens AI camera settings to activate the I2C protocol.
Modes and Features
🌐🤖 If the WIZnet Ethernet HAT connects to the router via the Ethernet interface without DHCP, the device turns the RGB LED to blue.
If HuskyLens recognizes three tags (AprilTags) for each printer axis in the same frame, the device turns the RGB LED to yellow.





When the web application receives the current printer movements (tag positions), it compares them to the previous printer movements stored in the database table to detect potential malfunctions related to the printer motions.
🌐🤖 Then, the application sends the current printer movements with a schematic describing 3D printer motions to the given Telegram bot via the Telegram Bot API.
As far as my experiments go, the device works impeccably while tracking the printer movements and informing me of potential malfunctions related to the printer motions 🙂
COMMENTS