{"id":1519,"date":"2018-04-18T02:03:22","date_gmt":"2018-04-17T17:03:22","guid":{"rendered":"https:\/\/www.dogrow.net\/python\/?p=1519"},"modified":"2018-05-03T00:29:25","modified_gmt":"2018-05-02T15:29:25","slug":"blog94","status":"publish","type":"post","link":"https:\/\/www.dogrow.net\/python\/blog94\/","title":{"rendered":"(94) \u3010\u9023\u8f091-4\u3011\u521d\u30e9\u30ba\u30d1\u30a4\uff1a \u6e29\u5ea6\u30c7\u30fc\u30bf\u3092SCP\u3067\u5468\u671f\u8ee2\u9001"},"content":{"rendered":"<h1 class=\"my_h\">1. \u3084\u308a\u305f\u3044\u3053\u3068<\/h1>\n<p>\u300c\u306f\u3058\u3081\u3066\u306e\u30e9\u30ba\u30d1\u30a4\uff01\u300d\u3092\u30e1\u30e2\u3057\u3066\u884c\u304d\u305f\u3044\u3002\u3053\u306e\u9023\u8f09\u306e\u6700\u7d42\u76ee\u6a19\u306f\u3001<br \/>\n<span class=\"my_fc_deeppink my_fs_big2\">\u30e9\u30ba\u30d1\u30a4\u3067\u5468\u671f\u6e29\u5ea6\u5831\u544a\u7aef\u672b\u88c5\u7f6e(WiFi\u7d4c\u7531)\u3092\u4f5c\u308b<\/span><br \/>\n\u3053\u3068\u3002<\/p>\n<p><a href=\"https:\/\/www.dogrow.net\/python\/blog91\/\">(91) \u3010\u9023\u8f091-1\u3011\u521d\u30e9\u30ba\u30d1\u30a4\uff1a \u9078\u5b9a\uff06\u5165\u624b\u7de8<\/a> \u3067\u306f\u3001\u30e9\u30ba\u30d1\u30a4\u3092\u5165\u624b\u3057\u305f\u3002<br \/>\n<a href=\"https:\/\/www.dogrow.net\/python\/blog92\/\">(92) \u3010\u9023\u8f091-2\u3011\u521d\u30e9\u30ba\u30d1\u30a4\uff1a WiFi\u3067\u7e4b\u3050<\/a> \u3067\u306f\u3001\u30e9\u30ba\u30d1\u30a4\u306b WiFi\u7d4c\u7531\u3067SSH\u63a5\u7d9a\u3057\u305f\u3002<br \/>\n<a href=\"https:\/\/www.dogrow.net\/python\/blog93\/\">(93) \u3010\u9023\u8f091-3\u3011\u521d\u30e9\u30ba\u30d1\u30a4\uff1a \u6e29\u5ea6\u30bb\u30f3\u30b5\u30fc\u3092\u3064\u306a\u3050<\/a> \u3067\u306f\u3001\u30e9\u30ba\u30d1\u30a4\u3067\u6e29\u5ea6\u5024\u3092\u53d6\u5f97\u3057\u305f\u3002<\/p>\n<p>\u4eca\u56de\u306f\u3001\u30e9\u30ba\u30d1\u30a4\u3067\u53d6\u5f97\u3057\u305f\u6e29\u5ea6\u5024\u3092\u3001WiFi\u7d4c\u7531\u3067\u5468\u671f\u7684\u306b SCP\u9001\u4fe1\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u3002<\/p>\n<h1 class=\"my_h\">2. \u65b9\u91dd<\/h1>\n<p>\u4eca\u56de\u306f\u5b9f\u88c5\u65b9\u91dd\u3067\u5c11\u3005\u8ff7\u3063\u3066\u3044\u308b\u3002<\/p>\n<h3 class=\"my_h\">(1) \u5b9f\u88c5\u65b9\u6cd5\u306e\u5019\u88dc<\/h3>\n<p>\u5019\u88dc\uff11\uff09 \u5468\u671f\u7684\u306b\u53d6\u5f97\u3057\u305f\u6e29\u5ea6\u5024\u3092\u5358\u767a\u3067\u9001\u4fe1\u3059\u308b\u3002<br \/>\n\u5019\u88dc\uff12\uff09 \u5468\u671f\u7684\u306b\u53d6\u5f97\u3057\u305f\u6e29\u5ea6\u5024\u3092\u8a18\u9332\u3057\u305f\u4eca\u65e5\u4e00\u65e5\u5206\u306e\u6e29\u5ea6\u30c7\u30fc\u30bf\u3092\u9001\u4fe1\u3059\u308b\u3002<br \/>\n\u5019\u88dc\uff13\uff09 \u5468\u671f\u7684\u306b\u53d6\u5f97\u3057\u305f\u6e29\u5ea6\u5024\u3092\u8a18\u9332\u3057\u305f\u30c7\u30fc\u30bf\u3092\u57fa\u306b\u4f5c\u3063\u305f\u30b0\u30e9\u30d5\u30c7\u30fc\u30bf or \u753b\u50cf\u3092\u9001\u4fe1\u3059\u308b\u3002<\/p>\n<p>\u3069\u308c\u306b\u3057\u3088\u3046\u304b&#8230;<\/p>\n<p>\u5019\u88dc\uff11\uff09\u306f\u3042\u3093\u307e\u308a\u306b\u3082\u5358\u7d14\u3067\u4e0d\u89aa\u5207\u304b\uff1f<br \/>\n\u5019\u88dc\uff13\uff09\u306f\u904e\u5270\u30b5\u30fc\u30d3\u30b9\u304b\uff1f<br \/>\n\u5019\u88dc\uff12\uff09\u3050\u3089\u3044\u304c\u3088\u3044\u306e\u304b\uff1f<\/p>\n<h3 class=\"my_h\">(2) \u65b9\u91dd\u3092\u6c7a\u5b9a<\/h3>\n<div class=\"my_fc_deeppink\" style=\"border:2px #ff1493 solid; padding:10px;border-radius:5px;margin:15px 10px;\">1) 1\u65e5 1\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3002<br \/>\n2) \u5468\u671f\u51e6\u7406\u3067\u306f\u3001\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u300c\u6642\u523b\u3001\u6e29\u5ea6\u300d\u3092\u8ffd\u8a18\u3057\u3066\u3044\u304f\u3002<br \/>\n3) \u5468\u671f\u51e6\u7406\u3067\u306f\u3001\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u66f4\u65b0\u5f8c\u306b SCP\u8ee2\u9001\u3059\u308b\u3002<\/div>\n<p>\u307e\u305a\u306f\u3053\u308c\u3067\u3084\u3063\u3066\u307f\u3088\u3046\u3002<\/p>\n<h1 class=\"my_h\">3. \u3084\u3063\u3066\u307f\u308b<\/h1>\n<h3 class=\"my_h\">(1) \u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4f5c\u6210<\/h3>\n<p>crond\u3067\u5468\u671f\u5b9f\u884c\u3059\u308b\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u66f8\u304f\u3002<\/p>\n<p>\u51e6\u7406\u30d5\u30ed\u30fc\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3002<br \/>\n1) \u6700\u65b0\u6e29\u5ea6\u3092\u53d6\u5f97\u3059\u308b\u3002 \uff08Shell\uff09<br \/>\n2) \u4eca\u65e5\u306e\u6e29\u5ea6\u8a18\u9332\u30d5\u30a1\u30a4\u30eb\u306b\u60c5\u5831\u3092\u8ffd\u8a18\u3059\u308b\u3002\uff08Python\uff09<br \/>\n3) \u3053\u306e\u30d5\u30a1\u30a4\u30eb\u3092 SCP\u8ee2\u9001\u3059\u308b\u3002 \uff08Shell\uff09<\/p>\n<p><spam class=\"my_fw_bold\">update_temp.sh<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n#!\/bin\/sh\r\ncd \/home\/piuser\/temperature\r\n\r\nTEMPFILE=\/sys\/bus\/w1\/devices\/28-0000086e3f47\/w1_slave\r\nDATETIME=`date +%Y_%m%d_%H%M`\r\n \r\n# 1) measurement (Shell)\r\nTEMPRAW=`cat $TEMPFILE | grep -e &quot;t=&quot; | awk -F &quot;t=&quot; '{print $NF}'`\r\nTEMPDEG=`echo $TEMPRAW | awk '{printf(&quot;%.1f&quot;, $1 \/ 1000)}'`\r\n \r\n# 2) update file (Python)\r\npython update_temp.py $DATETIME $TEMPDEG\r\n \r\n# 3) send (Shell)\r\nfor FILE in `find . -type f | sort -r`; do\r\n  scp -i .\/.my_private_key.ppk $FILE hoge@example.com:~\/temperature\r\n  break\r\ndone\r\n#end\r\n<\/pre>\n<h3 class=\"my_h\">(2) Python\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u66f8\u304f<\/h3>\n<p>Python\u3067\u306f\u3001\u5468\u671f\u8d77\u52d5\u6642\u306b\u6700\u65b0\u306e\u6e29\u5ea6\u60c5\u5831\u3092 1\u65e5\u5206\u306e\u6e29\u5ea6\u8a18\u9332\u30d5\u30a1\u30a4\u30eb\u306b\u4fdd\u5b58\u3059\u308b\u51e6\u7406\u3092\u5b9f\u88c5\u3059\u308b\u3002<\/p>\n<p><spam class=\"my_fw_bold\">update_temp.py<\/span><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nimport sys\r\nimport os\r\nimport numpy as np\r\n\r\n#---------------------------------\r\n# argv&#x5B;1] : date &quot;yyyy_mmdd_hhmm&quot;\r\n# argv&#x5B;2] : temperature &quot;sxxxxxx.x&quot;\r\nif __name__ == '__main__':\r\n    ary_argv = sys.argv\r\n    a_datetime = ary_argv&#x5B;1].split('_')\r\n    a_date = '%s_%s' % (a_datetime&#x5B;0], a_datetime&#x5B;1])\r\n    a_time = a_datetime&#x5B;2]\r\n    a_temp = ary_argv&#x5B;2]\r\n\r\n    fpath = a_date + &quot;.csv&quot;\r\n\r\n    if True == os.path.isfile(fpath) :\r\n        tempData = np.loadtxt(fpath, delimiter=',', dtype='|S8', ndmin=2)\r\n        tempData = np.append(tempData, &#x5B;&#x5B;a_time, a_temp]], axis=0)\r\n    else :\r\n        tempData = np.array(&#x5B;&#x5B;a_time, a_temp]], dtype='|S8')\r\n\r\n    np.savetxt(fpath, tempData, delimiter=',', fmt='%s')\r\n<\/pre>\n<h3 class=\"my_h\">(3) \u5358\u767a\u3067\u5b9f\u884c\u3057\u3066\u307f\u308b<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ .\/update_temp.sh\r\n<\/pre>\n<p>OK\u3060\uff01<br \/>\n\u610f\u56f3\u3057\u305f\u901a\u308a\u306b CSV\u30d5\u30a1\u30a4\u30eb\u304c\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3055\u308c\u3066\u3044\u305f\u3002<\/p>\n<h3 class=\"my_h\">(4) crond\u3067\u5468\u671f\u5b9f\u884c\u3059\u308b<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ crontab -e\r\n<\/pre>\n<p>10\u5206\u3054\u3068\u306b\u5b9f\u884c\u3059\u308b\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n*\/10 * * * * \/home\/piuser\/temperature\/update_temp.sh\r\n<\/pre>\n<h1 class=\"my_h\">4. \u6240\u611f<\/h1>\n<p>\u3072\u3068\u307e\u305a&#8230;<br \/>\n\u30e9\u30ba\u30d1\u30a4\u3067\u53ce\u96c6\u3057\u305f\u6e29\u5ea6\u30c7\u30fc\u30bf\u3092\u3001\u5468\u671f\u7684\u306b\u5225\u30de\u30b7\u30f3\u306b\u8ee2\u9001\u3059\u308b\u3068\u3053\u308d\u307e\u3067\u306f\u51fa\u6765\u305f\u3002<\/p>\n<p>\u3053\u308c\u3067\u672c\u9023\u8f09\u306f\u7d42\u308f\u308a\u3067\u3088\u3044\u306e\u304b\uff1f<br \/>\n\u3084\u3051\u306b\u5c3b\u3059\u307c\u307f\u306a\u7d42\u308f\u308a\u65b9\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u304c&#8230;<\/p>\n<p>\u610f\u56f3\u305b\u305a 1-Wire\u306e\u304a\u304b\u3052\u3067\u30c7\u30d0\u30a4\u30b9\u5236\u5fa1\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u5b9f\u88c5\u5de5\u6570\u304c\u30bc\u30ed\u306b\u306a\u3063\u3066\u3057\u307e\u3063\u305f\u3002<br \/>\n\u30c7\u30d0\u30a4\u30b9\u5236\u5fa1\u3092 Python\u3067\u30ac\u30ea\u30ac\u30ea\u66f8\u304f\u3064\u3082\u308a\u3060\u3063\u305f\u304c\u3053\u308c\u304c\u53f6\u308f\u305a\u3001\u6700\u5f8c\u306e\u30d5\u30a1\u30a4\u30eb\u51fa\u529b\u51e6\u7406\u3067\u7121\u7406\u3084\u308a Python\u306e\u51fa\u756a\u3092\u4f5c\u3063\u305f\u304b\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3057\u307e\u3063\u305f\u3002<\/p>\n<p>\u3053\u308c\u304c\u6559\u80b2\u7528\u30c7\u30d0\u30a4\u30b9\u3067\u3042\u308b\u30e9\u30ba\u30d1\u30a4\u306e\u9577\u6240\u306a\u306e\u3067\u3042\u308d\u3046\u3002<br \/>\n\u3068\u306b\u304b\u304f\u6577\u5c45\u304c\u4f4e\u304f\u3068\u3063\u3064\u304d\u3084\u3059\u3044\u3068\u611f\u3058\u305f\u3002<\/p>\n<p>\u30bb\u30f3\u30b5\u30fc\u7b49\u306e\u3044\u308d\u3044\u308d\u306a\u30c7\u30d0\u30a4\u30b9\u3092\u5bb9\u6613\u306b\u63a5\u7d9a\u3067\u304d\u308b\u3002<br \/>\nLinux\u30d9\u30fc\u30b9\u306e OS\u3092\u4f7f\u3048\u3070\u7121\u6570\u306e\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u8cc7\u6e90\u3082\u4f7f\u3048\u308b\u3002<br \/>\n\u304d\u3063\u3068\u5c11\u306a\u3044\u5de5\u6570\u3067\u3084\u308a\u305f\u3044\u3053\u3068\u3092\u5b9f\u73fe\u3067\u304d\u308b\u306e\u3060\u308d\u3046\u3002<\/p>\n<p>\u5742\u6751\u3055\u3093\u304c \u300cT-Engine\u3067\u30e6\u30d3\u30ad\u30bf\u30b9\u30b3\u30f3\u30d4\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0\u300d\u3068\u76db\u3093\u306b\u4ef0\u3063\u3066\u3044\u305f\u9803\u3092\u601d\u3044\u51fa\u3059\u3002<br \/>\nIoT\u3068\u540d\u524d\u3092\u5909\u3048\u3001\u4eca\u307e\u3055\u306b\u305d\u3093\u306a\u6642\u4ee3\u304c\u672c\u5f53\u306b\u8fd1\u3065\u3044\u3066\u3044\u308b\u306e\u3060\u3068\u611f\u3058\u308b\u3002<\/p>\n<p>\u4eca\u56de\u306f\u5c3b\u3059\u307c\u307f\u3067\u4eca\u4e00\u3064\u9054\u6210\u611f\u306e\u7121\u3044\u7d42\u308f\u308a\u65b9\u306b\u306a\u3063\u3066\u3057\u307e\u3063\u305f\u304c\u3001\u307e\u305f\u3044\u3064\u304b\u30e9\u30ba\u30d1\u30a4\u306b\u5225\u306e\u30c7\u30d0\u30a4\u30b9\u3092\u63a5\u7d9a\u3057\u3066\u904a\u3093\u3067\u307f\u3088\u3046\u3068\u601d\u3046\u3002<\/p>\n<hr class=\"my_hr_bottom\">\n","protected":false},"excerpt":{"rendered":"<p>1. \u3084\u308a\u305f\u3044\u3053\u3068 \u300c\u306f\u3058\u3081\u3066\u306e\u30e9\u30ba\u30d1\u30a4\uff01\u300d\u3092\u30e1\u30e2\u3057\u3066\u884c\u304d\u305f\u3044\u3002\u3053\u306e\u9023\u8f09\u306e\u6700\u7d42\u76ee\u6a19\u306f\u3001 \u30e9\u30ba\u30d1\u30a4\u3067\u5468\u671f\u6e29\u5ea6\u5831\u544a\u7aef\u672b\u88c5\u7f6e(WiFi\u7d4c\u7531)\u3092\u4f5c\u308b \u3053\u3068\u3002 (91) \u3010\u9023\u8f091-1\u3011\u521d\u30e9\u30ba\u30d1\u30a4\uff1a \u9078\u5b9a\uff06\u5165\u624b\u7de8 \u3067\u306f\u3001\u30e9\u30ba\u30d1\u30a4\u3092\u5165\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.dogrow.net\/python\/blog94\/\">\u7d9a\u304d\u3092\u8aad\u3080 &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1519","post","type-post","status-publish","format-standard","hentry","category-raspberry-pi"],"views":7012,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts\/1519","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/comments?post=1519"}],"version-history":[{"count":43,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts\/1519\/revisions"}],"predecessor-version":[{"id":1710,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts\/1519\/revisions\/1710"}],"wp:attachment":[{"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/media?parent=1519"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/categories?post=1519"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/tags?post=1519"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}