1

I have 30 raspberry pi camera modules working in the same network. I am using pssh -h host.txt raspistill command to take pictures form all these modules simultaneously where host.txt contains IP addresses of all PIs. The problem is every time these cameras take pictures in random sequence and I'm using time stamp to name the picture files. Here I have 3 questions:

  1. how to save pictures' name by the camera ID so I could know that which picture belong to which camera device?
  2. how to set camera ID?
  3. copy all the pictures from remote raspberry PIs to local machine but with the same name (camera ID).

Any help will be much appreciated. Thanks in advance.

  • You may want to have a look at compoundpi as well ... does more or less what you describe, and takes care of file naming for you. If you want absolute control over filename (and everything else), have a look at the batch clients chapter. – Dave Jones Sep 20 '16 at 21:51
2

there is alot of ways actually , but nativly , you must know some bash basics.

in terminal :

cam_id="camera_1"

raspistill -o $HOME\$cam_id

so i advise you read more about bash-scripting and shell commands more.

as for the file copying , its depends on the protocol you are using is it web , ftp or network shared folder smb or samba.

in that case i advise you to use wget.

useful link :

shell & bash basics : How To Read and Set Environmental and Shell Variables on a Linux VPS

wget : retrieving files using HTTP, HTTPS and FTP

2

I don't think I can quite answer all your questions, but pssh (known as parallel-ssh on Debian-based systems) can pass the host name to the remote hosts in the PSSH_HOST variable. In order to do this, though, in the /etc/ssh/sshd_config of all of the remote machines you need to ensure that there is the line:

AcceptEnv LANG LC_* PSSH_NODENUM PSSH_HOST

(the LANG and LC_* entries were likely there before, and PSSH_NODENUM additionally allows you to refer to machines by sequence.)

After restarting the ssh service on each remote machine

sudo service sshd restart

you should then be able to issue a command like:

parallel-ssh -h host.txt 'raspistill -dt -o "${PSSH_HOST}-%d.jpg"'

and you get individual files with the hostname and timestamp on each machine. The file host.txt contains a list of the hosts you want to operate on, one to a line, in the form [user@]host[:port]

To get the remote files to the local machine, I'd use something like rsync to keep the local image folders up to date with the remote ones. You might even be able to call it from pssh

  • I don't have a working raspistill setup, so I'm not sure if that command line will work exactly. But the ${PSSH_HOST} bit I have tested, and that's what you need to tell the files apart – scruss Dec 14 '16 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.