ãŠã§ãã«ã¡ã©ã¯æ¥œãããŠäŸ¿å©ãªãã®ã§ãã ãŸããèŠéè§ããªã¢ãŒãã§å¶åŸ¡ã§ããããããã®æçšæ§ãããã«åºãããŸãã 䜿çšããããã®å€ãã®ãªãã·ã§ã³ããããã»ãšãã©ã®å Žåãã«ã¡ã©ã¯äŒæäžãåç©ã®äžè©±ãããããã«äœ¿çšãããŸãã ãŸãã¯ãããšãã°ãå人ã«ä»ã®åœã®ããªãã®åœã«èšçœ®ãããã«ã¡ã©ãå¶åŸ¡ããŠãç¹å®ã®ã€ãã³ãã«ãåå ãããæ©äŒãäžããããšãã§ããŸãã ãããã«ãããã¿ãŒã³ããŒãã«ã§ã€ã³ã¿ãŒãããã«æ¥ç¶ãããã«ã¡ã©ã䜿çšãããšãç¶æ³ãããé©åã«å¶åŸ¡ã§ããŸãã ãã®æçš¿ã§ã¯ãå€ãã®æ¥æ倧工ã®ãŠã§ãã«ã¡ã©ãããžã§ã¯ãã®1ã€ã«ã€ããŠèª¬æããŸãã
Piããããã¯ãŒã¯ã«å°å ¥ããŸã
Raspberry Piã¯ãã€ã³ã¿ãŒãããæ¥ç¶ããã€ã¹ãèšèšããããã®åªããããŒã¹ãã©ãããã©ãŒã ã§ãã ãã®ãããªã¿ã¹ã¯ã«ãã Flaskãã¬ãŒã ã¯ãŒã¯ã¯éåžžã«äŸ¿å©ã§ãã æ¢åã®Pythonã¢ããªã±ãŒã·ã§ã³ïŒRaspberry Piã®éçºã«é©ããèšèªïŒã䜿çšããHTMLãã³ãã¬ãŒããè¿œå ããŠããšã³ããŠãŒã¶ãŒåãã®Webã€ã³ã¿ãŒãã§ã€ã¹ãäœæã§ããŸãã ãã®ãããžã§ã¯ãã§ã¯ã¯ãªãŒã³ãªãã³ãã¬ãŒãã䜿çšããŠãããããèªç±ã«å€æããŠä¿®æ£ã§ããŸãã
Piããã®ã¹ããªãŒãã³ã°ãããª
ãŸããPiãä»ããŠãããªã¹ããªãŒã ãã€ã³ã¿ãŒãããã«ãããŒããã£ã¹ãããæ¹æ³ãèŠã€ããå¿ èŠããããŸãã ãã®ãããªäœé»åã·ã¹ãã ã䜿çšããå Žåããã¹ãŠã®ããããã«ãŠã³ããããããããªã¢ã«ã¿ã€ã ã®å§çž®ãšã¹ããªãŒãã³ã°ã¯ã·ã¹ãã ã®è² è·ã倧ããããå¯èœæ§ããããŸãã ãã®çµæãéåžžã«é«ãããã©ãŒãã³ã¹ã瀺ããããã MJPG-StreamerãéžæãããŸããã
ãµãŒãå¶åŸ¡
ã«ã¡ã©ããã³/ãã«ããããµãŒãã¢ãŒã¿ãŒãå¶åŸ¡ããæ¹æ³ãå¿ èŠã§ããã I / Oãã³ã«ã¢ã¯ã»ã¹ããããã®Raspberry Piã®æšæºã©ã€ãã©ãªã¯GPIOãšåŒã°ããŸãã åçŽãªã¢ã¯ã·ã§ã³ãå®è¡ããæ¹ãç°¡åã§ããããµãŒãã¢ãŒã¿ãŒãå¶åŸ¡ããã«ã¯ç²ŸåºŠãäœãããŸãã å€ãã®è©Šè¡é¯èª€ã®åŸã RPIOãšåŒã°ãã代æ¿ã©ã€ãã©ãªãéžæãããŸããã ãã®å©ããåããŠã ã»ãããŒããŠã§ã¢ã§å¶åŸ¡ãããPWMä¿¡å·ã«ã¢ã¯ã»ã¹ã§ããŸããã å®å šã«æ©èœãããããžã§ã¯ããæ§ç¯ããæåŸã®ã¢ã¶ã€ã¯èŠçŽ ã§ãããã€ã³ã¿ãŒãããã«æ¥ç¶ããããã®çŽ æŽãããåºçºç¹ã§ããïŒ
ãã®ãããžã§ã¯ãã®ãã¹ãŠã®ã³ãŒãã¯Githubããã3Dã¢ãã«ã¯ThingiverseããããŠã³ããŒãã§ããŸãã
泚 ïŒeLinuxã«ã¯ã PiäºæUSB Webã«ã¡ã©ã®ãªã¹ãããããŸã ã ãã®ãããžã§ã¯ãã§ã¯C260ãŠã§ãã«ã¡ã©ã䜿çšããŠããŸãããããã¯æ¢ã«å©çšã§ããªãå ŽåããããŸãã C525㯠ãã¬ãã¥ãŒã«ãããšããè¿œå ããã«æ©èœããŸãã Powerãã§ãããèšèšã§ã¯ãã¹ããããŠããŸããã C270ã¯ãextã ã¢ã¯ãã£ããªUSBãããšããŠã®é»æºã ãã¶ã€ã³ã®3Dã¢ãã«ã¯C260 / 270åãã«ã·ã£ãŒãåãããŠããŸãããã«ã¡ã©ã«åãããŠå€æŽã§ããŸãã
ã¹ãããïŒ1ïŒç»åãSDã«ãŒãã«æžã蟌ã
â¢ãã®ãããžã§ã¯ãã®OSãšããŠãRaspberry Pi Linuxãã£ã¹ããªãã¥ãŒã·ã§ã³ã«é©å¿ããRaspbianãéžæãããŸããã ãã¹ã¯ãŒãïŒã©ãºããªãŒïŒãå«ããã»ãšãã©ã®æšæºèšå®ã¯ãã®ãŸãŸã§ãã ã€ã³ã¹ããŒã«ãå®äºãããããã°ã€ã³ããŠraspi-configãå®è¡ããã奜ã¿ã«åãããŠãã¹ã¯ãŒãããã®ä»ã®èšå®ãå€æŽããå¿ èŠããããŸãã
â¢ãã®ãããžã§ã¯ããæ©èœãããã«ã¯ãRaspbianã€ã¡ãŒãžã«å€ãã®å€æŽãå ããå¿ èŠããããŸãã å®æããPiCamã€ã¡ãŒãžãcdn.makezine.com/make/WeekendProjects/HomeSentrySecurityCamera/PiCam.imgããããŠã³ããŒãããŠãSDã«ãŒãã«æžã蟌ãããšãã§ããŸãã
â¢ç»åèšé²èªäœã®ã¹ããŒãªãŒã¯ãå¥ã®èšäºã«æãããŠããŸãã ãã®å Žåã httpïŒ//elinux.org/RPi_Easy_SD_Card_Setupã«ããRaspberry Pi Foundationã®ã¬ã€ãã«åŸãããšãã§ããŸãã
ã¹ãããïŒ2ïŒã±ãŒã¹ãå°å·ãäœæããŸãã¯è³Œå ¥ãã
â¢Piãé 眮ããå転/åŸæã¡ã«ããºã ã®ããŒã¹ãäœæããããã«ã3Dããªã³ã¿ãŒã®ããŠãžã³ã°ã¢ãã«ãéçºããŸããã ããã¯ãThingiverseãŠãŒã¶ãŒJosh Campbellã«ããåèšèšããŒãžã§ã³ã§ãã ãã¡ãããããŠã³ããŒãã§ããŸããhttpïŒ//www.thingiverse.com/thingïŒ274468
â¢3Dããªã³ã¿ãŒã«ã¢ã¯ã»ã¹ã§ããªãå Žåã¯ã ShapewaysãŸãã¯ãã®ä»ã®ãªã³ã©ã€ã³ã¹ãã¢ã§ã±ãŒã¹ãè³Œå ¥ã§ããŸãã ãã©ã¹ããã¯ã®ããããèªåã§ç³ä»ãããŸãã
ã¹ãããïŒ3ïŒãµãŒãã¢ãŒã¿ãŒçšã®é»æºã±ãŒãã«ãæºåãã
â¢2æ¬ã®USBã±ãŒãã«ã®ããããããå°ããªMicro-Bãã©ã°ãåãåããŸãã
â¢çŽ2.5ã»ã³ãã®å€éšçµ¶çžäœãåãå€ããŸããå åŽã«4æ¬ã®ã¯ã€ã€ïŒé»ãèµ€ãçœãç·ïŒããããŸãã
â¢é»ãšèµ€ã®ã¯ã€ã€ããçŽ6 mmã®çµ¶çžäœãåãé€ããŸãã ãã«ãã¡ãŒã¿ãŒã䜿çšããŠããããæ¬åœã«ã+ãããã³ãã¢ãŒã¹ãã§ããããšã確èªããŸãã
â¢ã±ãŒãã«ã®ã·ãŒã«ããåãå€ããçœãšç·ã®ã¯ã€ã€ãåæããŸãã
ã¹ããã4ïŒã±ãŒãã«ã®ã¯ãã ä»ã
â¢3ã€ã®ç±åçž®ãã¥ãŒããã«ããããŸãïŒãããã13 mmãš2ã€ã®9 mmã
â¢2ã€ã®ããã«ãžã£ã³ããŒãããã³ããåãåããŸãã
â¢ç±åçž®ã¯ã€ã€ãŒã13 mmççšããã¯ãã ä»ãæã«å·ã€ããªãããã«æ°ã»ã³ãæŒããŸãã
â¢æ éã«åé¢ããäžæ¹ã®ãžã£ã³ãã®äž¡æ¹ã®çããªãŒãç·ã«èµ€ãã¯ã€ã€ã®ç«¯ãå·»ãä»ããŸãã
â¢ã¯ã€ã€ããžã£ã³ãã«ã¯ãã ä»ãããäž¡æ¹ã®ç«¯åã«ãã£ãããšæ¥ç¶ãããŠããããšã確èªããŸãã
â¢é»ãç·ã§ãåãããšãè¡ããŸãã
â¢æ®ãã®ç±åçž®ãã¥ãŒãããžã£ã³ããŒã®åã»ããã«åãä»ãã溶æ¥ç¹ãèŠãããã«å°ãåŒãåºããŸãã é·ããã¥ãŒããæã¡äžããŠãå ã»ã©åæããçœç·ãšç·ç·ãèŠãããã«ããŸãã
â¢ç±åçž®ã
ã¹ããã5ïŒå転ã¢ãŒã¿ãŒã®åãä»ã
â¢ãµãŒãã¢ãŒã¿ãŒã®1ã€ã®ã¯ã€ã€ãŒã倧ããªé·æ¹åœ¢ã®ç©Žã«éããã¢ãŒã¿ãŒãæ¿å ¥ããŸãã åããªããªãå Žåã¯ãå°ããªãã¡ã€ã«ãŸãã¯ãµã³ãããŒããŒã䜿çšããŸãã
â¢ãµãŒãã¢ãŒã¿ãŒãåãä»ãããã2æ¬ã®é·ãããžãç· ããŠã¢ãŒã¿ãŒãåºå®ããŸãã
ã¹ããã6ïŒãã«ãã¢ãŒã¿ãŒãè¿œå ãã
â¢2çªç®ã®ãµãŒãã¢ãŒã¿ãŒã®ã³ãã¯ã¿ãŒãå°ããªé·æ¹åœ¢ã®ç©Žã«éããŸãã ããã§ãã¢ãŒã¿ãŒããã®äž¡æ¹ã®ã¯ã€ã€ãã±ãŒã¹ã®äžå€®ã«å ¥ããŸãã
â¢ãã®ã¢ãŒã¿ãŒã¯ãŸã åãä»ããªãã§ãã ããã
ã¹ãããïŒ7ïŒã¢ãŒã¿ãŒã®æ¥ç¶
â¢ãžã£ã³ããŒç·ã®ç«¯ãããŠãžã³ã°ã®åŽé¢ã®äžžãç©Žã«éããŸãã
â¢é»ãã¯ã€ã€ã®ãªãŒãç·ããè¶è²ã®ã¯ã€ã€ã«å¯Ÿå¿ãããµãŒãã³ãã¯ã¿ã®ç©Žã«æ¥ç¶ããŸãã
â¢èµ€ãã¯ã€ã€ã®ãªãŒãç·ãããªã¬ã³ãžè²ã®ã¯ã€ã€ã«å¯Ÿå¿ãããµãŒãã³ãã¯ã¿ã®ç©Žã«æ¥ç¶ããŸãã
â¢ãžã£ã³ããŒä»ãã®2æ¬ã®çŽ«è²ã®ã¯ã€ã€ãŒãåãåºãããããããé»è²ã®ã¯ã€ã€ãŒã«å¯Ÿå¿ããç©Žã«æ¿å ¥ããŸãã
ã¹ããã8ïŒãã«ãã¢ãŒã¿ãŒãåãä»ãã
â¢ãã«ããµãŒãã¢ãŒã¿ãŒãã2ã€ã®ããªã³ããã«ããŒã®å€§ããæ¹ã®åãç©Žã«æ¿å ¥ããŸãã
â¢ã¢ãŒã¿ãŒã2æ¬ã®é·ãããžã§åºå®ããŸãã
ã¹ãããïŒ9ïŒãµãŒãã¢ãŒã¿ãŒãPiã«æ¥ç¶ãã
â¢2æ¬ã®çŽ«è²ã®ã¯ã€ã€ãRaspberry Piã«æ¥ç¶ããå¿ èŠããããŸãã ãããã¯ãã¢ãŒã¿ãŒã®äœçœ®ãå€æŽããããã®ä¿¡å·ãéä¿¡ãããå¶åŸ¡ç·ã§ãã
â¢å転ã¢ãŒã¿ãŒããã®ä¿¡å·ç·ã¯ã端å23ã«æ¥ç¶ããå¿ èŠããããŸããããã¯ãå€åŽã®åã®8çªç®ã®ç«¯åã§ãã
â¢åŸæã¢ãŒã¿ãŒããã®ä¿¡å·ç·ã¯ã端å22ã«æ¥ç¶ããå¿ èŠããããŸããããã¯ãå åŽã®åã®8çªç®ã®ç«¯åã§ãã
ã¹ãããïŒ10ïŒæåã«é»æºãå ¥ãã
â¢ãã©ãŒãããæžã¿ã®SDã«ãŒããPiã«æ¿å ¥ããã€ãŒãµãããã±ãŒãã«ãæ¥ç¶ããŸãã ãããæåã®OSèµ·åã§ããå ŽåãUSBããŒããŒããããŠã¹ãããã³HDMIã¢ãã¿ãŒãå¿ èŠã«ãªãå ŽåããããŸãã
â¢USBã±ãŒãã«ããã¥ã¢ã«USBå é»åšã«äž¡æ¹ïŒäžæ¹ã¯Raspberryãããããäžæ¹ã¯ã¢ãŒã¿ãŒããïŒå·®ã蟌ã¿ãUSBã±ãŒãã«ãSDã«ãŒãã®é£ã®Raspberry Piã«æ¥ç¶ããŸãã ããã§ãPiããªã³ã«ãªããŸãã
ã¹ãããïŒ11ïŒãµãŒãã¢ãŒã¿ãŒã®ãªã»ãã
â¢Piã«ãªã¢ãŒãã§æ¥ç¶ããã«ã¯ãMacããã³Linuxã«çµã¿èŸŒãŸããŠããSSHãŠãŒãã£ãªãã£ã䜿çšããŸãã ïŒWindowsãŠãŒã¶ãŒã®å ŽåãPuttyãSSHã¯ã©ã€ã¢ã³ããšããŠäœ¿çšã§ããŸããMicrosoftããã€ãã£ãSSHãæäŸããŠãã ããïŒïŒ
â¢ã¿ãŒããã«ãŠã£ã³ããŠã§ãã
ssh pi@picam
ãšå ¥åããEnterããŒãæŒããŸãã æ¥ç¶ã§ããªãå Žåã¯ã
ping picam
è©ŠããŠãã ããã
ping: cannot resolve picam: Unknown host
ãšã©ãŒã¡ãã»ãŒãžãã¢ãã¿ãŒãšããŒããŒããæ¥ç¶ããŠIPã¢ãã¬ã¹ãèŠã€ãïŒifconfigãŠãŒãã£ãªãã£ã䜿çšïŒã次ã«IPã¢ãã¬ã¹ã䜿çšããŠæ¥ç¶ããŸã
ssh pi@192.168.1.10
äŸïŒ
ssh pi@192.168.1.10
â¢æ¥ç¶åŸãpicamãã£ã¬ã¯ããªã«ç§»åããŸã
cd picam
â¢rootãšããŠpicam.pyã¹ã¯ãªãããå®è¡ããŸãïŒ
sudo python picam.py
ã ã¹ã¯ãªããã®åºåã衚瀺ãããã¯ãã§ãã
Using hardware: PWM
PW increments: 10us
Initializing channel 0...
add_channel_pulse: channel=0, gpio=23, start=0, width=154
init_gpio 23
add_channel_pulse: channel=0, gpio=22, start=0, width=154
init_gpio 22
* Running on 0.0.0.0:80/
â¢ã¹ã¯ãªãããå®è¡ããåŸãäž¡æ¹ã®ãµãŒããéå§äœçœ®ã«æ»ãæ§åãèãå¿ èŠããããŸãã
â¢Ctrl + CãæŒããŠãããã°ã©ã ãçµäºããŸãã ãã®åŸã
sudo shutdown -h now
ãšå ¥åããŠPiãã·ã£ããããŠã³ããŸãã ã·ã£ããããŠã³ããåŸïŒéåžžçŽ30ç§ããããŸãïŒãRaspberryããé»æºã±ãŒãã«ãå€ããŸãã
ã¹ããã12ïŒãã¬ãŒã ã¯ãŒã¯ãã€ã³ã¹ããŒã«ãã
â¢ãµãŒãã¢ãŒã¿ãŒããŒãäœçœ®ã«ãªã£ãã®ã§ããããã«ãã¬ãŒã ãåãä»ããããšãã§ããŸãã 倧ãããã®ããå§ããŠãããŒã¿ãªãŒã¢ãŒã¿ãŒã®ãã¬ãŒã ããå§ããŸãã é·èŸºãã·ã£ãŒã·ãšå¹³è¡ã«ãªãããµãŒãã¢ãŒã¿ãŒãPiã®USBããã³ã€ãŒãµãããããŒããšåãåŽã«ãªãããã«é 眮ããŸãã ãã¬ãŒã ãå°ããªããžã§åºå®ããŸãã
â¢ã¹ã¯ãªãŒããåŸæãã¬ãŒã ã®äžã®ç©Žã«éããŸãã æ¥ç¶ãããŸã§äž¡ç«¯ãäžãåããŠããå¿ èŠããããŸãã
â¢åŸæãã¬ãŒã ãã¹ã€ã³ã°ãã¬ãŒã ã®ãµãŒãã¢ãŒã¿ãŒã«åãä»ããŸãã å°ããªããžã§ç· ããŸãã
ã¹ããã13ïŒã«ã¡ã©ã®åãä»ã
â¢ã«ã¡ã©ããã¬ãŒã ã«åãä»ããã¿ã€ã§åºå®ããŸãã ããžã®é ã2çªç®ã®ãã¬ãŒã ã«è§Šããªãããã«ãã£ãããšç· ããŠãã ããã
â¢ã«ã¡ã©ãUSBããŒãã®1ã€ã«æ¥ç¶ããSDã«ãŒããé»æºã±ãŒãã«ãã€ãŒãµãããã±ãŒãã«ãæ¿å ¥ããŸãã
ã¹ããã14ïŒã«ã¡ã©ã®èµ·å
â¢PiãããŠã³ããŒãããããSSHçµç±ã§åæ¥ç¶ããŸãã
â¢æåã«ããããªã®ã¹ããªãŒãã³ã°ã«äœ¿çšããããã°ã©ã ãå«ããã©ã«ããŒã«ç§»åããŸãã ã¿ãŒããã«ã§æ¬¡ã®ããã«å ¥åããŸãïŒ
cd ./mjpg-streamer/mjpg-streamer
â¢ã³ãã³ã
./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so -w ./www" &
mjpg-streamerãå®è¡ããŸãã
ãšã©ãŒã衚瀺ãããŸãããæªäœ¿çšã®ã¢ãžã¥ãŒã«ã«é¢é£ããŠããŸãã Webã«ã¡ã©ã®LEDãç¹ç¯ããããã°ã©ã åºåã®æåŸã«æ¬¡ã®ããã«è¡šç€ºãããŸãã
o: www-folder-path...: ./www/
o: HTTP TCP port.....: 8080
o: username:password.: disabled
o: commands..........: enabled
â¢Ctrl + CãæŒããŠãã¿ãŒããã«ã«æ»ããŸãã
cd
ãšå ¥åããŠEnterããŒãæŒããã«ãŒããã£ã¬ã¯ããªã«æ»ããŸãã
ã¹ãããïŒ15ïŒå€èŠ³
â¢ãã¹ãŠãçµã¿ç«ãŠãããŠåäœããããã«ãªã£ãã®ã§ãä»åºŠã¯ããçš®ã®å€èŠ³ãäžããŸãã
â¢ã¿ãŒããã«ã§ãpicamãã£ã¬ã¯ããªã«æ»ããŸã
cd picam
PiCamã¢ããªã±ãŒã·ã§ã³ãå®è¡ããŸãïŒ
sudo python picam.py
â¢ã¢ããªã±ãŒã·ã§ã³ãèµ·åãããã次ã®ãã©ãŠã¶ã«ç§»åããŸã
picam
picam
ã ã«ã¡ã©ã®ãã¿ã³ãšã³ã³ãããŒã«ãã¿ã³ã衚瀺ãããŸãã æŒããã³ã«ã«ã¡ã©ã10ºå転ããŸãã
â¢ã€ã³ã¿ãŒãããããã«ã¡ã©ã«ã¢ã¯ã»ã¹ããã«ã¯ãã«ãŒã¿ãŒã§ããŒã転éãèšå®ããå¿ èŠããããŸãã 1ã€ã®ããŒããããŒã80ïŒWebããŒãžã®å ŽåïŒã«è»¢éãã1ã€ã®ããŒããããŒã8080ïŒãããŒããã£ã¹ããããªã®å ŽåïŒã«è»¢éããå¿ èŠããããŸãã Piã§ã®ããŒã転éãšãµãŒããŒèµ·åã®è©³çŽ°ã«ã€ããŠã¯ã httpïŒ//raspberrywebserver.com/serveradmin/get-your-raspberry-pi-web-site-on-line.htmlãã芧ãã ãã ã ãã ãããã®å Žåãã«ã¡ã©ã¯äŸµå ¥è ããä¿è·ãããŠããªãããšãå¿ããªãã§ãã ãããã»ãã¥ãªãã£ã®åé¡ãäœããã®æ¹æ³ã§è§£æ±ºããå¿ èŠããããŸãã
æåŸã«
ãã®ãªã¢ãŒãWebã«ã¡ã©ãããžã§ã¯ãã«Wi-Fiãè¿œå ããããå±å€ã§äœ¿çšããããã«èåæ§ã®ããã±ãŒã¹ã䜿çšããããæ¬ã®ãããªæ®éã®ãã®ã§ã«ã¡ã©ãé ãããšãã§ããŸãã
å®éšïŒ