element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Pi IoT
  • Challenges & Projects
  • Design Challenges
  • Pi IoT
  • More
  • Cancel
Pi IoT
Blog [Pi IoT] Plant Health Camera #7 - Synchronizing the cameras
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: gpolder
  • Date Created: 8 Aug 2016 9:39 AM Date Created
  • Views 1495 views
  • Likes 5 likes
  • Comments 6 comments
  • pi 3
  • pi-iot
  • rpi.gpio
  • trigger
  • pi_camera
  • pi iot design challenge
  • plant health camera
Related
Recommended

[Pi IoT] Plant Health Camera #7 - Synchronizing the cameras

gpolder
gpolder
8 Aug 2016

This week I was traveling again, so unfortunately I didn't have much time to work on the project.

Therefore I will share my thoughts on how to synchronize the two cameras.

 

Previous posts:

[Pi IoT] Plant Health Camera #6 - Putting the slave Pi to work

[Pi IoT] Plant Health Camera #5 - OpenCV

[Pi IoT] Plant Health Camera #4 - Putting the parts together

[Pi IoT] Plant Health Camera #3 - First steps

[Pi IoT] Plant Health Camera #2 - Unboxing

[Pi IoT] Plant Health Camera #1 - Application

 

Intro

In the previous post I explained how the two cameras are combined, using the master and slave Pi. Here I will show how the two Pi's are connected hardware wise, and how the two images are taken simultaneously from the two systems.

Hardware setup

The power for the Pi B+ comes from the Pi 3's header block, as shown in the image below.

I wrote some python code which will run on the slave system. It will wait for a trigger pulse on GPIO 23 and then take an image and save it on the share as described in the previous post. The master system will output the trigger on GPIO 18.

image

 

Software

Below is the python code which runs on the slave system, it is based on an example I found on the internet (camera - Problems triggering via GPIO - Raspberry Pi Stack Exchange).

If not done already rip.gpio needs to be installed:

sudo apt-get install python-dev python-rpi.gpio

 

slave_camera.py:

 

#!/usr/bin/python


import RPi.GPIO as GPIO
import socket
import time
import picamera

# PiCamera Setup

camera = picamera.PiCamera()
camera.ISO = 100

image_num = 1
ready = 1

# GPIO Setup

GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)


# Begin Loop
try:
  while True:

  if GPIO.input(23):

  camera.capture('/home/pi/planthealthcam/slave_image.jpg')
  print('input from master on gpio 23, Picture taken!')
  ready = 1
  image_num += 1
  time.sleep(3)

except KeyboardInterrupt: # trap a CTRL+C keyboard interrupt  
  GPIO.cleanup() # resets all GPIO ports used by this program 

 

In order to start this script on every boot, I added it to /etc/rc.local:

 

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

python /home/pi/planthealthcam/slave_camera.py &

exit 0

 

In a following post I will describe the python code on the master system.

stay tuned.

  • Sign in to reply

Top Comments

  • gpolder
    gpolder over 9 years ago in reply to element14Dave +2
    Hi element14Dave , thanks, any news on the missing Sense HAT, WiPi Dongle and the PiFace digital? In particular the Sense HAT, would be great to add Temperature, Barometric pressure and Humidity to the…
  • gpolder
    gpolder over 9 years ago in reply to DAB +1
    DAB , true it's not super time sensitive, but as the plants can move, for instance due to the wind, I prefer to take the NIR and RED image at the same time. Gerrit.
  • gpolder
    gpolder over 4 years ago in reply to tonyteyer +1
    Hi Tony, thanks for your interest in this project. 2- How do I put the code on the Pi slave? vi or vim? you indeed can logon with a terminal (putty on windows, Terminal on mac) and use vi or any editor…
Parents
  • DAB
    DAB over 9 years ago

    Nice simple solution.

     

    You could also time synchronize the two RPi's to take the photos.

     

    The NDVI data you are looking at is not super time sensitive as it takes a while for a plant to exhibit outward signs of stress.

     

    DAB

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • gpolder
    gpolder over 9 years ago in reply to DAB

    DAB,

     

    true it's not super time sensitive, but as the plants can move, for instance due to the wind, I prefer to take the NIR and RED image at the same time.

     

    Gerrit.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • gpolder
    gpolder over 9 years ago in reply to DAB

    DAB,

     

    true it's not super time sensitive, but as the plants can move, for instance due to the wind, I prefer to take the NIR and RED image at the same time.

     

    Gerrit.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube