{"id":692,"date":"2019-08-27T00:07:27","date_gmt":"2019-08-26T15:07:27","guid":{"rendered":"https:\/\/dalomo.net\/blog\/?p=692"},"modified":"2019-09-01T11:00:45","modified_gmt":"2019-09-01T02:00:45","slug":"rasberry-pi-zero-wh%e3%81%a7%e7%85%a7%e6%98%8e%e4%bb%98%e3%81%8d%e5%ae%9a%e7%82%b9%e3%82%ab%e3%83%a1%e3%83%a9%e3%82%92%e4%bb%95%e4%b8%8a%e3%81%92%e3%82%8b","status":"publish","type":"post","link":"https:\/\/dalomo.net\/blog\/2019\/08\/27\/692\/","title":{"rendered":"Rasberry Pi Zero WH\u3067\u7167\u660e\u4ed8\u304d\u5b9a\u70b9\u30ab\u30e1\u30e9\u3092\u4ed5\u4e0a\u3052\u308b"},"content":{"rendered":"<h1>\u4f5c\u3063\u3066\u304d\u305f\u3084\u3064\u3092\u307e\u3068\u3081\u308b<\/h1>\n<p>\u4eca\u307e\u3067\u51e6\u7406\u3054\u3068\u306b\u4f5c\u3063\u3066\u304d\u305f\u3084\u3064\u3092\u4e00\u3064\u306b\u307e\u3068\u3081\u3066\u3001\u5b8c\u6210\u3055\u305b\u3088\u3046\u3068\u601d\u3046\u3002\u51e6\u7406\u306e\u6d41\u308c\u3068\u3057\u3066\u306f<\/p>\n<ol>\n<li>10\u5206\u3054\u3068\u306b\u51e6\u7406\u3092\u884c\u3046\u3002<\/li>\n<li>\u6642\u9593\u304c\u304d\u305f\u3089\u660e\u308b\u3055\u3092\u53d6\u5f97\u3059\u308b\u3002<\/li>\n<li>\u660e\u308b\u3055\u3092\u3082\u3068\u306b\u30e9\u30a4\u30c8\u3092\u70b9\u3051\u308b\u304b\u5224\u65ad\u3059\u308b\u3002<\/li>\n<li>\u6697\u304b\u3063\u305f\u3089\u30e9\u30a4\u30c8\u3092\u70b9\u3051\u308b\u3002<\/li>\n<li>\u64ae\u5f71\u3092\u3059\u308b\u3002<\/li>\n<li>\u64ae\u5f71\u3057\u305f\u753b\u50cf\u306b\u6642\u9593\u3068\u660e\u308b\u3055\u3092\u8868\u793a\u3059\u308b\u3002<\/li>\n<li>\u6bce\u65e518:03\u306b\u5fae\u901f\u5ea6\u52d5\u753b\u3092\u4f5c\u6210\u3059\u308b\u3002<\/li>\n<\/ol>\n<p>\u3053\u3093\u306a\u611f\u3058\u3002\u305d\u306e\u524d\u306b\u660e\u308b\u3055\u6e2c\u5b9a\u3092\u3061\u3087\u3063\u3068\u3044\u3058\u308b\u3002<\/p>\n<h2>ADC\u306b\u30d1\u30b9\u30b3\u30f3\u3092\u4f7f\u3063\u3066\u307f\u308b<\/h2>\n<p>ADC\u306e\u5165\u529b\u306b\u30d0\u30a4\u30d1\u30b9\u30b3\u30f3\u30c7\u30f3\u30b5\u3092\u4f7f\u3046\u3068\u6570\u5024\u304c\u5b89\u5b9a\u3059\u308b\u3089\u3057\u3044\u3002\u30c7\u30fc\u30bf\u30b7\u30fc\u30c8\u306b\u66f8\u3044\u3066\u3042\u3063\u305f\u306e\u3067\u30011\u03bcF\u306e\u30b3\u30f3\u30c7\u30f3\u30b5\u3092\u8cb7\u3063\u3066\u304d\u305f\u3002\u305d\u308c\u3092IC\u306e\u5165\u529b\u524d\u306b\u5165\u308c\u308b\u30020.1\u79d2\u6bce\u306b1000\u56de\u6570\u5024\u3092\u53d6\u5f97\u3057\u3066\u307f\u3066\u3001\u9055\u3044\u304c\u3042\u308b\u304b\u78ba\u8a8d\u3057\u3066\u307f\u305f\u3002<\/p>\n<p><a href=\"https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2019\/08\/pascon.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-693\" src=\"https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2019\/08\/pascon-300x127.png\" alt=\"\" width=\"300\" height=\"127\" srcset=\"https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2019\/08\/pascon-300x127.png 300w, https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2019\/08\/pascon-768x325.png 768w, https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2019\/08\/pascon-1024x434.png 1024w, https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2019\/08\/pascon.png 1360w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u4e0a\u304c\u30d1\u30b9\u30b3\u30f3\u7121\u3057\u3001\u4e0b\u304c\u3042\u308a\u3002\u3069\u3046\u3067\u3059\u304b\u3002\u8868\u306b\u3057\u3066\u307f\u3088\u3002<\/p>\n<table width=\"276\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\" width=\"72\"><\/td>\n<td style=\"text-align: center;\" width=\"102\">\u30d1\u30b9\u30b3\u30f3\u3042\u308a<\/td>\n<td style=\"text-align: center;\" width=\"102\">\u30d1\u30b9\u30b3\u30f3\u306a\u3057<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">\u5e73\u5747<\/td>\n<td style=\"text-align: center;\">3079.985<\/td>\n<td style=\"text-align: center;\">3309.093<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">\u4e2d\u592e<\/td>\n<td style=\"text-align: center;\">3082<\/td>\n<td style=\"text-align: center;\">3311<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">\u6700\u5927<\/td>\n<td style=\"text-align: center;\">3174<\/td>\n<td style=\"text-align: center;\">3372<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">\u6700\u5c0f<\/td>\n<td style=\"text-align: center;\">2980<\/td>\n<td style=\"text-align: center;\">3238<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">\u6a19\u6e96\u504f\u5dee<\/td>\n<td style=\"text-align: center;\">48.34716926<\/td>\n<td style=\"text-align: center;\">43.57428543<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u3069\u3046\u3067\u3059\u304b\u3002\u30d1\u30b9\u30b3\u30f3\u3042\u308a\u306e\u65b9\u304c\u30d0\u30e9\u3064\u3044\u3066\u3093\u3058\u3083\u306d\u3047\u304b\u3002\u610f\u5473\u306a\u3055\u305d\u3046\u3060\u306a\u3002\u3084\u3081\u3088\u3002<\/p>\n<h2>CdS\u30bb\u30eb\u306e\u3082\u3046\u4e00\u65b9\u306e\u62b5\u6297\u306e\u5024<\/h2>\n<p>IC\u306eCH\u3078\u304b\u3051\u308b\u96fb\u5727\u306f\u5206\u5727\u56de\u8def\u3092\u4f7f\u3063\u3066\u3044\u308b\u306e\u3067\u96fb\u5727\u306e\u5909\u5316\u306f\u66f2\u7dda\u306a\u611f\u3058\u306b\u306a\u308b\u3002\u6697\u3044\u6642\u306b\u6570\u5b57\u304c0\u306b\u306a\u3063\u3066\u3001\u8584\u6697\u3044\u3042\u305f\u308a\u306e\u6570\u5b57\u304c\u7d30\u304b\u304f\u306a\u308b\u62b5\u6297\u306e\u5024\u3063\u3066\u3069\u3046\u3084\u3063\u3066\u6c42\u3081\u3093\u3060\u308d\u30fc\u306a\u30fc\u3068\u8abf\u3079\u305f\u3051\u3069\u3088\u304f\u5206\u304b\u3093\u306a\u304b\u3063\u305f\u306e\u3067\u529b\u6280\u3067\u3044\u304f\u3053\u3068\u306b\u3057\u305f\u3002CdS\u30bb\u30eb\u306e\u62b5\u6297\u306e\u5024\u306f1k\u03a9\u304b\u3089100k\u03a9\u3050\u3089\u3044\u306b\u5909\u308f\u308b\u3068\u3057\u3066\u3001R1\u306bCdS\u3001R2\u306b\u56fa\u5b9a\u5024\u306e\u62b5\u6297\u3092\u5165\u308c\u308b\u3068\u3059\u308b\u3002<\/p>\n<p><a href=\"https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2019\/08\/cdsresi.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-694\" src=\"https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2019\/08\/cdsresi-300x127.png\" alt=\"\" width=\"300\" height=\"127\" srcset=\"https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2019\/08\/cdsresi-300x127.png 300w, https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2019\/08\/cdsresi-768x325.png 768w, https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2019\/08\/cdsresi-1024x434.png 1024w, https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2019\/08\/cdsresi.png 1360w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u3053\u3093\u306a\u611f\u3058\u3067\u3001R2\u306e\u62b5\u6297\u5024\u304c\u5927\u304d\u304f\u306a\u308b\u307b\u3069\u30ab\u30fc\u30d6\u304c\u7de9\u3084\u304b\u306b\u306a\u3063\u3066\u304f\u307f\u305f\u3044\u300225k\u03a9\u4f7f\u3044\u305f\u304b\u3063\u305f\u3051\u306922k\u03a9\u3057\u304b\u6301\u3063\u3066\u306a\u3044\u3057\u3001\u5408\u6210\u3059\u308b\u30b9\u30da\u30fc\u30b9\u3082\u3042\u3093\u307e\u306a\u3044\u306e\u306722k\u03a9\u306b\u3059\u308b\u3053\u3068\u306b\u3057\u305f\u3002\u4e00\u5ea6\u4e00\u65e5\u4e2d\u56de\u3057\u3066\u307f\u3066\u3001\u6570\u5024\u306e\u5909\u5316\u3092\u8ffd\u3044\u304b\u3051\u3066\u307f\u3063\u3068\u5927\u4f53MPC\u304b\u3089\u5410\u304d\u51fa\u3055\u308c\u308b\u6570\u5024\u304c1000\u3050\u3089\u3044\u306e\u3068\u304d\u304c\u95be\u5024\u3063\u307d\u3044\u3002\u3046\u30fc\u3093\u9069\u5f53\u306a\u3002<\/p>\n<h2>\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0<\/h2>\n<p>\u305d\u308d\u305d\u308d\u6c17\u304c\u6e08\u3093\u3060\u306e\u3067\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3059\u308b\u3002\u4f5c\u3063\u305f\u3084\u3064\u306e\u30b3\u30d4\u30da\u3060\u3002\u4eca\u56de\u306f\u30b3\u30e1\u30f3\u30c8\u5f62\u5f0f\u3067\u610f\u56f3\u3092\u6b8b\u3057\u3068\u3053\u3063\u3068\u3002<\/p>\n<pre class=\"python\">#\u5fc5\u8981\u306a\u3082\u3093import\r\nimport picamera\r\nimport datetime\r\nfrom time import sleep\r\nimport os\r\nfrom PIL import Image, ImageFont, ImageDraw\r\nimport pigpio as pg\r\n\r\npi = pg.pi() #GPIO\u4f7f\u3046\u6e96\u5099\r\n\r\nh = pi.spi_open(0, 50000, 0) #SPI\u901a\u4fe1\u306e\u30cf\u30f3\u30c9\u30e9\r\n\r\n#\u6e96\u5099\u3067\u304d\u3066\u306a\u304b\u3063\u305f\u3089\u7d42\u4e86\r\nif not pi.connected:\r\n    exit(0)\r\n\r\n#ADC\u304b\u3089\u30d0\u30a4\u30ca\u30ea\u3092\u53d6\u5f97\u3001\r\n(count, rx_data) = pi.spi_xfer(h, [0b00000110, 0, 0])\r\nbi = rx_data[1] &lt;&lt; 8 | rx_data[2]\r\n\r\n#\u6697\u304b\u3063\u305f\u3089\u30e9\u30a4\u30c8\u70b9\u3051\u308b\r\nif bi &lt; 1000:\r\n    pi.set_mode(17, pg.OUTPUT)\r\n    pi.write(17, pg.HIGH)\r\n    islighted = True #\u30e9\u30a4\u30c8\u304c\u70b9\u3044\u3066\u308b\u304b\u306ebool\u5024\u306bTrue\r\n\r\n#\u30ab\u30e1\u30e9\u306e\u753b\u50cf\u4fdd\u5b58\u6e96\u5099\r\ndir_path = '\/home\/pi\/nas\/pic\/' #\u4fdd\u5b58\u5834\u6240\r\nfiles = os.listdir(dir_path) #\u4fdd\u5b58\u5834\u6240\u5185\u306e\u30d5\u30a1\u30a4\u30eb\u6570\u3092\u53d6\u5f97\u3057\u2026\r\nfile_name = str(len(files)).zfill(5) #5\u6841\u30670\u30d5\u30a3\u30eb\u3057\u3066\u30d5\u30a1\u30a4\u30eb\u540d\u3067\u4f7f\u3046\r\n\r\n#\u64ae\u5f71\r\nwith picamera.PiCamera() as camera:\r\n    sleep(5) #\u30a6\u30a9\u30fc\u30e0\u30a2\u30c3\u30d7\r\n    camera.hflip = True #\u753b\u50cf\u56de\u8ee2\r\n    camera.vflip = True #\u3053\u308c\u3082\r\n    camera.capture(dir_path+file_name+'.jpg') #\u30d5\u30eb\u30d1\u30b9\u3068\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u6307\u5b9a\u3057\u3066\u4fdd\u5b58\r\n\r\n#\u5199\u771f\u306b\u8ffd\u52a0\u63cf\u753b\u3059\u308b\u6e96\u5099\r\nnow = datetime.datetime.now() #\u65e5\u4ed8\u6642\u523b\u53d6\u5f97\r\ntext = now.strftime('%Y-%m-%d %H:%M') #\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3057\u3066\u6587\u5b57\u5217\u306b\u5909\u63db\r\nillumi = str(bi) #\u660e\u308b\u3055\u306e\u6570\u5024\u3092\u6587\u5b57\u5217\u578b\u306b\u3057\u3068\u304f \u203b\u3044\u3089\u306a\u3044\u304b\u3082\r\n\r\n#\u753b\u50cf\u7de8\u96c6\r\nimg = Image.open(dir_path+file_name+'.jpg') #\u64ae\u5f71\u3057\u305f\u5199\u771f\u958b\u304f\r\ndraw = ImageDraw.Draw(img) #\u63cf\u753b\u306e\u306a\u3093\u304b\r\nfont = ImageFont.truetype('\/home\/pi\/nas\/DSEG7Classic-Bold.ttf', 15) #\u30d5\u30a9\u30f3\u30c8\u6307\u5b9a\r\ndraw.text((6, 6), text, font=font, fill=(0,0,0)) #\u5f71\u3065\u304f\u308a\r\ndraw.text((5, 5), text, font=font, fill=(255,255,255))\r\ndraw.text((6, 25), illumi, font=font, fill=(255,255,255)) #\u3081\u3093\u3069\u3044\u306e\u3067\u660e\u308b\u3055\u306e\u65b9\u306f\u5f71\u4f5c\u3063\u3066\u306a\u3044\r\nimg.save(dir_path+file_name+'.jpg') #\u4e0a\u66f8\u304d\u4fdd\u5b58\r\n\r\n#\u30e9\u30a4\u30c8\u70b9\u3044\u3066\u305f\u3089\u6d88\u3059\r\nif islighted:\r\n    pi.write(17, pg.LOW)\r\n\r\npi.spi_close(h) #SPI\u901a\u4fe1\u306e\u5f8c\u51e6\u7406\r\npi.stop() #GPIO\u306e\u5f8c\u51e6\u7406<\/pre>\n<p>\u2026\u6211\u306a\u304c\u3089\u6c5a\u3044\u30b3\u30fc\u30c9\u3060\u3002\u3067\u3082\u3068\u308a\u3042\u3048\u305a\u5f62\u306b\u306a\u3063\u305f!\u5b09\u3057\u3044\u306d\u3002<\/p>\n<hr \/>\n<p>\u8ffd\u8a18:\u4e0a\u8a18\u30b3\u30fc\u30c9\u306f\u30a8\u30e9\u30fc\u306b\u306a\u308b\u3002<a href=\"https:\/\/dalomo.net\/blog\/2019\/09\/01\/701\/\">\u7d9a\u304d<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u3063\u3066\u304d\u305f\u3084\u3064\u3092\u307e\u3068\u3081\u308b \u4eca\u307e\u3067\u51e6\u7406\u3054\u3068\u306b\u4f5c\u3063\u3066\u304d\u305f\u3084\u3064\u3092\u4e00\u3064\u306b\u307e\u3068\u3081\u3066\u3001\u5b8c\u6210\u3055\u305b\u3088\u3046\u3068\u601d\u3046\u3002\u51e6\u7406\u306e\u6d41\u308c\u3068\u3057\u3066\u306f 10\u5206\u3054\u3068\u306b\u51e6\u7406\u3092\u884c\u3046\u3002 \u6642\u9593\u304c\u304d\u305f\u3089\u660e\u308b\u3055\u3092\u53d6\u5f97\u3059\u308b\u3002 \u660e\u308b\u3055\u3092\u3082\u3068\u306b\u30e9\u30a4\u30c8\u3092\u70b9\u3051\u308b\u304b\u5224\u65ad\u3059\u308b\u3002 \u6697\u304b\u3063 &hellip; <a href=\"https:\/\/dalomo.net\/blog\/2019\/08\/27\/692\/\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":693,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[2],"tags":[58,50,49,47,54],"class_list":["post-692","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-2","tag-led","tag-python","tag-raspberry-pi-zero-wh","tag-47","tag-54"],"_links":{"self":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts\/692","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/comments?post=692"}],"version-history":[{"count":5,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts\/692\/revisions"}],"predecessor-version":[{"id":705,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts\/692\/revisions\/705"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/media\/693"}],"wp:attachment":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/media?parent=692"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/categories?post=692"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/tags?post=692"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}