Skip to content

RPI Camera Setup

Chenming Zhang edited this page Aug 9, 2022 · 2 revisions

rpi camera set up for weather station

To set up a weather station camera, you should prepare:

  1. Pi Zero W camera kit (camera module + Pi Zero W + ribbon cable + SD-card)
  2. One 3D-printed camera housing;
  3. One cable (3m-5m);
  4. Gadgets for soldering (pin headers + wires with header + heat shrink)

The main components of the camera are shown as follows: main components of the camera

Soldering

Solder pin headers to Pi Zero W

sensors' wiring sketch

Solder wires to cable

sensors' connecntion to datalogger v3

Assemble all components

sensors' connecntion to datalogger v3

Code

Crontab

	@reboot home/pi/pyduino/bash/camera_weather_station.sh

camera_weather_station.sh

	#!/bin/bash
	sleep 120  #need enough time for pi to reboot and load modules required by camera, and connect to wifi
	cd /home/pi/photo_weather_station/
	FILENAME=$(date +"%Y-%m-%d_%H%M")_field_camera.jpg
	raspistill -vf --thumb none --quality 13 -o $FILENAME
	sleep 5
	scp /home/pi/photo_weather_station/$DATE <user>@mango.eait.uq.edu.au:/storage/www/dropbox.eait.uq.edu.au/<user>/Bribie/
	sleep 5
	scp /home/pi/photo_weather_station/$DATE <user>@mango.eait.uq.edu.au:/home/users/<user>/Bribie/photo/
	sleep 5

raspistill flags

RPI ZERO CAMERA VIA PIN 8 - TEST OK

	try:
		ard.write("power_switch,8,power_switch_status,1,debug,1")
		print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
		print("Switch on. Taking photo ...... ")

		time.sleep(180) #must be long enough to update images via 3G or 4G connection.

		ard.write("power_switch,8,power_switch_status,0,debug,1")
		print("Switch Off. See you next loop ......")

	except Exception as error:
		if SCREEN_DISPLAY:print('Taking photo failed')
		print(type(error))
		print(error)

Converting existing large size photos to a reduced size

Below is the commands to convert the existing large jpg files in a folder to reduced sizes.

convert_to_small photos.sh

    mkdir converted
    for file in *.jpg; do 
       echo $file
       convert -resize 30% $file ${file}_resized.jpg;
       mv ${file}_resized.jpg converted/; 
    done
Clone this wiki locally