GithubHelp home page GithubHelp logo

nvtkaszpir / prusa-esp32-node-red-time-lapse Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 2.44 MB

Taking time lapse videos from Prusa prints using esp32 camera and Node-RED

License: Apache License 2.0

Shell 7.20% Dockerfile 18.71% Python 34.26% HTML 12.39% G-code 8.53% Makefile 14.31% HCL 4.60%
docker docker-compose esp32 esp32-cam esp32-camera esphome ffmpeg node-red ov2640 prusa

prusa-esp32-node-red-time-lapse's Introduction

prusa-esp32-node-red-time-lapse

Taking time lapse videos from Prusa prints using esp32 camera and Node-RED.

Versions

Current v2 version is on master branch and uses custom gcode to trigger images.

For previous version see branch v1, but notice this is not maintained anymore.

Tested with Prusa Mini+ v4.4.1 and v5.1.2, so it should probably work with any newer Prusa printer API (or may need slight adjustment).

About

Using custom gcode printer triggers button with every new layer. Pressing the button sends message from esp32 to MQTT topic. When message from specific topic is received then it triggers flow in Node-RED. In the flow there is a check if the printer is printing, and thus it takes picture via web from esp32 camera, and stores it in local directory. If the print of the printer stops then it triggers rendering images into a mp4 video.

See docs/README.md for detailed instructions

2023-11-11_2_720p.mp4

printer status flow

web_ui

What works

  • trigger button via custom gcode

  • trigger flow when button is pressed

  • trigger video render if printer was printing and stopped printing

  • Node-RED + mqtt in containers (docker), can also run directly on host

  • logic flow - capturing images to directory if printer is printing

  • rendering images into a movie using ffmpeg within node-red container

  • now whole process is within single flow, and you can run multiple flows if you have different printers/cameras

  • you can define default values per flow such as destination directory, printer address, camera address

  • if day change is detected (via UTC) then print counter is reset to zero after current print is finished

  • fetch image from camera only once

  • ffmpeg in container + shell script to merge images into a mp4 file

  • basic web ui dashboard, it's crap but provides core info :)

  • default docker-compose spawns fake prusa api and fake esp32 camera, this is great to test flows and adjust them without need of using real hardware

  • fixed issues with out of order frames

Known limitations

  • due to using custom gcode it takes a bit time to tune button triggering, but you can manually trigger flow in Node-RED.
  • if you have print in the bed corner close to where power connector is attached to bed, then it can trigger button presses and thus extra image captures, that's why it is better to adjust print area to avoid movements in that space, if possible.
  • if you deploy node-red flow then counter for daily print is reset, which results in files to be saved in already existing directories and video may not be rendered because it already exists, or it will be merged from old and new images (depends on the timelapse script options)
  • you MUST configure node general config under on Startup and set vars there

config

  • screenshot taking/stopping and video render have some delay, this is intentional, first, it allows to add 'final' frame when printer head is away from print, second, it allows to not trigger actions on failed messages
  • before rendering videos there is not much info on the dashboard
  • video progress is showing yellow dot on the dashboard only if ffmpeg runs for over 10s
  • can not get rendered video from the dashboard - out of scope - use other flows for that, there is one that allows to browse files via web ui, or just mount data dir as samba share etc, see below
  • if camera fetch error occurs there is no retry to fetch it, this is rather not an issue because ffmpeg will automatically detect incorrect images and will not add them to video
  • rendered images and videos are not cleaned up, you must manage data dir on your own

NOT-TODO

Things that will not going to happen:

  • adding code to list files for render videos/images in web ui; there are other better solutions there such as Csongor Varga code

TODO

  • save daily print counter state to avoid writing to existing directories

  • detect camera errors + add retry

  • detect bad camera captures + add retry

  • how to deal with the corner case when printing very close to the button - use gcode to trigger on-board pins, is is supported by Prusa Mini?

Future plans

Currently project fulfills the needs I wanted.

prusa-esp32-node-red-time-lapse's People

Contributors

nvtkaszpir avatar

Stargazers

 avatar

Watchers

 avatar  avatar

prusa-esp32-node-red-time-lapse's Issues

Lift/drop print head on photo take

Happened to have some top layer scratches, it was 160x160x2 mm flat PETG slab and it probably warped probably due to cooldown and the large flat size on the bed.

Things to consider:

  • per-layer: on layer change lift print head a bit and move to the button trigger, on way back drop print head in target location
  • on final layer: as above, but lift higher?

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.