Edited at

電源不要のLTE農地監視カメラを月額298円で運用する


目的

とある事情から、家から遠いところに畑を借りました。

そこでじゃがいも、トウモロコシ、キュウリ、カボチャを育てています。

ただ車で30分ほどかかるので、おいそれ毎日と行けるわけではありません。

そこでカメラを畑に設置して写真を送信し、収穫時期や水やりの時期などを監視できるようにして楽しようと考えました!


しくみ

ソーラーパネルでバッテリーを充電し、その電力でRaspberrypiという小型パソコンを動かし、カメラで撮影した写真をインターネットに送信し、LINEに通知します。

送信した写真は毎日スマホで見ることができますので、頃合いを見計らって畑に行けるというしくみ!

ランニングコストはLTE通信の月々298円のみ!

なお、ラズベリーパイはnode-redというブロックを組み合わせて作るプログラムツールを使用しています。

写真はGoogleのfirebaseというストレージに保存し、そのURLをIFTTT経由でLINEに通知しています。

概念.png


部品

部品
価格
購入先

ケース
880円
ホームセンター

30Wソーラーパネル
5,500円
Amazon

12V20Aディープサイクルバッテリー
4,770円
Amazon

太陽電池充放電コントローラー
3,000円
Amazon

Raspberrypi2
昔4,000円くらい

Raspberrypi用カメラ(v1.2)
850円
Amazon

USB-LTEモジュール(L-02C)
2000円
ヤフオク

車載用USBアダプタ電源
108円
ダイソー

VVF1.6ケーブル 2c 10m
1000円くらい
ホームセンター

LTE回線契約料(キャンペーン価格)
2,160円
WEB

合計
23,268円
※購入当時価格


環境

概要
詳細

本体
Raspberrypi2 Raspbian

LTE通信

ロケットモバイル神プラン(298円/月)
200円分の招待コード「MLXKFDZAPT」

ストレージ
firebase(5GBまで無料)

LINE送信
ITFFF経由


写真


送信された写真

雑草まみれで除草できていないのが分かると思いますww

20190627173144.jpg


設置場所

ワイヤレスなので畑の端っこに適当に配置して、撮影したい場所に向けるのみ。

s_P_20190629_142601_vHDR_On.jpg

s_P_20190707_140235_vHDR_On.jpg

自然豊かな場所に1ヶ月位放置したら、なんかよくわからないモヤモヤした蜘蛛の巣みたいのが発生・・・なにかの虫??


node-red


フロー

image.png


ソース


node-red

[{"id":"be23d13c.bebf2","type":"camerapi-takephoto","z":"61f2e9a4.ec44b8","filemode":"2","filename":"","filedefpath":"1","filepath":"","fileformat":"jpeg","resolution":"4","rotation":"0","fliph":"0","flipv":"0","brightness":"50","contrast":"0","sharpness":"0","quality":"80","imageeffect":"none","exposuremode":"auto","iso":"0","agcwait":"1.0","led":"0","awb":"auto","name":"カメラ","x":130,"y":640,"wires":[["2a68b07.858945"]]},{"id":"83d92cbe.eaaed","type":"inject","z":"61f2e9a4.ec44b8","name":"1時間ごと","topic":"","payload":"","payloadType":"str","repeat":"3600","crontab":"","once":true,"onceDelay":0.1,"x":130,"y":100,"wires":[["bd9d4199.3518"]]},{"id":"15446452.67c9ac","type":"upload-to-firebase","z":"61f2e9a4.ec44b8","server":"8398db4d.994908","name":"firebase","folder":"/test","x":300,"y":760,"wires":[["d6941cb6.1d83b"]]},{"id":"1e4d6512.827ffb","type":"function","z":"61f2e9a4.ec44b8","name":"firebase定義","func":"const func = global.get(\"func\");\nvar filename =msg.filename.replace(/^.*[\\\\\\/]/, '');\nvar data = {\n        \"fileName\":\"\"+func.nowtime()+\".jpg\",\n        \"content\":msg.payload,\n        \"contentType\":'image/jpeg',\n} \n    msg.attachments =[data];\n    return msg;","outputs":1,"noerr":0,"x":150,"y":760,"wires":[["15446452.67c9ac"]]},{"id":"9fafb929.adcc18","type":"file in","z":"61f2e9a4.ec44b8","name":"写真保存","filename":"","format":"","chunk":false,"sendError":false,"x":400,"y":640,"wires":[["1e4d6512.827ffb"]]},{"id":"2a68b07.858945","type":"function","z":"61f2e9a4.ec44b8","name":"写真名","func":"    msg.filename = msg.payload;\n    return msg;","outputs":1,"noerr":0,"x":270,"y":640,"wires":[["9fafb929.adcc18"]]},{"id":"d1f664f7.5a4f78","type":"exec","z":"61f2e9a4.ec44b8","command":"sudo poff rocketmobile","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"PPP切断","x":820,"y":880,"wires":[[],[],["2eaabe7d.8bb122"]]},{"id":"bd9d4199.3518","type":"exec","z":"61f2e9a4.ec44b8","command":"sudo hub-ctrl -h 0 -P 2 -p 1","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"USB電源オン","x":140,"y":180,"wires":[[],[],["c9719def.2d9ea"]]},{"id":"2eaabe7d.8bb122","type":"delay","z":"61f2e9a4.ec44b8","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":960,"y":780,"wires":[["45e29518.09036c"]]},{"id":"19ff7546.6f65db","type":"ifttt out","z":"61f2e9a4.ec44b8","eventName":"post_line","key":"95c9fe48.e0b69","x":580,"y":840,"wires":[]},{"id":"d6941cb6.1d83b","type":"function","z":"61f2e9a4.ec44b8","name":"LINE用定義","func":"const func = global.get(\"func\");\n\n\nmsg.payload ={\n    value1:func.nowtime2(),\n    value2:msg.downloadUrl,\n    value3:\"\"\n    \n};\n\nvar now = new Date();\nmsg.hour=now.getHours();\n\nreturn msg;","outputs":1,"noerr":0,"x":170,"y":860,"wires":[["ad89036c.ed679"]]},{"id":"ad89036c.ed679","type":"switch","z":"61f2e9a4.ec44b8","name":"12時のみ送信","property":"hour","propertyType":"msg","rules":[{"t":"eq","v":"12","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":360,"y":860,"wires":[["19ff7546.6f65db","1004c840.e96e68"],["d1f664f7.5a4f78"]]},{"id":"1004c840.e96e68","type":"delay","z":"61f2e9a4.ec44b8","name":"LINE送信待ち10秒","pauseType":"delay","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":590,"y":900,"wires":[["d1f664f7.5a4f78"]]},{"id":"45e29518.09036c","type":"exec","z":"61f2e9a4.ec44b8","command":"sudo hub-ctrl -h 0 -P 2 -p 0","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"USB電源オフ","x":1120,"y":780,"wires":[[],[],[]]},{"id":"351ec79d.5d7a88","type":"inject","z":"61f2e9a4.ec44b8","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":110,"y":40,"wires":[["b14cd53.7ec9d28"]]},{"id":"b14cd53.7ec9d28","type":"function","z":"61f2e9a4.ec44b8","name":"関数初期化","func":"\nconst foo ={ nowtime:function() {\nvar now = new Date();\nvar res = \"\" + now.getFullYear()\n+ (\"0\"+(1+now.getMonth())).slice(-2) \n+ (\"0\"+now.getDate()).slice(-2)\n+ (\"0\"+now.getHours()).slice(-2)\n+ (\"0\"+now.getMinutes() ).slice(-2)\n+ (\"0\"+now.getSeconds()).slice(-2);\nreturn res;\n},nowtime2:function() {\nvar now = new Date();\nvar res = \"\" + now.getFullYear()+\"/\"\n+ (\"0\"+(1+now.getMonth())).slice(-2) +\"/\"\n+ (\"0\"+now.getDate()).slice(-2)+\" \"\n+ (\"0\"+now.getHours()).slice(-2)+\":\"\n+ (\"0\"+now.getMinutes() ).slice(-2)+\":\"\n+ (\"0\"+now.getSeconds()).slice(-2);\nreturn res;\n}};\nglobal.set(\"func\",foo);","outputs":1,"noerr":0,"x":250,"y":40,"wires":[[]]},{"id":"c9719def.2d9ea","type":"change","z":"61f2e9a4.ec44b8","name":"i=0","rules":[{"t":"set","p":"usboncheck","pt":"global","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":130,"y":280,"wires":[["917a9170.2db0d"]]},{"id":"efd48a5b.73a338","type":"switch","z":"61f2e9a4.ec44b8","name":"USB認識","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"LG Electronics","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":660,"y":280,"wires":[["51fb6658.a29438"],["93c449db.4116e8"]]},{"id":"917a9170.2db0d","type":"switch","z":"61f2e9a4.ec44b8","name":"i<10","property":"usboncheck","propertyType":"global","rules":[{"t":"lt","v":"10","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":288,"y":280,"wires":[["b1a41b66.83e138"],["2eaabe7d.8bb122"]]},{"id":"93c449db.4116e8","type":"delay","z":"61f2e9a4.ec44b8","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":400,"y":200,"wires":[["cba507d3.bee3d8"]]},{"id":"b1a41b66.83e138","type":"exec","z":"61f2e9a4.ec44b8","command":"lsusb","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"USBチェック","x":500,"y":280,"wires":[["efd48a5b.73a338"],[],[]]},{"id":"cba507d3.bee3d8","type":"function","z":"61f2e9a4.ec44b8","name":"i++","func":"\nglobal.set(\"usboncheck\",global.get(\"usboncheck\")+1);\n\nreturn msg;","outputs":1,"noerr":0,"x":530,"y":200,"wires":[["917a9170.2db0d"]]},{"id":"51fb6658.a29438","type":"exec","z":"61f2e9a4.ec44b8","command":"sudo pon rocketmobile","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"PPP接続","x":160,"y":400,"wires":[[],[],["93f2ac13.c50ea"]]},{"id":"93f2ac13.c50ea","type":"delay","z":"61f2e9a4.ec44b8","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":140,"y":480,"wires":[["a0a63e42.6c41d"]]},{"id":"9fd260bc.17c55","type":"exec","z":"61f2e9a4.ec44b8","command":"ifconfig","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":500,"y":540,"wires":[["1e726a25.86cf06"],[],[]]},{"id":"1e726a25.86cf06","type":"switch","z":"61f2e9a4.ec44b8","name":"有無","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"ppp0","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":650,"y":540,"wires":[["be23d13c.bebf2"],["a667f1f8.6cccb"]]},{"id":"a0a63e42.6c41d","type":"change","z":"61f2e9a4.ec44b8","name":"i=0","rules":[{"t":"set","p":"usboncheck","pt":"global","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":150,"y":540,"wires":[["be517d.d3f65e8"]]},{"id":"be517d.d3f65e8","type":"switch","z":"61f2e9a4.ec44b8","name":"i<10","property":"usboncheck","propertyType":"global","rules":[{"t":"lt","v":"10","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":310,"y":540,"wires":[["9fd260bc.17c55"],["2eaabe7d.8bb122"]]},{"id":"5ad017f6.358168","type":"function","z":"61f2e9a4.ec44b8","name":"i++","func":"\nglobal.set(\"usboncheck\",global.get(\"usboncheck\")+1);\n\nreturn msg;","outputs":1,"noerr":0,"x":550,"y":460,"wires":[["be517d.d3f65e8"]]},{"id":"a667f1f8.6cccb","type":"delay","z":"61f2e9a4.ec44b8","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":400,"y":460,"wires":[["5ad017f6.358168"]]},{"id":"8398db4d.994908","type":"config-firebase","z":"","apikey":"AIzaSyCoIeNS4vgYsNwnt5oVZBpcAhyOGaSe6uo","authdomain":"********.firebaseapp.com","bucket":"********.appspot.com","project":"test"},{"id":"95c9fe48.e0b69","type":"ifttt-key","z":""}]


以下PPP接続(pon)に必要


/etc/ppp/peers/rocketmobile

# This optionfile was generated by pppconfig 2.3.18.

#
#
hide-password
noauth
connect "/usr/sbin/chat -v -f /etc/chatscripts/rocketmobile"
debug
/dev/ttyUSB2
460800
defaultroute
noipdefault
user "roke@moba"
remotename rocketmobile
ipparam rocketmobile

usepeerdns

/dev/ttyUSB2



/etc/chatscripts/rocketmobile

# This chatfile was generated by pppconfig 2.3.18.

# Please do not delete any of the comments. Pppconfig needs them.
#
# ispauth CHAP
# abortstring
ABORT BUSY ABORT 'NO CARRIER' ABORT VOICE ABORT 'NO DIALTONE' ABORT 'NO DIAL TONE' ABORT 'NO ANSWER' ABORT DELAYED
# modeminit
'' ATH
OK AT+CFUN=1
OK ATZ
OK 'ATQ0 V1 E1 S0=0 &C1 &D2'
OK AT+CGDCONT=1,"IP","4gn.jp"
# ispnumber
OK-AT-OK "ATDT*99#"
# ispconnect
CONNECT \d\c
# prelogin

# ispname
# isppassword
# postlogin

# end of pppconfig stuff



作った結果

楽にならなかった…

必要なときだけ行こう!とか思っていたら、水やりや追肥、雑草取りや収穫などで暇さえあれば行かなければならない状態…なぜだ…

ただ、写真で現地の様子が確認できるのでよくわからないことに対するもやもや感は無くなった気がします。