pinewell's farmer blog 農業と電子工作、ソフトウェア、バイク、車

2013年4月3日

motionの設定、motion.conf。

Filed under: 育苗管理システム — pinewell @ 6:59 PM

おもむろにUSBカメラを挿す。
Apr 3 18:12:23 debian kernel: [ 5233.184994] usb 2-1: new high speed USB device using orion-ehci and address 2
Apr 3 18:12:24 debian kernel: [ 5233.775622] usb 2-1: New USB device found, idVendor=2084, idProduct=0009
Apr 3 18:12:24 debian kernel: [ 5233.855986] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Apr 3 18:12:24 debian kernel: [ 5233.941562] usb 2-1: Product: BUFFALO BSW20K06H USB PC Camera
Apr 3 18:12:24 debian kernel: [ 5234.011446] usb 2-1: Manufacturer: Syntek
Apr 3 18:12:24 debian kernel: [ 5234.059473] usb 2-1: SerialNumber: STK00001
Apr 3 18:12:24 debian kernel: [ 5234.113725] usb 2-1: configuration #1 chosen from 1 choice
Apr 3 18:12:25 debian kernel: [ 5234.580160] Linux video capture interface: v2.00
Apr 3 18:12:25 debian kernel: [ 5234.721386] uvcvideo: Found UVC 1.00 device BUFFALO BSW20K06H USB PC Camera (2084:0009)
Apr 3 18:12:25 debian kernel: [ 5234.857449] input: BUFFALO BSW20K06H USB PC Camer as /devices/platform/orion-ehci.1/usb2/2-1/2-1:1.0/input/input0
Apr 3 18:12:25 debian kernel: [ 5234.983617] usbcore: registered new interface driver uvcvideo
Apr 3 18:12:25 debian kernel: [ 5235.057385] USB Video Class driver (v0.1.0)
これがでてくれば認識OK。
/dev/video0ができているはず。

motionの動作確認。
最低限、/etc/motion/motion.confの

webcam_localhost on をコメントアウトし、
webcam_localhost offにする。

#motion
これでデーモンモードじゃない状態で起動。いろいろ出てくる。
適当なブラウザで http://%LS-GLのIP%:8081/ で画像が見ているはず。

動くことが確認できたら、
#vi /etc/motion/motion.conf

daemon off を daemon on
width 320 -> 640
height 240 -> 480
framerate 2 -> 100
auto_brightness off -> on
brightness 0 -> 127
ffmpeg_cap_new on -> off
locate off -> on

target_dir /tmp/motion -> target_dir /var/www/motion
snapshot_filename %v-%Y%m%d%H%M%S-snapshot -> snapshot_filename snapshot/%Y%m%d%H%M%S-%v-%q-snapshot
jpeg_filename $v-%Y%m%d%H%M%S-%q -> jpeg_filename %Y/%m/%d/%H%M%S-%v-%q
webcam_quality 50 -> 100
control_port 8080 -> 8070
control_localhost on -> off
; on_picture_save value -> on_picture_save /var/www/motion/bin/indexcopy.php %f

ディレクトリはあらかじめ作っておこう。
#mkdir /var/www/motion
#chmod 777 /var/www/motion

で、動くことが確認できたら
#vi /etc/default/motion
start_motion_daemon=no -> yes

rc.local、inittab、lighttpd、php5、mysql、smartmontools、forwardの設定

Filed under: 育苗管理システム — pinewell @ 5:57 PM

準備できた音、シリアルポートのttyS0のパーミッション・設定
液晶表示の初期化
#vi /etc/rc.local

chmod 666 /dev/ttyS0 >> /dev/null
/bin/stty -F /dev/ttyS0 9600 >> /dev/null
/bin/echo ‘s’ > /dev/ttyS0
/usr/sbin/microapl -a bz_on finepix

exit 0

/dev/ttyS0 を 通常のシリアルポートとして使用(シリアルコンソールは使えなくなる)
#vi /etc/inittab
T0:23:respawn:/sbin/getty -L ttyS0 115200 linux
をコメントアウト
#T0:23:respawn:/sbin/getty -L ttyS0 115200 linux

lighttpdの設定
DirectoryListingを無効に。
#vi /etc/lighttpd/lighttpd.conf

#server.dir-listing = “enable”
server.dir-listing = “disable”

url.access-deny に
,”.ini” を追加

php5を使用可能に。
#lighty-enable-mod fastcgi
#lighty-enable-mod fastcgi-php

php5の設定(php.ini)
#vi /etc/php5/cgi/php.ini

mysqlの設定 (my.cnf)
#vi /etc/mysql/my.cnf

[client]
default-character-set=utf8
[mysqld]
default-character-set=utf8
[mysqldump]
default-character-set=utf8
[mysql]
default-character-set=utf8

smartmontools
#vi /etc/default/smartmontools

enable_smart=”/dev/sda”
start_smartd=yes

#vi /etc/smartd.conf
すべてのDEVICESCANをコメントアウト

#DEVICESCAN ~~~
/dev/sda -H -m root@localhost

forwardの設定
%ユーザー名%宛(root->%ユーザー名%はalias)のすべてのメールを%メールユーザー名%@%メールドメイン名%に転送
$cd
$vi .forward

%メールユーザー名%@%メールドメイン名%

postfixの設定

Filed under: 育苗管理システム — pinewell @ 5:52 PM

これはワシが借りているVPSサーバーへ relayする設定。
サブミッションポートでlistenしてSASL認証を用いてる。

postfixの設定
vi /etc/postfix/main.cf

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no
append_dot_mydomain = no
readme_directory = no
myhostname = debian.%ドメイン名%
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = camera.%メールドメイン名%, debian.%ドメイン名%, localhost.%ドメイン名%, localhost
relayhost = [%メールドメイン名%]:587
smtp_sasl_auth_enable = yes
smtp_sasl_security_options =
smtp_sasl_password_maps = hash:/etc/postfix/saslpass
smtp_use_tls = no
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command = procmail -a “$EXTENSION”
recipient_delimiter = +
inet_interfaces = all
home_mailbox = Maildir/
message_size_limit = 0
mailbox_size_limit = 0

#cd /etc/postfix/
#vi saslpass

%メールドメイン名% %メールユーザー名%:’%パスワード%’

#postmap saslpass
#rm saslpass

squeeze化したLS-GLに必要なソフトウェアのインストール

Filed under: 育苗管理システム — pinewell @ 5:48 PM

いっぱいある。

apt-get install ntpdate
apt-get install lighttpd
apt-get install php5-cgi
apt-get php5-mysql
apt-get install smartmontools
apt-get install logwatch
apt-get install motion
apt-get libwww-perl
apt-get nkf

apt-get install postfix
Postfix Configurationは
Internet Site
System Mail Name :camera.%メールドメイン名%

apt-get mysql-server
Configuring mysql-server
password :

apt-get install hddtemp
daemon設定はNoで。

debianの設定
# dpkg-reconfigure locales
ja_JP.UTF-8 を追加、defaultはNone。
# update-alternatives –config editor
editorをvim.tinyに変更

sshdの設定
 ポートをnnnnnへ変更、ルートのログインを禁止。
vi /etc/ssh/sshd_config
Port 22
–>Port nnnnn
PermitRootLogin yes
–>PermitRootLogin no

ntpdateの設定
vi /etc/cron.daily/ntpdate

#!/bin/sh
/usr/sbin/ntpdate ntp.nict.jp >> /dev/null

#chmod 755 ntpdate

追記
#apt-get install php5-cli
#apt-get install php5-gmp

回路図

Filed under: 育苗管理システム — pinewell @ 4:31 PM

ここまでの回路図。

DHT22が一つ、DS18B20が2つ。

Arduinoがあって、ロジックレベルコンバータ。

表示用に16桁x2行のI2C LCD。

これだけ。

Circuit

2013年4月2日

電源の引き出し、ケースの加工

Filed under: 育苗管理システム — pinewell @ 7:01 PM

Arduinoで使う5Vの電源をLS-GLの電源より分岐させる。

NCM_0042

 

 

 

赤が5Vだった。

 

 

モジュラージャックを設置するために背面を加工。

NCM_0045

 

 

プラのケースカバー、ケース本体の鉄を切り出す。

 

 

NCM_0051

2.5インチHDD、Arduinoを乗せた基板を固定するためのネジ穴。

ボルトの出ているのがArduinoの位置。

 

 

 

 

NCM_0055

 

 

乗っけたらこんな感じ。HDDのコネクタは右(後ろ方向)に出る。

100均で買ってきたモジュラー分配。

Filed under: 育苗管理システム — pinewell @ 7:00 PM

NCM_0040

 

 

 

 

 

100円均一で買ってきたモジュラーの分配機。

黒・赤は分配されたまま使用。VCCとGNDとなる。

黄・緑の線はそれぞれに一つ。これはArduinoとDS18B20との接続に使う。

tel

 

 

DS18B20で使うのは3本なのでこれでよし。

 

 

 

2013年4月1日

I2C液晶。

Filed under: 育苗管理システム — pinewell @ 7:00 PM

StrawberryLinuxのI2C液晶。

ユニバーサル基板を切り出し、3.3kΩの抵抗と配線をハンダ付け。

NCM_0037

4本の信号線をハンダ付け。

黄色がSLCで緑がSDA。黒がGNDで赤がVCC。

左上には3.3kΩのプルアップ用抵抗。

Arduinoと接続するためのコネクタはヘッダピン(オス)。

並びは上から黒、緑、黄、赤。

 

 

NCM_0038

完成。右上にヘッダピンが見える。

 

« Newer Posts

Powered by WordPress