定刻に写真を撮って自分のディレクトリーに保存していたが、それではVPNを自宅との間に張ってVNCでログインしないとみられない。
出来ないことはないけど、少し不便だ。

そこで、画像をメールで飛ばす方法を検討する。いろんなブログで書かれてるけど私はメールで飛ばして、GoogleフォトかEverNoteで見たいと考えていた。

まずはsSMTPをインストール

$ sudo apt-get install -y ssmtp

次にsSMTPの設定ファイルを修正

sudo vi /etc/ssmtp/ssmtp.conf
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=リレーしたいメールアドレス

# The place where the mail goes. The actual machine name is required no 
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=リレーさせるメールサーバ:587

# Where will the mail seem to come from?
#rewriteDomain=

# The full hostname
hostname=ラスベリーパイのホスト名

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
#FromLineOverride=YES

AuthUser=メールID
AuthPass=メール送信の為のパスワード

次にMuttというMUA(メールユーザーエージェント)をインストール

$ sudo apt-get install -y mutt

次に写真を添付してMutt経由でEverNoteに送るスクリプトは下記、これに実行権限を与えてCronで定時に実行させればOKです。

#!/bin/bash
DATE=$(date +"%Y-%m-%d_%H%M")
raspistill -o /home/pi/camera/$DATE.jpg -w 640 -h 480
mutt -s "Pic$DATE @EverNoteのノート名" エバーノートのアドレス -a "/home/pi/camera/$DATE.jpg"

これで以前のCronが動いてEverNoteに画像が入ってくる。

Posted in

コメントを残す