Software apps and online services
Hand tools and fabrication machines
When I start a 3D print I don’t sit around waiting for it to finish so I can start another one, I get up and do something more productive. This though, can sometimes lead to problems like me forgetting whether or not my printer is currently printing or wondering how much time it will be until I can start another print. The desire to be able to remotely monitor my print led me to OctoPrint, a program which when loaded onto a raspberry pi and connected to a 3D printer lets the printer be controlled and monitored from a website. Though this helped, I wasn't a fan of having to pull out my phone every time I was curious of my 3D printer's state. So, I made it even easier for myself to check on my printer by creating what I call 3D Printer Host.
3D Printer Host is a do it yourself electronic device created with a WiFi enabled Adafruit Feather, a Neopixel ring, and a 3D printed enclosure. The device connects to OctoPrint via its API and the wonderful OctoPrint API library for Arduino. It displays the print’s progress as well as state on the Neopixel ring. The 3D Printer Host also connects to Alexa via Thingspeak and a custom skill which allows a user to ask Alexa about many aspects of their printer and find details about any current print. Though the way in which this device functions may be confusing, it is all easily explained in the following diagram.
A demo of the 3D Printer Host can be found below. I have created and published an Alexa skill called 3D Printer host to the Alexa skill store. This skill showcases the functionality of building a 3D Printer host skill for yourself. This published skill will not alow users to monitor their own printer. To do so, this tutorial should be followed to create a Printer host of your own.
Just a note before we start: all code, models, and other files can be found at the bottom of this page.Hardware
The basic hardware of the 3D Printer Host is a 3D printed enclosure, a 16 light knockoff Neopixel ring, and an Adafruit Feather ESP8266 HUZZAH Arduino board.
To begin, gather the electronic components along with some wire. There are three options for printing the enclosure. First, you can print the 'Base', 'Outer Cover', and 'Inner Cover' in a color of your choice and print the 'Cover Slip' out of a transparent filament. The three cover parts will snap together causing the Neopixel ring to shine directly through the transparent filament. Second, the 'Base', 'Outer Cover', and 'Inner Cover' can be printed out of a color of your choice allowing the raw Neopixels to be seen. The third option is to print the 'Full Cover' along with the 'Base' in a lighter color filament and let the light shine through the single color of the cover. All files are linked to at the bottom of this page.
Start by soldering the DC power on the Neopixel to the 3v pin on the Feather. Solder ground to ground and data input to pin 12. The circuit diagram shows the correct wiring.
Place the Feather on the standoffs as pictured below.
Snap the Neopixel ring into its channel.
Finally, screw on the cover of your choice.
For this entire system to begin to work the first thing you must do is hook up you printer to OctoPrint. To do this you will need
- A Raspberry pi microcomputer
- Accessories such as power supply and case
- An SD card with latest OctoPrint image
For a full instruction guide on installing OctoPrint go to the OctoPrint website. Any further Information or clarification can be found on Youtube or other online guides.
Once OctoPrint is up and running, go to your OctoPrint server (typically https://Octopi.local), login, and head to the API Settings. Enable the API and allow CORS. Finally, take note of the API Key because this will need to be pasted into code later.
Thingspeak will be used to store data coming from OctoPrint via the Arduino into an http requestable channel. This will allow the Amazon Lambda function to request and receive data from the Thingspeak channel and relay the data through Alexa to the user.
First, create a Thingspeak profile by following the link here. Verify your account by clicking the link they sent you via email. Finally Navigate to the 'Channels' page header and click 'New Channel'.
For this project we will be creating two channels, one for the printer data and another for the print job. Once you have navigated to the channel setup page make it look like the picture below.
Once your channel matches as shown above you may click the 'save channel' button at the bottom. Next navigate back to 'My Channels' and create another channel. Fill in the information as shown again to set up the print job monitoring channel. Save the channel when completed.
Create one more channel following the outline below:
Once complete, head over to the 'API Keys' tab of each channel. Here you will find your Write API Key and Read API Key for that channel. Both of these will become important later so make sure you know how to get to them.
Most of the Printer Host's functionality is found in the esp8266 equipped Arduino board which connects together OctoPrint, the Neopixels, and Alexa (Thingspeak).
First of all, you must have an Updated version of the Arduino IDE which can be found here. Next, copy the 'Arduino Code' found at the bottom of this page into a new Arduino sketch.
The code needs a few libraries and drivers to allow it to function properly. The Adafruit Feather Drivers which allow the Feather to be recognized and programmed with a computer can be downloaded here. Next, the esp8266 library for Arduino must be downloaded, paste
into the additional boards menu under file ==> preferences. Additional boards can be separated with commas.
Go to Sketch ==> include library ==> manage libraries. Search 'octoprint' and download the OctoPrint API library. Repeat this process and search for 'adafruit Neopixel', download the Adafruit Neopixel library.
After that, go to Tools ==> Board and select the Adafruit HUZZAH ESP8266. Plug in your Printer Host Gadget and select the correct COM port, make sure that under Tools, you have self selected the following settings.
- Frequency: 80MHz
- Flash Size: 4M(3M SPIFFS)
- Upload Speed 115200
Finally, fill in your wifi credentials, Octoprint API key, OctoPrint IP address and Thingspeak write API keys for both channels under the 'User Data' section of the Arduino Code. Make sure to keep the quotation marks and remove all of the dashes.
Color Settings can be changed to customize the color scheme of your Printer Host, but have not been tested and could cause errors.
Upload the sketch by hitting the forward arrow at the top of the screen.Amazon Skill
Alexa Skills are based out of and configured by the Alexa Skills Kit on the Amazon Developer Console. Start by following this link and create a new account using the email that you have connected to your Alexa. Next, go to the developer console , and then to the 'Alexa Skills Kit' tab. From here click Create Skill. As prompted create a name for the skill ex: '3D Printer Host', and choose the skill type as custom. Finally click 'Create Skill'.
You will now be transported to the 'build' page of your skill. Navigate to the JSON editor using the menu on the left side.
Replace the code from in the JSON editor with the Interaction Model code linked to at the bottom of this page. Click the 'save model' and then 'build model' buttons at the top of the screen. If you want to change the invocation name (what is said to trigger the skill) to something besides 'printer host' simply replace it with the desired value at the top of the code.
For example "Alexa, ask <invocation name> how long my print has left?"
Under the 'Endpoint' tab select AWS Lambda ARN and locate and note Your Skill ID
To continue, a Lambda function must be constructed and configured via AWS (Amazon Web Services). This function will interprate the request that the Alexa skills kit sends it. The function will respond with an Alexa speech string that Alexa will say. To start the process follow this link and create an account. You will need to hook up credit card information, but since the free tier suits all of this projects needs nothing will be charged. Verify the account by following the directions onscreen, select the free plan, and then sign into the console. Make sure that your selected region in the top right corner is N. Virginia no matter where you live.
Search and select Lambda from the AWS services search. Click 'Create function', 'Author from scratch', and fill in the details to match the ones below. Then create the function.
Once the function has been created, find the Designer section which consists of a flowchart. Add the 'Alexa Skills Kit' trigger from the list on the left. It will ask for the skill ID, so paste the skill ID that was copied earlier here. Navigate to the function code by clicking on the Printer Host section of the flowchart and scrolling down. Paste the Index Lambda code into the index.js file. In the Index.js file locate the 'User Input' section and fill in the IDs, write, and read keys of all Thingspeak channels and the Application Id of the of the Alexa skill created earlier. After that, create a new file and name it 'AlexaSkill'. Copy the Alexa Skill Lambda Code into the new file. Once all of that is complete, the Lambda function should be saved.
Copy the ARN (Amazon Resource Name) in the top corner of this Lambda function and proceed back to the Alexa skill created earlier in the Amazon Developer Console. Go to the Endpoint page and paste the ARN that was just copied into the Default slot. Be sure to save the endpoints . The Configuration page should like like the following.
Now proceed to the Test page and under the 'Alexa Simulator' enter the utterance 'alexa, ask printer host how my printer is doing'. The response should include a statement about the state of your printer and its temperatures. If you do not get this response, go back and review the setup of Thingspeak, Lambda, and the Alexa skill. If the response did come back as hoped, congratulations your 3D Printer Host is up and running.Use
To activate your Alexa skill go to the Alexa app on your phone and navigate to Skills==> Your Skills ==> Dev Skills. Click on the Printer Host skill and enable it. You can now monitor your 3D printer via Alexa.
The 3D Printer Host Alexa Skill can answer many requests relating to both the printer and print job. All of these functions can be triggered by many ways of wording each request.
- Asking about the printer: 'How is my printer?' will respond with whether or not the 3d printer is operational and what it is currently doing. (printing, paused, or standing by)
- Asking for an overview: 'Give me an overview.' will respond with an overview of the current print job. Ex: 'Your printer has 2 hours and 45 minutes left on a 6 hour and 10 minute print of 3D_Benchy.gcode'
- Asking 3D printer host what it can do: 'What are you capable of?' will return a list of available commands.
- Asking for the amount of time remaining:'How much time is left on my 3d print?' will respond with the amount of time in hours and minutes remaining on the printer current print job.
- Asking about the total estimated time:'How much time is my print expected to take?' will return the time in hours and minutes that the printer's current print is expected to take .
- Asking about the time printed:'How long has my printer been printing?' will return the amount of time that the printer has been printing the current print.
- Asking about the percentage completed: 'What percent of my print has been completed?' will return the relative percentage of the current print that has been completed.
- Asking for the file name: 'what is the name of the file that is currently being printed?' will trigger a response which includes the name of the file currently being printed.
Users of this device are now able to control their 3D printers via Alexa and the 3D Printer Host Gadget using post commands.
The following commands are supported:
- Canceling: Asking printer host to cancel the current print.
- Restarting: Ask printer host to restart a print or file.
- Pausing: Ask printer host to pause print.
- Start: Ask printer host to start print. Starts a print of whatever file is currently selected.
Reading the Gadget
The Printer Host's ring of Neopixels can communicate many aspects of the printer and current print. These colors are set by default but can be changed in the Color Settings section of the Arduino code.
- A full circle of red light means that the printer or OctoPrint is disconnected or experiencing an error. Check that the Raspberry pi that is hosting OctoPrint is connected to power and the 3D printer.
- A full circle of blue light or no light (depending on whether or not background is turned on in the Arduino code) indicates that the printer is standing by. The 3d printer is connected and ready to print but is not currently printing.
- A partial circle of green means that a print is currently in progress. The progress of the print is displayed by the percentage of the Neopixel Ring filled. If the print is 20% completed, the ring will be roughly 20% full. If 100% of the ring is full it doesnt mean that your print is done, just that
- A partial circle of yellow indicates that the print is paused. The progress of the print is displayed as the percentage of the Neopixel Ring filled.
This entire system is made possible by the OctoPrint API library for Arduino. This library is relatively new (January 2018) and as so does not yet support all the functionality of OctoPrint's API. As the library is updated I will update this project to allow for new functionality. Other exciting features are coming soon so stay tuned for ways to update your 3D Printer Host.