This project was conceived because I have a resin 3D printer that I want to run outside. Because the printer is outside, I need to leave it blocked from sunlight. Therefore, I cannot check on the print by lifting the lid (at least not during the daytime).
The project has now been through 2 interations; once with my Creality LD-002H and again with my Elegoo Mars 5 Ultra.
✅ Turns on a camera on a set interval
✅ Turns on a camera with ad hoc command and/or separate program
✅ Turn on light(s) before recording with the camera (and off after recording)
✅ Turns on light with ad hoc command and/or separate program
✅ Store videos on SSD to be accessed via SSH
✅ Record temperature in a log to be accessed via SSH
✅ Fully 3D printed shell
✅ A script to run on Windows machine for downloading files from the RPi
git clone https://github.com/DavidMiles1925/printer_camera.gitNote: These MUST be installed prior to using this software.
This is the library used to interact with the RPi Camera Module
sudo apt install -y python3-picamera2
This library gets used to convert .h264 files to .mp4.
sudo apt install -y ffmpeg
This will be installed on your WINDOWS MACHINE to bring files over from the pi.
Ensure that you have set up an SSH Key. Documentation for SSH Key Setup Here
pip install paramiko scp
All programs should be run from the command line.
Options can be configured in config.py.
This runs the main app which takes a video every
{CAMERA_RECORDING_TIME}seconds.Before running make sure these options are configured!
SAVE_DIRECTORY_PATHandLOG_DIRECTORY_PATHhave the correct Pi Name in their directory path.
FILENAME_PREFIXhas a descriptor that acurately describes the material being recorded.
Option Possible Values Purpose VIDEO_RECORDING_ONTrue/False Turn video recording feature on or off CAMERA_RECORDING_TIMEAny Number Seconds that the camera will record if activated TIME_BETWEEN_LOOP_ITERATIONSAny Number Seconds between checks for feature activation (not including the length of the video recording) FILENAME_PREFIXAny String - Do NOT include spaces in the name. This is will be filename, followed by a number DIRECTORY_NAME_PREFIXAny String This is the directory name prefix where videos will be stored SAVE_DIRECTORY_PATH"/home/[PI NAME]/printer_camera/recordings/" The directory where recordings will be stored LIGHTING_ONTrue/False This determines whether the light will turn on WHILE THE CAMERA IS RUNNING LIGHT_ALWAYS_ONTrue/ False This will determine if the light is ALWAYS ON while the program is running EVEN IF THE CAMERA IS NOT LOG_DIRECTORY_PATH"/home/[PI NAME]/printer_camera/logs" This is the directory name prefix where logs will be stored
This program, when run by iteself, will print the current temperature to the console intermitently.
This module is used in main.py to log the temperature each time the camera records a video.
Option Possible Values Purpose TEMPERATURE_LOGGING_ONTrue/False This determines whether the temperature will be logged when main.pyis run.TEMP_LOG_TIME_Any Number The amount of time in seconds between logging when temp.pyis run
This program is a stand-alone app used for testing the camera or grabbing an ad hoc picture/video.
It can also be used to toggle lights in the chamber on and off.
Photos are saved in .jpg format.
Videos are stored in .mp4 format (after being converted from .h264)
Option Possible Values Purpose SINGLE_RECORDING_TIMEAny Number The length of the video to be recorded in seconds LIGHT_PIN_1BCM number from GPIO This pin will be used for an LED to light the chamber LIGHT_PIN_2BCM number from GPIO This pin will be used for an LED to light the chamber DISABLE_CAMERATrue/False Turn to Trueto be able to disconnect RPi Camera Module without errors
This program is only to be run on a windows machine.
You MUST have set up an SSK Key. Documentation for SSH Key Setup Here
Option Possible Values Purpose REMOTE_HOSTRPi IP Address The IP address of the RPi for ssh connection PI_USERNAMERPi Username The username of the RPi WIN_USERNAMEWindows Username The username of the Windows account pulling files REMOTE_PATH_PHOTOFile Path Path to grab photo files from REMOTE_PATH_VIDEOFile Path Path to grab video files from LOCAL_PATHFile path Path where files will be downloaded Manual Copy/Paste commands to pull videos.
scp -r PI_NAME@192.168.1.000:/home/PI_NAME/printer_camera/recordings/ /c/users/USER_NAME/downloads scp -r PI_NAME@192.168.1.000:/home/PI_NAME/printer_camera/logs/ /c/users/USER_NAME/downloads
The majority of the original code as repurposed from the motion_camera repo. Look there for more detailed documetnation.
| Material | Quantity | Link |
|---|---|---|
| Raspberri Pi Zero 2 W (with header pins) | 1 | |
| SD Card Formatted with Raspberry Pi OS | 1 | |
| Raspberri Pi Camera Module | 1 | |
| Breadboard | 1 | |
| 3D Printed Shell | 2 | Printed Shell |
| 100Ω Resistor (for lights) | 2 | |
| 4.7KΩ Resistor (for temperature sensor) | 1 | |
| DuPont Cables M-F (short) | 5 |
| Pin Name | Pin Number (BCM) | Purpose |
|---|---|---|
| LIGHT_1_PIN | 17 | Lighting: Brightening the printing chamber |
| LIGHT_2_PIN | 26 | Lighting: Brightening the printing chamber |
| N/A | GND (any) | Lighting: Ground |
| 1-Wire Connection | 4 | Temperature Sensor: THIS WILL REQUIRE ADDITIONAL STEPS |
| N/A | GND (any) | Temperature Sensor: Ground |
| N/A | 5V | Temperature Sensor: Power |
PiCamera must be properly connected or program will not run.
You will need to ensure picamera2 is installed on your machine. (see Dependencies above)
I have documented the setup of the camera extensively in the Motion Camera Repo. Refer to this documentation for more information.
Ensure the camera is installed (in the RPI Zero 2 W) with the gold traces facing the board ("face-down").
The side of the camera with the cable running in is the bottom of the camera.
The RPi must be booted with the camera attached. If it is attached afterwards, the program will throw an error.
One-Wire Interface needs to be enabled to read the data pin. Do this in the RPi config.
Documentation can be found here.
Tutorial can be found here.
- Add to /boot/config.txt
Run the raspberry pi config tool
sudo raspi-configSelect Interface Options
Select 1-Wire and Select "Yes"
- Reboot
sudo reboot- We need to add a bootable kernal to Linux:
sudo modprobe w1-gpio
sudo modprobe w1-therm- Change directories and check for attached device:
cd /sys/bus/w1/devices
ls- Enter device directory:
cd 28-XXXXXXXXXXXX- Check raw temperature readout:
cat w1_slaveAbout
The library temp.py was created using code from the tutorial referenced above.
It was adjusted so that it can be used as a library as well as run as a main function.
The above steps will need to be completed before the code can be run.
Integration
I set up the log function to take prefix= argument in order to accomodate the temp log.
The Version 1 files have been moved to the /Depricated folder and will not be used anymore.
Files are located in the print_files folder above. The Pi piece and the breadboard piece were glued back-to-back and installed in the fan port on the cover for the Mars 5 Ultra.
Version 1
Version 2
My article on printing outdoors
Article - Outdoor Resin Printinig
My YouTube video showing outdoor printing
Video - Outdoor Resin Printing
Resin Settings from Maker Trainer (for LD-002H)
LD-002H Resin Settings Spreadsheet
Resin Settings from Elegoo (for Mars 5 Ultra)
Calibration Model and Tutorial from Ameralabs
Calibration Tutorial
means that picamera2 checked for attached cameras but found an empty list.
- Check physical connection
-
Is the camera ribbon cable firmly seated in the CSI port?
-
Make sure it's facing the correct direction (metal pins face the camera connector contacts).
-
Try reseating the cable on both ends (Pi and camera).
- Make sure the camera is enabled
Even if you already ran this, double-check:
sudo raspi-config- Go to: Interface Options → Camera → Enable
The start_recording() method in picamera2 requires two arguments:
picam2.start_recording(output, encoder)
You're currently just passing the filename (filename), but it's expecting a file encoder and a file-like output.
After reboot:
libcamera-hello
If it still fails:
Double-check that your cable is for the Pi Zero (not the wide one for full-size Pis).
Make sure the camera module itself is firmly connected and supported by the OS.
Run:
libcamera-still --list-cameras









