GithubHelp home page GithubHelp logo

savjee / 3dmon Goto Github PK

View Code? Open in Web Editor NEW
6.0 4.0 2.0 367 KB

Simple 3D print progress monitor (for Home Assistant)

License: MIT License

Python 74.42% Shell 25.58%
3d-printing home-assistant tinycorelinux serialport

3dmon's Introduction

3dmon

A simple Python script that monitors the print status of my Prusa i3 MK3 printer and reports it to Home Assistant.

Runs on a Raspberry Pi Zero W, powered by TinyCore Linux. It's lightweight, boots in seconds and is sd-card-corruption-proof™️.

What it looks like in Home Assistant (paired up with an IP camera):

Notification when the printer is done:

Motivation. Why?

I wanted a simple way to monitor my 3D printer through Home Assistant. That way I could set up automations like: notify me when the printer is almost done.

Octoprint would be ideal but it doesn't run well on a Pi Zero. So instead I connected the printer's USB interface to the Pi and monitor its serial output with Python. Progress updates are captured and sent to Home Assistant through the REST API.

Why TinyCore? It boots up in seconds and runs entirely in RAM. I can power cycle my Pi all day and won't have sd card corruption. Yay!

Setup

  1. Download the latest version of Tiny Core Linux ( available at: http://tinycorelinux.net/downloads.html )
  2. Copy the operating system to the SD card ( instructions at: https://www.raspberrypi.org/documentation/installation/installing-images/)
  3. Insert your SD card and boot your device - you will need a keyboard and screen for this step
  4. Complete basic install for Tiny Core Linux - available online or TinyCoreLinux-Setup.md
  5. Connect to a network
  6. To set the correct time, you need to modify the NTP server, using the following command:
sudo vi /etc/sysconfig/ntpserver
  1. As Tiny Core Linux runs in RAM, all changes are lost unless the folders/files are added to a list, the following command will ensure the NTP server is kept:
echo /etc/sysconfig/ntpserver >> /opt/.filetool.lst
filetool.sh -b
  1. Then reboot your device (sudo reboot) and when your device has rebooted, entering the following command should show you the correct time:
date

If your time is not updating, run the following command to force an update:

sudo getTime.sh
  1. Configure the current repository to install packages:
sudo vi /opt/tcemirror

Change the only line in this file to: http://distro.ibiblio.org/tinycorelinux

  1. Next you need to install python and the required modules:
tce-load -wi python3.8
tce-load -wi py3.8serial
tce-load -wi usb-serial-5.10.16-piCore
tce-load -wi firmware-rpi-wifi
tce-load -wi wifi

Hint - you can use the following command to search for packages:

tce-ab
  1. Install additional Python modules
pip3.8 install requests

  1. Save your changes
echo /usr/local/lib/python3.8/site-packages/serial >> /opt/.filetool.lst
filetool.sh -b
  1. Optional - Reboot device and open python to check all the modules are available:
python3

import serial
import requests
import json

Setup crontab on Tinycore

Add this to /opt/bootlocal.sh to start cron:

crond -L /dev/null 2>&1

Make sure that crontabs are persisted. Run:

echo var/spool/cron >> /opt/.filetool.lst

Backup & reboot:

filetool.sh -b
sudo reboot

License & contributions

Licensed under MIT

I'm not really good at Python (this is probably my first real project). Feel free to fix/improve my code ;)

One thing to keep in mind: this project is all about monitoring 3D printers. I won't accept pull requests for control logic. Just trying to keeps things simple & reliable.

3dmon's People

Contributors

krowvin avatar savjee avatar tomuky2k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

krowvin tomcollis

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.