Skip to content

Digital camera that takes pictures and stores them, mounted on a raspberry pi.

Notifications You must be signed in to change notification settings

the-other-mariana/diy-camera

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DIY Camera

Requirements

Name Description Image Link
Raspberry Pi 3B+ (tested) Works with 2/3 or 4 - -
Micro SD Card SanDisk Ultra 16GB 80MB/s img Link
Camera Sensor Arducam Camera Sensor IMX477 with C-CS Adapter img Link
Camera Lens Arducam Zoom C-Mount Lens 8-50mm for Camera IMX477 img Link
Ribbon Cable FPC Ribbon Cable 22 to 15 pins, 15cm or shorter img Link
3.5 inch HDMI Display Osoyoo HDMI display 3.5 inches img Link

3D Prints

  • Case

The case for this camera is not mine, I printed Pikon Camera 3D model from here.

img

  • For 3D printing, I'm using:

    • Ender 3 Model V1
  • The steps for 3D printing are

  1. Download the Creality Print Software app image from here. Since it's a portable software, you don't need to install what you download.

  2. Give execution permissions to the .AppImage file you downloaded:

chmod +x ./Creality_Print-v3.11.1-Ubutu-x86_64-Release.AppImage
  1. Execute the software:
./Creality_Print-v3.11.1-Ubutu-x86_64-Release.AppImage
  1. Click on Import Model button in the right side menu:

img

  1. Select one of the three .STL files you downloaded for the case section.

  2. Rotate it with the blue button so that the supports are easily removable.

img

  1. Once you're finished, click on Start Slice.

img

  1. Click on Export and name the file as you wish. This will result in a .gcode file that your Ender 3 will be able to read.

img

  1. Copy the .gcode files to a Micro SD so that you can print it from there.

Set Up

You must download the OS version: 2022-01-28-raspios-bullseye-arm64-full from here.

  1. Plug your Micro SD Card into your pc and check its name:
sudo fdisk -l
  1. Unmount the card. Since my card has another OS burned already, it has two partitions (shown in above command), so I unmounted both:
sudo umount /dev/sdb1
sudo umount /dev/sdb2
  1. Burn the image onto the Micro SD Card
sudo dd bs=4M if=~/Downloads/2022-01-28-raspios-bullseye-arm64-full.img of=/dev/sdb status=progress
sync
sudo eject /dev/sdb

OS Configs

  1. Install libcamera by either of the two ways:

a) From source

git clone https://github.com/raspberrypi/libcamera.git
cd libcamera/
mkdir build
cd build
cmake ..
cd ..
meson setup build
sudo apt install meson
meson setup build
ninja -C build install
libcamera

b) With the package manager

sudo apt install libcamera-apps
sudo apt-install -y python3-pyqt5 python3-opengl python3-picamera2
  1. Open firmware configs:
sudo raspi-config
  1. Navigate to Advance Options and Enable Glamor Graphic Acceleration. Optionally, also in Advanced Options you can Enable Legacy Camera.

  2. Go back to Advanced Options and navigate to GL Driver, select GL (Full KMS)

  3. Reboot

sudo reboot
  1. Modify the config file with sudo vim ~/boot/config.txt:
  • ~/boot/config.txt: Make sure this is under the [all] section:
...
[all]
gpu_mem=128
camera_auto_detect=0
dtoverlay=imx477

Also, uncomment the line with dtoverlay=vc4-kms-v3d.

  1. Show a preview of the camera image:
libcamera-still -t 0

Important: if the preview shows an all-black image, try adjusting all the lens' lighting, since often times the configs are all messed up. Twist the lens.

Display

The display used here was at first the classic 3.5 inch GPIO-based display, but when I connected the camera module, it wouldn't work at all. I figured that the camera preview that we use inside the Qt app sends the output directly to HDMI. Using a GPIO-connected display would mean to copy somehow the HDMI output to anything similar, which means a delay, which means too much work. The easy way out is to buy a display that works with HDMI. Therefore, I suggest strongly to use a 3.5 inch that connects to the Pi with HDMI.

The display I linked here worked with the camera module but you definitely need to tweak some stuff.

  1. Connect your raspberry pi to the display. Now we need to install the driver for it.

  2. Turn on the Pi and open a terminal:

git clone https://github.com/osoyoo/HDMI-show.git
  1. Give the folder the rights.
sudo chmod -R 777 HDMI-show
  1. Enter the directory:
cd HDMI-show/
  1. Run the script:
sudo ./hdmi35-480x320-show

This will automatically reboot your pi. In my case, the reboot didn't end up working, and left my pi with a blank screen:

img

If, for any reason, your screen goes blank and never shows the desktop properly, you need to do this:

a. Plug your SD card into a PC

b. Go to boot folder

c. Open in a text editor the file /boot/config.txt. Through the installation we just did, Osoyoo adds these lines to your original config.txt file:

dtoverlay=vc4-fkms-v3d
hdmi_group=2
hdmi_mode=87
hdmi_drive=1
hdmi_pixel_freq_limit=20000000
hdmi_cvt 480 320 60 6 0 0 0
dtoverlay=ads7846,cs=1,penirq=25,penirq_pull=2,speed=50000,keep_vref_on=0,swapxy=0,pmax=255,xohms=150,xmin=200,xmax=3900,ymin=200,ymax=3900

In my raspberry pi 3b+ model, I needed to comment the line:

#hdmi_pixel_freq_limit=20000000

For it to work again. That's it. You can visit the driver's repo here to know what else goes under the hood here.

Boot Configs

  1. In order to make the program start as the pi is turned on, you need to open the file /etc/xdg/lxsession/LXDE-pi/autostart and write the lines:
#@lxpanel --profile LXDE-pi
#@pcmanfm --desktop --profile LXDE-pi
@xscreensaver -no-splash
@sudo python3 /home/pi/Documents/github/diy-camera/main.py

where the last command has the path from our main.py file.

  1. Reboot the pi and you should be able to see the program running.

About

Digital camera that takes pictures and stores them, mounted on a raspberry pi.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages