From b48092da6bf6806b2821f63a30a503b5c49d7d21 Mon Sep 17 00:00:00 2001 From: ictar Date: Fri, 23 Sep 2016 09:41:21 +0800 Subject: [PATCH 1/2] update --- raw/AI challenge in 78 lines of Python.md | 100 --- ...rry Pi - Building a Digital Photo Frame.md | 688 +++++++++--------- 2 files changed, 336 insertions(+), 452 deletions(-) delete mode 100644 raw/AI challenge in 78 lines of Python.md diff --git a/raw/AI challenge in 78 lines of Python.md b/raw/AI challenge in 78 lines of Python.md deleted file mode 100644 index 074aa64..0000000 --- a/raw/AI challenge in 78 lines of Python.md +++ /dev/null @@ -1,100 +0,0 @@ -原文:[AI challenge in 78 lines of Python](http://kootenpv.github.io/2016-09-07-ai-challenge-in-78-lines) - ---- - - -## The challenge (Tron) - -Tron is a multiplayer game in which 2-4 players play a snake-like game. Every step one makes, the board gets filled by one block. Whenever a player has nowhere to go, they lose. Last man standing. See a video below of 4 bots in action on Codingame: - - - -I will explain the intuition and the implemented algorithms for a bot reaching 133/3131 as of 9 September 2016, using only [78 lines of PEP8 style guide code](https://gist.github.com/kootenpv/3d20fbc2e8cf37eaa045f8090a0216a7). In comparison, [there are bots](https://github.com/search?utf8=%E2%9C%93&q=codingame+tron) with thousands of lines of code. - -## Algorithms - -We will have to consider how good each of the possible moves are from any given position. After having played around with the game, a very simple but efficient idea came to mind. What if we consider being the closest to as many tiles as possible (in comparison to our enemies) to be the most important? - -That is, for each move (UP/DOWN/RIGHT/LEFT), we can consider how many tiles we are the closest in comparison to the enemy. Ask the question for each tile: who would be here first if racing with the enemies? This difference might be small when comparing UP/DOWN/LEFT/RIGHT in a relatively unimportant situation, but you’ll see that when there is a dead end, the score drops for the move that steps into this dead end. You could do this without taking into account the enemies, but it gets stronger when you implement enemies taking turns too (like in a real game!). - -This is done by simulation: “virtually” expand each round in _all_ directions – for each bot in turn. Whenever there is an empty spot, they obtain it, and will expand from this spot in the next virtual round. It will stop when there have been no untouched tiles obtained by any of the players (indicating either the board to be filled or those parts of the map unreachable). - -Here is a visual aid: - -``` -# o: visited by player 0 in previous turns -# x: visited by player 1 in previous turns -# 0: visited by player 0 this turn -# 1: visited by player 1 this turn -# a: turn for player 0 -# b: turn for player 1 - -# Start: -0) -x . . . . . -. . . . . . -. . . o . . -. . . . . . - -# Let's compare 2 examples: -1a) UP 1a) DOWN -x . . . . . x . . . . . -. . . 0 . . vs . . . . . . -. . . o . . . . . o . . -. . . . . . . . . 0 . . - -# Example 0 went UP: -1b) 2a) 2b) 3a) 3b) 4a) end -x 1 . . . . x x . 0 . . x x 1 o . . x x x o 0 . x x x o o . x x x o o 0 x x x o o o -1 . . o . . x . 0 o 0 . x 1 o o o . x x o o o 0 x x o o o o x x o o o o x x o o o o -. . . o . . . . . o . . 1 . . o . . x . 0 o 0 . x 1 o o o . x x o o o 0 x x o o o o -. . . . . . . . . . . . . . . . . . . . . . . . 1 . . . . . x . 0 0 0 . x x o o o o - -# Example 0 went DOWN: -1b) 2a) 2b) 3a) 3b) 4a) end -x 1 . . . . x x . . . . x x 1 . . . x x x . . . x x x 1 . . x x x x . . x x x x x x -1 . . . . . x . . . . . x 1 . . . . x x . . . . x x 1 . . . x x x . 0 . x x x x o o -. . . o . . . . . o . . 1 . . o . . x . 0 o 0 . x 1 o o o . x x o o o 0 x x o o o o -. . . o . . . . 0 o 0 . . . o o o . . 0 o o o 0 1 o o o o o x o o o o o x o o o o o -``` - -We can observe here that going UP is more beneficial to player 0: he will be closest to 15 tiles, compared to 11 tiles if he would have chosen to go DOWN. - -This automatically makes the bot rather smart: it really seems like it is pursuing the enemy to try and lock them up. - -In actuality, calculating the evaluation score for which move is best is using variations on this closeness: - -* number of tiles we are closest to (higher=better) -* number of tiles enemies are closest to (lower=better) -* summed distance for reaching each tile for all enemies (higher=better) - -``` -# simple weighting, importance: num_my_tiles > num_enemy_tiles > enemies_dist -return sum([num_my_tiles * 10000000, num_enemy_tiles * -100000, enemies_dist]) -``` - -It’s a fun excercise to see what happens when you change these numbers, and perhaps even add your scoring metrics. - -## Scripts - -I have provided 3 scripts: one which contains only the [neccessary 78 lines](https://gist.github.com/kootenpv/3d20fbc2e8cf37eaa045f8090a0216a7), one which contains [logging on the codingame website](https://gist.github.com/kootenpv/af270c0a9f4b5c84dadbe6494b77c1c0) which provides more insight in what is going on, and the last one [contains comments](https://gist.github.com/kootenpv/32d1a0d97e391392dec10a83070336f8) for most of the lines to better understand how the current solution has been implemented. - -## Improving the current solution - -There is still a lot that could be improved: - -* Assumes bots try to optimize space-gain; this is suboptimal (conservative) with multiple players and limited options -* Consider the disappearance of enemies upon their deaths -* Consider keeping an escape route (related to enemy death) -* Implement in faster language to be able to consider even more turns ahead -* Improve evaluation scoring -* Consider possible enemy moves ahead, and choose something that is good for us: - - * Implement minimax - * Alpha-beta pruning (don’t keep considering moves that we know lead to bad results) -* Use the time budget (return best move when time is almost up, ~98ms) - -## Main message - -The actual main message here is that intuition can do very well: while many people have submitted overcomplicated code, only considering a single move ahead based on closeness does really well already. - diff --git a/raw/Getting started with Raspberry Pi - Building a Digital Photo Frame.md b/raw/Getting started with Raspberry Pi - Building a Digital Photo Frame.md index 74b2205..4492efb 100644 --- a/raw/Getting started with Raspberry Pi - Building a Digital Photo Frame.md +++ b/raw/Getting started with Raspberry Pi - Building a Digital Photo Frame.md @@ -1,20 +1,57 @@ -Ô­ÎÄ£º[Getting started with Raspberry Pi - Building a Digital Photo Frame](https://paulstamatiou.com/getting-started-raspberry-pi/) +原文:[Getting started with Raspberry Pi - Building a Digital Photo Frame](https://paulstamatiou.com/getting-started-raspberry-pi/) --- -** What you can do with a tiny $35 computer and how I built a digital photo frame ** - -In early 2012 an intriguing single-board computer with a weird name hit the market. For the low price of $35, you could get a fully functioning computer that could run a real operating system. - -It was called the Raspberry Pi and it was the brainchild of a UK charity called the Raspberry Pi Foundation. They saw the need for an affordable computer after seeing a consistent drop in students applying to study computer science. - -Well it turns out this tiny and cheap fully-functional computer had a much larger audience than anticipated. Multiple models have been created since, including the $5 Pi Zero, and **over 9 million Raspberry Pis have been sold**. - -This is a long post so I more than likely made some errors along the way. Feel free to [let me know on Twitter](http://twitter.com/Stammy "Paul Stamatiou on Twitter"), thanks! - -(这里要插入目录) - - +** 用一个小小的$35的电脑,你可以做什么,以及我是如何构建一个电子相框的** + +2012年年初,一个名字奇怪的有趣的单板计算机投入了市场。仅需低廉的$35,你就可以获得一个可以运行真正操作系统的全功能计算机。 + +这就是所谓的树莓派(Raspberry Pi),它是一个名为树莓派基金会的英国慈善机构的心血结晶。在看到申请学习计算机科学的学生人数持续下降后,他们看到了对负担得起的计算机的需求。 + +而事实证明,这个微小而廉价的全功能计算机有一个比预期大得多的受众。自创建以来,已经有多个型号了,包括$5的Pi Zero,另外,**已经售出了超过9百万的树莓派**。 + +这是一篇很长的博文,因此,一路上我更有可能犯一些错。随时[在Twitter上知会我](http://twitter.com/Stammy "Paul Stamatiou on Twitter"),谢谢! + + + +- [它是什么?](#它是什么?) + - [这就像一块Arduino吗?并不是。](#这就像一块arduino吗?并不是。) + - [电量消耗](#电量消耗) + - [用于教育的Pi](#用于教育的pi) + - [Pi社区和资源](#pi社区和资源) +- [有了Pi,你能做什么?](#有了pi,你能做什么?) + - [灰常多。](#灰常多。) + - [为什么我会有一个Pi?](#为什么我会有一个pi?) + - [所以,你可以拿它做什么?](#所以,你可以拿它做什么?) + - [Pi不大适合做什么?](#pi不大适合做什么?) +- [开始](#开始) + - [操作系统安装](#操作系统安装) + - [你需要什么](#你需要什么) + - [零部件清单](#零部件清单) + - [Optional](#optional) + - [什么操作系统?](#什么操作系统?) + - [Imaging the microSD card](#imaging-the-microsd-card) + - [Benchmarking, overclocking and cooling](#benchmarking-overclocking-and-cooling) + - [Heatsinks](#heatsinks) +- [使用I/O引脚](#使用io引脚) + - [Pi electronics 101](#pi-electronics-101) + - [Parts](#parts) + - [Setup & powering an LED](#setup--powering-an-led) + - [Control the LED](#control-the-led) + - [Using a transistor](#using-a-transistor) + - [Use a relay](#use-a-relay) + - [What's next?](#whats-next) +- [做一个数码相框](#做一个数码相框) + - [with a 10" 1920x1200 display](#with-a-10-1920x1200-display) + - [We're going to need a display](#were-going-to-need-a-display) + - [Mounting the display](#mounting-the-display) + - [Mounting the Pi](#mounting-the-pi) + - [Displaying the photos](#displaying-the-photos) + - [Turning the display off](#turning-the-display-off) + - [Wiring up a button and fan](#wiring-up-a-button-and-fan) + - [What's next with the Pi Frame?](#whats-next-with-the-pi-frame) + + [![](https://turbo.paulstamatiou.com/assets/gray-squircles-loader-3.gif)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09364-1500.jpg) @@ -29,51 +66,47 @@ This is a long post so I more than likely made some errors along the way. Feel f [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00108-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00108-1500.jpg) +## 它是什么? +###### 这就像一块Arduino吗?并不是。 -###### Is this like an Arduino? No. +虽然我听说Pi多年了,但是我从没好好看看它,而精神上只是把它看成给爱好者玩的某种类型的Arduino开发板。我真是大错特错了。 -While I have been hearing about the Pi for years, I never really took a good look at it and mentally just wrote it off as some kind of Arduino development board for enthusiasts to hack on. I couldn¡¯t have been more wrong. +Arduino是一个开源的微控制器,有I/O引脚来控制其他电子产品。另一方面,Pi 仍然有那些I/O引脚 (GPIO),但还有一个闭源的ARM **S**ystem **o**n a **C**hip (SoC)。然而,Arduino更适合连接到立即可用的模拟传感器,而Pi最适合那些使用I2C或者SPI通信的串行口传感器。 -The Arduino is an open-sourced microcontroller with I/O pins to control other electronics. The Pi on the other hand still has those I/O pins (GPIO) but also has a closed-source ARM **S**ystem **o**n a **C**hip (SoC). However, the Arduino is better suited at connecting to analog sensors out of the box whereas the Pi works best with serial interface sensors using I2C or SPI communication. +最快的Arduino运行在84MHz,而Pi 3运行在**1.2GHz**。 -The fastest Arduino runs at 84MHz while the Pi 3 runs at **1.2GHz**. - -So what do I mean when I say the Pi is a fully-functional computer? Surely something that cheap can¡¯t really be usable.. it is. Along with that **64-bit 1.2GHz quad-core CPU** the Model 3 B features **1GB of RAM, 802.11n Wi-Fi and Bluetooth** along with a myriad of ports: 4x USB, HDMI, microSD and more. That allows it to run operating systems optimized for ARM chipsets, and there are quite a few these days: +所以,当我说Pi是一个全功能的计算机时,我想表达什么呢?当然,那么便宜的东西实际上并不可用 …… 它是。装备**64位 1.2GHz四核CPU**,Model 3 B拥有**1GB内存,802.11n标准的Wi-Fi和Bluetooth**,以及大量的端口:4个USB,HDMI,microSD等等。这允许它运行为ARM芯片优化的操作系统,而且目前有相当多可用的操作系统: * [Ubuntu MATE](https://ubuntu-mate.org/raspberry-pi/ "Ubuntu MATE for the Raspberry Pi 2 and Raspberry Pi 3") -* [Raspbian](https://www.raspbian.org/ "Raspbian is a free operating system based on Debian optimized for the Raspberry Pi hardware.") and Raspbian Lite (Debian optimized for Pi) -* [OSMC](https://osmc.tv/2016/02/raspberry-pi-3-announced-with-osmc-support/ "Raspberry Pi 3 announced with OSMC support") and [OpenELEC](http://openelec.tv/) (media center OSes) -* [Pidora](http://pidora.ca/ "Pidora is a Fedora Remix optimized for the Raspberry Pi computer.") (Fedora for Pi) -* [Arch Linux ARM](https://archlinuxarm.org/platforms/armv8/broadcom/raspberry-pi-3 "Arch Linux, a lightweight and flexible Linux? distribution that tries to Keep It Simple.") (Arch optimized for ARM computers) -* [Chromium OS for Single Board Computers](http://www.chromiumosforsbc.org/) (You might know it as Chrome OS as used on Chromebooks) -* [Windows 10 IoT Core](https://developer.microsoft.com/en-us/windows/iot/win10/noobs) (A [Windows 10 variant](https://developer.microsoft.com/en-us/windows/iot) made for Internet of Things uses) -* Coming soon: [Official Android support](http://arstechnica.com/gadgets/2016/05/google-to-bring-official-android-support-to-the-raspberry-pi-3/) from Google - -For comparison the smaller $5 Raspberry Pi Zero (v1.3 and camera module shown below) has a single-core **1GHz CPU and 512MB of RAM** ¡ª still enough to run these operating systems too ¡ª along with its microSD slot, a mini HDMI and two micro USB ports. However, it lacks onboard networking and you'll need a USB dongle with USB Wi-Fi if you'd like Internet access. +* [Raspbian](https://www.raspbian.org/ "Raspbian is a free operating system based on Debian optimized for the Raspberry Pi hardware.")和Raspbian Lite (用于Pi的优化过的Debian) +* [OSMC](https://osmc.tv/2016/02/raspberry-pi-3-announced-with-osmc-support/ "Raspberry Pi 3 announced with OSMC support")和[OpenELEC](http://openelec.tv/) (媒体中心操作系统) +* [Pidora](http://pidora.ca/ "Pidora is a Fedora Remix optimized for the Raspberry Pi computer.") (用于Pi的Fedora) +* [Arch Linux ARM](https://archlinuxarm.org/platforms/armv8/broadcom/raspberry-pi-3 "Arch Linux, a lightweight and flexible Linux? distribution that tries to Keep It Simple.") (为ARM电脑优化的Arch) +* [用于单板计算机的Chromium OS](http://www.chromiumosforsbc.org/) (你可能知道它,它作为Chrome OS,用于Chromebooks) +* [Windows 10 IoT Core](https://developer.microsoft.com/en-us/windows/iot/win10/noobs) (一个为物联网提出的[Windows 10变体](https://developer.microsoft.com/en-us/windows/iot)) +* 即将推出:[官方Android支持](http://arstechnica.com/gadgets/2016/05/google-to-bring-official-android-support-to-the-raspberry-pi-3/) from Google +作为对比,更小的$5的树莓派Zero (如下所示的v1.3和照相机模块)拥有单核**1GHz CPU和512MB内存** —— 仍然足以运行以上操作系统 —— 带有microSD插槽,一个迷你HDMI和两个微型USB端口。然而,它缺少板载网络,因此如果你想上网,那么仍需要一个带有USB Wi-Fi的USB上网卡。 [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09417-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09417-1500.jpg) [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09429-750.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09429-1500.jpg) - -There are lots of Raspberry Pi competitors. Some are more powerful and more expensive. There's the [PINE64](https://www.pine64.com/ "A powerful 64-Bit expandable single board computer ¨C Starting at just $15") with 2GB of RAM and Gigabit Ethernet, the 2GHz quad-core Odroid XU4 with USB 3.0 and Gigabit Ethernet as well as the blatant Raspberry Pi clone the Banana Pi[1](#footnote-1) with its SATA connection. However, nothing quite beats **the Pi's massive developer and enthusiast community**. This makes it easy to find support for projects you're building or use Pi-specific software projects. - -###### Energy consumption +有许多树莓派的竞争者。有些功能更强大,更贵。[PINE64](https://www.pine64.com/ "A powerful 64-Bit expandable single board computer ¨C Starting at just $15")带有2GB内存和千兆以太网,2GHz的四核Odroid XU4带USB 3.0和千兆以太网,以及明目张胆克隆树莓派的香蕉派[1](#footnote-1)带有SATA连接。然而,它们都无法打败**Pi大大规模开发者和爱好者社区**。这使得它容易找到你正构建的项目的支持,或者使用Pi特有的软件项目。 -Oh and this thing sips electricity! Unlike larger computers where you may need to think twice about running it 24/7, **Raspberry Pis cost almost nothing to run**. This makes the Pi remarkably attractive as an always-on linux server or base for your connected hardware projects. +###### 电量消耗 -Consumption depends on the model and there are ways to reduce consumption even further[2](#footnote-2), but a Pi 3 Model B will draw around 1.4W at idle and up to 3.7W at load. +噢,这个玩意不怎么吃电!不像更大的计算机,对于24*7运行它,你也许要三思而行,**树莓派运行成本基本没有**。这使得将Pi作为永远在线的Linux服务器或者连接硬件的项目的基础极具吸引力。 -In the state of California where electricity costs around 15 cents per kWh, running a Pi 3 at load for a full year would cost just $5 (and just $2 per year at idle). A Pi Zero will cost signicantly less as it runs closer to 0.7W at load. For comparison, my [4 disk Synology NAS](https://paulstamatiou.com/storage-for-photographers-part-2/ "Storage for photographers Part 2") probably costs around $3.5 _per month_ to run. +消耗取决于幸好,并且有很多方法可以更进一步的减少消耗[2](#footnote-2),但一块Pi 3 Model B闲时大概消耗1.4W,并在负载的适合上升到3.7W -The diminuitive Pi power needs opens the door for interesting mobile and embedded uses as it can be powered by a normal USB battery pack for a good while. +在加利福尼亚州,电费大概是每千瓦15美分,一整年负载运行一块Pi 3只需花费$5 (而闲时则只需每年$2)。一块Pi Zero将明显花费更少,因为它在负载时运行接近0.7W。为了便于比较,我的[4个磁盘的Synology NAS](https://paulstamatiou.com/storage-for-photographers-part-2/ "Storage for photographers Part 2")的运行大概花费_每月_$3.5。 -###### Pi for education +微小的Pi电力需求为好玩的移动和嵌入式应用打开了大门,因为它可以通过一个正常的USB电池组供好一会电。 -Before it became insanely popular with developers and hobbyists, the Pi was intended to be an affordable computer for education. That effort still goes on with the Raspberry Pi foundation trying to get Pis into schools and now there are new efforts like the [Kano computer kit](http://us.kano.me/) and the [Pi-Top](http://pi-top.com/ "Pi-Top"), both the result of successful crowdfunding campaigns. +###### 用于教育的Pi - +在它在开发者和爱好者之中疯狂流行之前,Pi意欲成为教育负担得起的电脑。这种努力仍在继续,树莓派基金会试图把Pi带进学校,现在,有了新的努力,像[Kano电脑包](http://us.kano.me/)和[Pi-Top](http://pi-top.com/ "Pi-Top"),它们都是成功众筹的结果。 [![](https://turbo.paulstamatiou.com/assets/gray-squircles-loader-3.gif)](https://turbo.paulstamatiou.com/uploads/2016/05/pstam_pitop_kits.jpg) @@ -81,98 +114,95 @@ Before it became insanely popular with developers and hobbyists, the Pi was inte [![](https://turbo.paulstamatiou.com/assets/gray-squircles-loader-3.gif)](https://turbo.paulstamatiou.com/uploads/2016/05/pstam_kano_pc_photo.jpg) - - +鉴于这些原因,对于Pi,有相当对面向教育的软件:用于音乐的[Sonic Pi](https://www.raspberrypi.org/learning/getting-started-with-sonic-pi/worksheet/),[Scratch](https://www.raspberrypi.org/learning/physical-computing-with-scratch/worksheet/ "Physical computing with Scratch"),[Processing](https://www.raspberrypi.org/learning/introduction-to-processing/worksheet/)和[Python](https://www.raspberrypi.org/learning/python-intro/),[Minecraft Pi](https://www.raspberrypi.org/learning/getting-started-with-minecraft-pi/worksheet/),[还有更多](https://www.raspberrypi.org/resources/)。当然,很多这些都可以用任何一台计算机来完成,但是Pi的价位使得它更易获得。 -Given these roots, there is quite a bit of education oriented software out there for the Pi: [Sonic Pi](https://www.raspberrypi.org/learning/getting-started-with-sonic-pi/worksheet/) for music, [Scratch](https://www.raspberrypi.org/learning/physical-computing-with-scratch/worksheet/ "Physical computing with Scratch"), [Processing](https://www.raspberrypi.org/learning/introduction-to-processing/worksheet/) and [Python](https://www.raspberrypi.org/learning/python-intro/), [Minecraft Pi](https://www.raspberrypi.org/learning/getting-started-with-minecraft-pi/worksheet/) and [much more](https://www.raspberrypi.org/resources/). Sure, a lot of this can be done with any computer but the price point of the Pi makes it even more accessible. +###### Pi社区和资源 -###### Pi community and resources +一旦你决定好了开始玩树莓派,那么你会很高兴的知道你并不孤单。有大量的Pi hacker社区来帮助你设想、构建和调试你的项目,并且有丰富的Pi特定的硬件来助力你的项目。 -Once you've decided to start tinkering around with a Raspberry Pi, you'll be happy to know you're not alone. There's a large community of Pi hackers to help you ideate, build and debug your projects, along with an abundance of Pi-specific hardware to bootstrap your projects. +* [树莓派subreddit](http://reddit.com/r/raspberry_pi/) +* [树莓派论坛](https://www.raspberrypi.org/forums/) +* [MagPi杂志](https://www.raspberrypi.org/magpi/) +* [树莓派eLinux维基](http://elinux.org/RPi_Hub) +* [adafruit](https://blog.adafruit.com/category/raspberry-pi/) - 一个在线电子商店,它有一个博客,上面有大量关于Pi的新闻和教程 +* [Pi故障排除指南](http://elinux.org/R-Pi_Troubleshooting) -* [Raspberry Pi subreddit](http://reddit.com/r/raspberry_pi/) -* [Raspberry Pi forums](https://www.raspberrypi.org/forums/) -* [MagPi Magazine](https://www.raspberrypi.org/magpi/) -* [Raspberry Pi eLinux wiki](http://elinux.org/RPi_Hub) -* [adafruit](https://blog.adafruit.com/category/raspberry-pi/) - an online electronics store with a blog featuring lots of Pi news and tutorials -* [Pi troubleshooting guide](http://elinux.org/R-Pi_Troubleshooting) +## 有了Pi,你能做什么? +##### 灰常多。 -#### What can you do with a Pi? +#### 为什么我会有一个Pi? -### So much. +在我看到了我一个朋友使用树莓派Zero来用他的Amazon Echo控制Sonos设置,我变得对Pi好奇起来。鉴于我有一个[Sonos系统](https://paulstamatiou.com/stuff-i-use/ "Stuff I use"),我想要用相同的设置启动。虽然我可以很容易的只把必要的节点服务器放在我的NAS上,但是我更想让那个盒子隐藏在我的路由器背后以获得安全性。我无所谓为一个简单的基于Pi的服务器转发端口。 +那周,我订了一个Pi 3 Model B,并[设置了我自己的Sonos/Echo集成](https://github.com/rgraciano/echo-sonos "Amazon Echo integration with Sonos") —— 虽然我原本想要那个小小的Pi Zero,但它在那时已经售罄了。 + -#### Why did I get a Pi? - -I became Pi-curious after I had seen a friend using a Raspberry Pi Zero to control his Sonos setup with his Amazon Echo. Given that I have a [Sonos system](https://paulstamatiou.com/stuff-i-use/ "Stuff I use") I wanted to set up the same to start. While I could easily just host the necessary node server on my NAS, I would prefer to keep that box invisible behind my router for security. I had no qualms forwarding ports for a simple Pi-based server. - -I ordered a Pi 3 Model B that week and [setup my own Sonos/Echo integration](https://github.com/rgraciano/echo-sonos "Amazon Echo integration with Sonos") ¡ª while I had originally wanted the tiny Pi Zero, it was sold out everywhere at the time. + - - +然后,我开始思考,用Pi还能做什么…… -Then I started thinking about what else could be done with a Pi... +#### 所以,你可以拿它做什么? -#### So what can you do with it? +第一个以及最明显的路:**把它当成一台电脑使用**。它绝对不是你房子里最快的机器,但它可以很好的完成基本任务。虽然你可以将它挂到一个全尺寸鼠标、键盘和桌面显示上,但是对于更小的展示,还有大量的选择,包括触摸屏,这使得Pi适合各种项目。 -There's the first and most obvious route: **use it as a computer**. It definitely won't be the fastest machine in your house but it can accomplish basic tasks well. While you can hook it up to a full size mouse, keyboard and desktop display, there are tons of options for smaller displays, including touch screens, that make the Pi ideal for various projects. +但是请记住,它有那些I/O引脚。以Pi为中心,无数的硬件改装和物联网创意可以很容易地成为现实: -But remember how it has all those I/O pins? There are infinite hardware hacking and internet of things ideas that can easily come to life with the Pi at the center: +* **数码相框** -* **Digital photo frame** + 数码相框并非新玩意;Digital photo frames are nothing new; you probably remember the crappy versions years ago where you stuck an SD card in to play your photos. Well times have changed and tons of connected digital photo frames are on the market now. There's the $299 [Electric Objects EO1](https://www.electricobjects.com/), the $999+ [Klio](http://www.klioart.com/) and the $445+ [Meural digital canvas](https://meural.com/). So now lots of folks have turned to the Pi to build their own versions, including me (at the very bottom of this post!). - Digital photo frames are nothing new; you probably remember the crappy versions years ago where you stuck an SD card in to play your photos. Well times have changed and tons of connected digital photo frames are on the market now. There's the $299 [Electric Objects EO1](https://www.electricobjects.com/), the $999+ [Klio](http://www.klioart.com/) and the $445+ [Meural digital canvas](https://meural.com/). So now lots of folks have turned to the Pi to build their own versions, including me (at the very bottom of this post!). + ![digital picture frame](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00138-750.jpg) -
![digital picture frame](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00138-750.jpg) -* **Smart/Magic Mirror** +* **魔镜** Smart mirrors are probably the most popular Raspberry Pi project in existence right now. They bring memories of futuristic movie interfaces and are relatively simple to build, especially with a large community developing them and [releasing software](https://github.com/MichMich/MagicMirror "Magic Mirror 2 the open source modular smart mirror platform") to drive them. In a nutshell: put a display running a full-page browser with a dark UI displaying info like news, weather or whatever is important to you behind a 2-way mirror and hang it in your house somewhere. There are lots of guides about this online: [1](https://www.reddit.com/r/raspberry_pi/comments/3oktfu/magic_mirror_how_to/ "Magic Mirror how to"), [2](http://michaelteeuw.nl/post/83188136918/magic-mirror-part-v-installing-the-raspberry-pi "Magic Mirror: Part V - Installing the Raspberry Pi"), [3](http://innate.cc/ "Smart Mirror Mini Form Factor Update"), [4](http://blog.dylanjpierce.com/raspberrypi/magicmirror/tutorial/2015/12/27/build-a-magic-mirror.html), [5](https://medium.com/@maxbraun/my-bathroom-mirror-is-smarter-than-yours-94b21c6671ba). -
- ![smart/magic mirror](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-pi-smart-mirror.jpg) - ![smart/magic mirror](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-max-smart-mirror.jpg) -
Probably the [most popular magic mirror build](https://medium.com/@maxbraun/my-bathroom-mirror-is-smarter-than-yours-94b21c6671ba). This one was done with a Fire TV Android stick since the creator couldn't find a Pi Zero in stock at the time. Same concept though.
- * Roll your own motion detecting Dropcam [with motionEyeOS](https://github.com/ccrisan/motioneyeos/wiki "motionEyeOS is a Linux distribution that turns a single-board computer into a video surveillance system.") -* [Create an alarm clock](https://georgecushen.com/spotify-alarm-clock-raspberry-pi-ubuntu-linux/ "Wake Up with Spotify Alarm Clock for Raspberry Pi") that plays music from Spotify + ![smart/magic mirror](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-pi-smart-mirror.jpg) + ![smart/magic mirror](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-max-smart-mirror.jpg) + Probably the [most popular magic mirror build](https://medium.com/@maxbraun/my-bathroom-mirror-is-smarter-than-yours-94b21c6671ba). This one was done with a Fire TV Android stick since the creator couldn't find a Pi Zero in stock at the time. Same concept though. + +* Roll your own motion detecting Dropcam [with motionEyeOS](https://github.com/ccrisan/motioneyeos/wiki "motionEyeOS is a Linux distribution that turns a single-board computer into a video surveillance system.") +* [创建一个闹钟](https://georgecushen.com/spotify-alarm-clock-raspberry-pi-ubuntu-linux/ "Wake Up with Spotify Alarm Clock for Raspberry Pi") that plays music from Spotify * Setup your own VPN server with [PiVPN (OpenVPN)](http://www.pivpn.io) for when you're not at home and connect to unsecure coffee shop Wi-Fi networks.* Build your own [portable Pi Desktop computer](https://learn.adafruit.com/10-raspberry-pi-desktop) or [tablet](http://francescopochetti.com/pipad-build-tablet-raspberry-pi/): -
- ![Portable Pi Desktop computer](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-adafruit-pidesktop.jpg) - ![Portable Pi tablet computer](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-pi-tablet-project.jpg) - * [Build a document scanner](http://www.instructables.com/id/Raspberry-Pi-Based-Document-Scanner-With-Automatic/ "Raspberry Pi Document Scanner With Automatic Upload to Dropbox") that automatically uploads to Dropbox + ![Portable Pi Desktop computer](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-adafruit-pidesktop.jpg) + ![Portable Pi tablet computer](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-pi-tablet-project.jpg) +* [Build a document scanner](http://www.instructables.com/id/Raspberry-Pi-Based-Document-Scanner-With-Automatic/ "Raspberry Pi Document Scanner With Automatic Upload to Dropbox") that automatically uploads to Dropbox * Home theater PC with OpenElec, OSMC, Kodi, [RasPlex](https://github.com/RasPlex/RasPlex/releases "Rasplex is a community driven port of Plex Home Theater for the Raspberry Pi") or even [Android TV](https://github.com/peyo-hd/device_brcm_rpi3 "Android TV for Raspberry Pi 3") ([see video](https://www.youtube.com/watch?v=NMDf5thqoMk "Raspberry Pi 3 Running Android Tv OS and N64 , SNES emulator test")) * Create an ["Onion Pi" Tor proxy](https://learn.adafruit.com/onion-pi/overview "Make a Raspberry Pi into a Anonymizing Tor Proxy") * Setup an Ad blocker for your whole network with [Pi Hole](https://pi-hole.net/) * Program your own Pi-based robot with the [GoPiGo robot kit](http://www.dexterindustries.com/GoPiGo/): -
![gopigo robot kit](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-pi-gopigo-robot.jpg)* DIY plant automatic watering system: [1](http://www.instructables.com/id/Automatic-Plant-Watering-and-Soil-Moisture-Sensing/ "Automatic Plant Watering and Soil Moisture Sensing"), [2](http://www.instructables.com/id/Raspberry-Pi-Irrigation-Controller/ "Raspberry Pi Irrigation Controller"), [3](https://hackaday.io/project/2711-autonomous-watering-system "Autonomous watering system"), [4](https://blog.serverdensity.com/automatically-watering-your-plants-with-sensors-a-pi-and-webhooks/) + ![gopigo robot kit](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-pi-gopigo-robot.jpg) + +* DIY plant automatic watering system: [1](http://www.instructables.com/id/Automatic-Plant-Watering-and-Soil-Moisture-Sensing/ "Automatic Plant Watering and Soil Moisture Sensing"), [2](http://www.instructables.com/id/Raspberry-Pi-Irrigation-Controller/ "Raspberry Pi Irrigation Controller"), [3](https://hackaday.io/project/2711-autonomous-watering-system "Autonomous watering system"), [4](https://blog.serverdensity.com/automatically-watering-your-plants-with-sensors-a-pi-and-webhooks/) * Make a [personal voice assistant](http://www.instructables.com/id/Raspberri-Personal-Assistant/?ALLSTEPS) * Make a [portable gaming console](http://www.instructables.com/id/Raspberry-Pi-Portable-Games-Console/step6/Assembling-the-Console/), [Porta Pi Arcade system](http://www.instructables.com/id/Build-your-own-Mini-Arcade-Cabinet-with-Raspberry-/) or [Game Boy Zero](https://www.raspberrypi.org/blog/game-boy-zero/ "Game Boy Zero") using with [RetroPie](https://retropie.org.uk/). -
![Portable Pi gaming console](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-pi-portable-games-console.jpg) ![Porta Pi Arcade](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-pi-arcade.jpg) ![Game Boy Zero](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-pi-gameboy-zero.jpg) - * Turn your Raspberry Pi into a gaming console with the [Lakka](http://www.lakka.tv/ "The open source game console") Linux distro + +* Turn your Raspberry Pi into a gaming console with the [Lakka](http://www.lakka.tv/ "The open source game console") Linux distro * Have your Pi run a [Twitter bot that tweets photos](http://blog.bandwidth.com/actually-using-your-raspberry-pi-part-4-twitter-bot/) from the Pi Camera * DIY Pi-controlled espresso machine using [iSPRESSO](http://ispresso.net/ "iSPRESSO is an appliance modification comprised of Raspberry Pi computer, solid state relays, temp sensor, buttons and a display, a custom Printed Circuit Board, and custom linux shell scripts and a good bit of python code") * [DIY Amazon Echo](https://github.com/amzn/alexa-avs-raspberry-pi) using Alexa voice service: -
- ![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-diy-alexa.jpg) - * Setup [wireless electrical outlets via RF modules](https://timleland.com/wireless-power-outlets/ "Wireless power outlets") made for the Pi or hack your own [voice-controlled electrical outlets](http://www.instructables.com/id/Wireless-Multi-Channel-Voice-Controlled-Electrical/): + ![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-diy-alexa.jpg) + +* Setup [wireless electrical outlets via RF modules](https://timleland.com/wireless-power-outlets/ "Wireless power outlets") made for the Pi or hack your own [voice-controlled electrical outlets](http://www.instructables.com/id/Wireless-Multi-Channel-Voice-Controlled-Electrical/): + + ![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-pi-wireless-voice-outlets.jpg) -
- ![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-pi-wireless-voice-outlets.jpg) - * Create your own [BitTorrent downloading box](http://www.howtogeek.com/142044/how-to-turn-a-raspberry-pi-into-an-always-on-bittorrent-box/ "How to Turn a Raspberry Pi into an Always-On BitTorrent Box") +* Create your own [BitTorrent downloading box](http://www.howtogeek.com/142044/how-to-turn-a-raspberry-pi-into-an-always-on-bittorrent-box/ "How to Turn a Raspberry Pi into an Always-On BitTorrent Box") * Make a [Raspberry Pi server cluster](http://makezine.com/projects/build-a-compact-4-node-raspberry-pi-cluster/): -
- ![pi cluster](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-picluster.jpg) - * Have the Raspberry Pi [open the door with a Slack chat command](http://blog.tryolabs.com/2016/06/01/raspberrypi-slack-our-humble-contribution-to-the-offices-laziness/ "RASPBERRY PI + SLACK: OUR HUMBLE CONTRIBUTION TO THE OFFICE¡¯S LAZINESS") + ![pi cluster](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-picluster.jpg) + +* Have the Raspberry Pi [open the door with a Slack chat command](http://blog.tryolabs.com/2016/06/01/raspberrypi-slack-our-humble-contribution-to-the-offices-laziness/ "RASPBERRY PI + SLACK: OUR HUMBLE CONTRIBUTION TO THE OFFICE¡¯S LAZINESS") * Use it as a server for [Home Assistant](https://home-assistant.io/) or [pimatic](https://pimatic.org/ "pimatic is a home automation framework that runs on node.js. It provides a common extensible platform for home control and automation tasks") for all the connected devices and appliances in your home or [have it run HomeBridge](https://github.com/nfarina/homebridge/wiki/Running-HomeBridge-on-a-Raspberry-Pi "Homebridge is a lightweight NodeJS server you can run on your home network that emulates the iOS HomeKit API.") to allow Siri to control more home automation devices. * Use your Pi to host any of these [free web applications yourself](https://github.com/Kickball/awesome-selfhosted/blob/master/README.md) ** DIY [Seenote](https://www.getseenote.com/) digital sticky note / to-do list @@ -180,11 +210,11 @@ But remember how it has all those I/O pins? There are infinite hardware hacking * Play a [MIDI file over a Tesla coil](https://www.youtube.com/watch?v=KhvExaTCXHA) * Create a [high-res networked outdoor camera](http://blog.wq.lc/16-megapixel-outdoor-network-camera-on-the-cheap/ "16 Megapixel Outdoor Network Camera on the Cheap"): -
- ![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-networked-outdoor-picam.jpg) - * And [many](https://hackaday.io/list/3424-raspberry-pi-projects) more [projects](http://www.instructables.com/id/Raspberry-Pi-Projects/)... + ![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-networked-outdoor-picam.jpg) + +* And [many](https://hackaday.io/list/3424-raspberry-pi-projects) more [projects](http://www.instructables.com/id/Raspberry-Pi-Projects/)... -#### What is the Pi not so well suited for? +#### Pi不大适合做什么? For one, the Pi is a full computer and while it does not consume much power for a computer, it can still be overkill compared to an Arduino for simple hardware projects that don't require running an OS, GUI or networking. @@ -194,67 +224,52 @@ In short, the Pi is not quite the best for intense I/O and networking uses but c -#### Getting started +## 开始 -### OS installation +##### 操作系统安装 -#### What you need +#### 你需要什么 Okay, let's get started! I'm going to assume that at the very least you'd like to just install some operating system on a Pi. First you'll need to pick what Raspberry Pi and accessories to buy ¡ª you didn't think you could get away with just buying the Pi itself did you? But what Pi do you want? There's the larger and more powerful Pi 3 Model B and the tiny Pi Zero. I ended up getting both, but if the cost difference isn't a big issue for you I'd suggest starting with the Pi 3B. With integrated Wi-Fi as well as full-size HDMI and USB ports, it's almost a turn-key solution. -###### Parts list*
- **Raspberry Pi 3 Model B** -
- Buy from: - [The Pi Hut](https://thepihut.com/collections/raspberry-pi/products/raspberry-pi-3-model-b), - [MCM](http://www.mcmelectronics.com/product/83-17300), - [Adafruit](https://www.adafruit.com/product/3055), [Pimoroni](https://shop.pimoroni.com/collections/raspberry-pi/products/raspberry-pi-3), - [Amazon](http://www.amazon.com/Raspberry-Pi-RASP-PI-3-Model-Motherboard/dp/B01CD5VC92/ref=as_li_ss_tl?ie=UTF8&keywords=raspberry%20pi&qid=1464412585&ref_=sr_1_4&s=pc&sr=1-4&linkCode=ll1&tag=paulstamatiou-20&linkId=a9639c24281e760bc09a6a807c37bcd6) - - - The heart of your Pi projects. Unfortunately, Amazon themselves do not sell it (just third parties, often at a higher price) so it's probably best to purchase from one of the official partners above. +###### 零部件清单 +* **Raspberry Pi 3 Model B** ($35) - - $35 -*
- [2.5A micro-USB power adapter](http://www.amazon.com/CanaKit-Raspberry-Supply-Adapter-Charger/dp/B00MARDJZ4/ref=as_li_ss_tl?ie=UTF8&refRID=1N7W6CHN64Q9EYQBEN21&linkCode=ll1&tag=paulstamatiou-20&linkId=34d578791be1daf5282c214b30895f06 "CanaKit 5V 2.5A Raspberry Pi 3 Power Supply / Adapter / Charger (UL Listed)") +买自: +[The Pi Hut](https://thepihut.com/collections/raspberry-pi/products/raspberry-pi-3-model-b), +[MCM](http://www.mcmelectronics.com/product/83-17300), +[Adafruit](https://www.adafruit.com/product/3055), [Pimoroni](https://shop.pimoroni.com/collections/raspberry-pi/products/raspberry-pi-3), +[Amazon](http://www.amazon.com/Raspberry-Pi-RASP-PI-3-Model-Motherboard/dp/B01CD5VC92/ref=as_li_ss_tl?ie=UTF8&keywords=raspberry%20pi&qid=1464412585&ref_=sr_1_4&s=pc&sr=1-4&linkCode=ll1&tag=paulstamatiou-20&linkId=a9639c24281e760bc09a6a807c37bcd6) + - Just about any micro-USB power adapter should work, but the more power hungry devices you connect to your Pi the more critical a good power supply becomes. Lots of Raspberry Pi issues that crop up end up being caused by a bad power source, so it's best not to mess around and get a good one. While I have a ton of USB chargers already, I opted not to get a powerful one used by many Pi folks without issue. Another option is this [Anker Dual USB charger](http://www.amazon.com/Anker-Charger-PowerPort-Foldable-iPhone/dp/B012WMWPJW/ref=as_li_ss_tl?ie=UTF8&qid=1464558272&sr=8-1&keywords=wall+charger+anker&refinements=p_89%3AAnker&linkCode=ll1&tag=paulstamatiou-20&linkId=5064fe7ae75d29f829a0f59701c87a32 "Anker 24W Dual USB Wall Charger") with 2 2.4A USB ports if you have other devices to run simultaneously, which I also ended up purchasing later on for my Pi Frame project below. +你的Pi项目的核心。Unfortunately, Amazon themselves do not sell it (just third parties, often at a higher price) so it's probably best to purchase from one of the official partners above. - - $10 -*
- [16GB microSD memory card](http://www.amazon.com/SanDisk-Extreme-MicroSDXC-Adapter-SDSQXNE-064G-GN6MA/dp/B013CP5F90/ref=as_li_ss_tl?ie=UTF8&keywords=64GB%20sandisk%20extreme%20microsd&qid=1464419155&ref_=sr_1_1&sr=8-1&linkCode=ll1&tag=paulstamatiou-20&linkId=0df538f214b6b8fcba4d469830c692a0 "SanDisk Extreme 16GB microSDHC UHS-1") +* [2.5A micro-USB power adapter](http://www.amazon.com/CanaKit-Raspberry-Supply-Adapter-Charger/dp/B00MARDJZ4/ref=as_li_ss_tl?ie=UTF8&refRID=1N7W6CHN64Q9EYQBEN21&linkCode=ll1&tag=paulstamatiou-20&linkId=34d578791be1daf5282c214b30895f06 "CanaKit 5V 2.5A Raspberry Pi 3 Power Supply / Adapter / Charger (UL Listed)") ($10) - Anything larger than 8GB should be fine, but it's very important to get a fast card (Class 10 at least) from a reputable brand. Faulty or slow microSD cards are often a source of Raspberry Pi woes, so it's best not to skimp around in this department either. +Just about any micro-USB power adapter should work, but the more power hungry devices you connect to your Pi the more critical a good power supply becomes. Lots of Raspberry Pi issues that crop up end up being caused by a bad power source, so it's best not to mess around and get a good one. While I have a ton of USB chargers already, I opted not to get a powerful one used by many Pi folks without issue. Another option is this [Anker Dual USB charger](http://www.amazon.com/Anker-Charger-PowerPort-Foldable-iPhone/dp/B012WMWPJW/ref=as_li_ss_tl?ie=UTF8&qid=1464558272&sr=8-1&keywords=wall+charger+anker&refinements=p_89%3AAnker&linkCode=ll1&tag=paulstamatiou-20&linkId=5064fe7ae75d29f829a0f59701c87a32 "Anker 24W Dual USB Wall Charger") with 2 2.4A USB ports if you have other devices to run simultaneously, which I also ended up purchasing later on for my Pi Frame project below. - I already had a bunch of large and fast microSD cards from my GoPro, so I just used one: a 64GB SanDisk Extreme. If you want something even faster you can opt for the SanDisk Extreme Plus or [SanDisk Extreme Pro version](http://www.amazon.com/SanDisk-Extreme-Memory-Speeds-Ready-SDSDQXP-064G-G46A/dp/B008HK1YAA/ref=as_li_ss_tl?ie=UTF8&qid=1464420526&sr=8-3&keywords=64GB+sandisk+extreme+plus+microsd&linkCode=ll1&tag=paulstamatiou-20&linkId=6b513c25ae825406b86d59cf941371f3 "SanDisk Extreme Pro 16GB MicroSDHC memory card"). +* [16GB microSD memory card](http://www.amazon.com/SanDisk-Extreme-MicroSDXC-Adapter-SDSQXNE-064G-GN6MA/dp/B013CP5F90/ref=as_li_ss_tl?ie=UTF8&keywords=64GB%20sandisk%20extreme%20microsd&qid=1464419155&ref_=sr_1_1&sr=8-1&linkCode=ll1&tag=paulstamatiou-20&linkId=0df538f214b6b8fcba4d469830c692a0 "SanDisk Extreme 16GB microSDHC UHS-1") ($10) - - $10 +Anything larger than 8GB should be fine, but it's very important to get a fast card (Class 10 at least) from a reputable brand. Faulty or slow microSD cards are often a source of Raspberry Pi woes, so it's best not to skimp around in this department either. -**You'll also need a keyboard, mouse, HDMI cable and a monitor or TV[3](#footnote-3).** I'm assuming you probably already have these lying around. A USB keyboard and mouse are ideal so there's no issues getting it to connect during initial setup. As for the display, you really only need it for the setup process. After that you can install a VNC server and access it from any computer (if your intended Pi use doesn't require a display all the time). +I already had a bunch of large and fast microSD cards from my GoPro, so I just used one: a 64GB SanDisk Extreme. If you want something even faster you can opt for the SanDisk Extreme Plus or [SanDisk Extreme Pro version](http://www.amazon.com/SanDisk-Extreme-Memory-Speeds-Ready-SDSDQXP-064G-G46A/dp/B008HK1YAA/ref=as_li_ss_tl?ie=UTF8&qid=1464420526&sr=8-3&keywords=64GB+sandisk+extreme+plus+microsd&linkCode=ll1&tag=paulstamatiou-20&linkId=6b513c25ae825406b86d59cf941371f3 "SanDisk Extreme Pro 16GB MicroSDHC memory card"). -###### Optional*
- [Case for the Raspberry Pi 3](http://www.amazon.com/Raspberry-Pi-Case-Black-fits/dp/B00UW2G1BS/ref=as_li_ss_tl?s=pc&ie=UTF8&qid=1464423290&sr=1-3&keywords=raspberry+pi+3+case+canakit&linkCode=ll1&tag=paulstamatiou-20&linkId=f6330a1e3c8876702f340774b21c3170 "Raspberry Pi Case") +* **You'll also need a keyboard, mouse, HDMI cable and a monitor or TV[3](#footnote-3).** I'm assuming you probably already have these lying around. A USB keyboard and mouse are ideal so there's no issues getting it to connect during initial setup. As for the display, you really only need it for the setup process. After that you can install a VNC server and access it from any computer (if your intended Pi use doesn't require a display all the time). - There are a million to chose from so I encourage you to search around though to see what's out there. +###### Optional +* [Case for the Raspberry Pi 3](http://www.amazon.com/Raspberry-Pi-Case-Black-fits/dp/B00UW2G1BS/ref=as_li_ss_tl?s=pc&ie=UTF8&qid=1464423290&sr=1-3&keywords=raspberry+pi+3+case+canakit&linkCode=ll1&tag=paulstamatiou-20&linkId=f6330a1e3c8876702f340774b21c3170 "Raspberry Pi Case") ($9) - - $9 -*
- [Tiny wireless keyboard/trackpad](http://www.amazon.com/FAVI-FE02RF-BL-Wireless-Keyboard-SmartStick/dp/B0090BTY8Y/ref=as_li_ss_tl?ie=UTF8&psc=1&redirect=true&ref_=oh_aui_detailpage_o02_s00&linkCode=ll1&tag=paulstamatiou-20&linkId=2035b5790be962b2b8dd82dac8bfccc5 "FAVI FE02RF-BL Mini 2.4GHz Wireless PC / Tablet Keyboard") +There are a million to chose from so I encourage you to search around though to see what's out there. - While I have a full-size USB keyboard and mouse, I ended up getting this tiny keyboard mouse combo for casual usage. Easy to hide away when not in use. +* [Tiny wireless keyboard/trackpad](http://www.amazon.com/FAVI-FE02RF-BL-Wireless-Keyboard-SmartStick/dp/B0090BTY8Y/ref=as_li_ss_tl?ie=UTF8&psc=1&redirect=true&ref_=oh_aui_detailpage_o02_s00&linkCode=ll1&tag=paulstamatiou-20&linkId=2035b5790be962b2b8dd82dac8bfccc5 "FAVI FE02RF-BL Mini 2.4GHz Wireless PC / Tablet Keyboard") ($32) - - $32 +While I have a full-size USB keyboard and mouse, I ended up getting this tiny keyboard mouse combo for casual usage. Easy to hide away when not in use. -#### What operating system? +#### 什么操作系统? There are lots of operating systems to choose from when it comes time to image your microSD card and start the installation process. The typical Raspberry Pi setup advice involves [installing NOOBS](https://www.raspberrypi.org/documentation/installation/noobs.md) which makes it easy to select between Raspbian, Pidora, OpenELEC, OSMC, RISC OS and Arch Linux. Most newcomers select the Debian-based Raspbian Jessie, the official operating system for the Raspberry Pi. @@ -269,14 +284,19 @@ This part is usually harder than it needs to be. Typically you would download th I ended up going the hard route with the command line to image my card with Ubuntu MATE, but I'll be listing an easier option below. * Download the [Ubuntu MATE 16.04 LTS image made for the Raspberry Pi](https://ubuntu-mate.org/download/). You should get a file named `ubuntu-mate-16.04-desktop-armhf-raspberry-pi.img.xz`. -* Uncompress the image. You can install the command line tool [unxz](http://tukaani.org/xz/) or use a GUI app like [The Unarchiver](http://unarchiver.c3.cx/unarchiver). I chose the latter:
unxz ubuntu-mate-16.04-desktop-armhf-raspberry-pi.img.xz
-* Plug in your microSD card (you'll probably get an SD card adapter with any card you purchased) and run
diskutil list
+* Uncompress the image. You can install the command line tool [unxz](http://tukaani.org/xz/) or use a GUI app like [The Unarchiver](http://unarchiver.c3.cx/unarchiver). I chose the latter:
unxz ubuntu-mate-16.04-desktop-armhf-raspberry-pi.img.xz
+```
+*   Plug in your microSD card (you'll probably get an SD card adapter with any card you purchased) and run 
diskutil list
+```
 *   Identify the disk for your microSD card. This should be something like `/dev/disk4`, **not** `/dev/disk4s1` (The "s" part denotes the partition and we want the whole disk). Triple-check that this is the correct device and size. You may want to eject it and put it back in and verify that the item is removed from `diskutil list` when you do this. You don't want to overwrite the wrong disk!
 *   If this disk is not listed as being FAT32, you will need to format it as DOS FAT32. You can do this in OS X by opening up Disk Utility, selecting the microSD card, clicking Erase and then selecting MS-DOS (FAT).
-*   Unmount the disk, with the "X" being the number you just identified: 
diskutil unmountDisk /dev/diskX
-* Now we get to start the actual imaging process. Verify the name and location of the downloaded .img file you extracted, and enter in the correct disk location (the /dev/diskX part) and run this:
sudo dd bs=1M if=~/Desktop/ubuntu-mate-16.04-desktop-armhf-raspberry-pi.img of=/dev/diskX
+* Unmount the disk, with the "X" being the number you just identified:
diskutil unmountDisk /dev/diskX
+```
+*   Now we get to start the actual imaging process. Verify the name and location of the downloaded .img file you extracted, and enter in the correct disk location (the /dev/diskX part) and run this: 
sudo dd bs=1M if=~/Desktop/ubuntu-mate-16.04-desktop-armhf-raspberry-pi.img of=/dev/diskX
+```
 *   Alternatively you can try an even faster method by using the raw disk location instead of the buffered disk identifier. Just add an "r" before the disk like so: /dev/rdisk4. This may not work for everyone:
-    
sudo dd bs=1M if=~/Desktop/ubuntu-mate-16.04-desktop-armhf-raspberry-pi.img of=/dev/rdiskX
+
sudo dd bs=1M if=~/Desktop/ubuntu-mate-16.04-desktop-armhf-raspberry-pi.img of=/dev/rdiskX
+```
 *   **This will take a long time.** For my 64GB card it took 48 minutes using the first approach (not the rdisk method). You get no status from the dd command while it's working but you can press CTRL+T to get an update.
 *   When completed you can pull out the card and put it in your Raspberry Pi! If you have any questions about this process or are not using a Mac, there are lots of more detailed guides online like [this one](http://elinux.org/RPi_Easy_SD_Card_Setup "RPi Easy SD Card Setup") and [this one](http://www.tweaking4all.com/hardware/raspberry-pi/install-img-to-sd-card/ "Raspberry Pi ¨C How to get an Operating System on a SD-Card").
 
@@ -284,28 +304,21 @@ If you're dying to just get started immediately you can [buy a microSD card with
 
 **But there's an easier way for OS X users**: a new tool called [ApplePi-Baker](http://www.tweaking4all.com/software/macosx-software/macosx-apple-pi-baker/ "MacOS X - ApplePi Baker - Prep SD-Cards for IMG or NOOBS"). It's ridiculously easy to use. It automatically detected my microSD card and all I had to do was select the extracted img file. It did the rest and my card was ready to use after a few minutes.
 
-  
- ![ApplePi Baker](https://turbo.paulstamatiou.com/uploads/2016/05/pstam_applepibaker.jpg) +![ApplePi Baker](https://turbo.paulstamatiou.com/uploads/2016/05/pstam_applepibaker.jpg) -#### Boot it up! +#### 开机! With your new SD card ready to go, slide it in your Raspberry Pi 3 and power it up. It should boot into the setup wizard for whichever OS you chose. This part should be a breeze. After a short while you'll be greeted with your new OS! Take some time to browse around and get it setup to your liking. But you'll first want to resize the file system. You'll find it in the Ubuntu MATE welcome dialog here: - - - [![Ubuntu MATE first boot](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-ubuntu-mate-first-boot.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-ubuntu-mate-first-boot.jpg) - - - +[![Ubuntu MATE first boot](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-ubuntu-mate-first-boot.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-ubuntu-mate-first-boot.jpg) + #### Set a DHCP reservation The majority of how I work with my Pi is actually over SSH and VNC rather than directly using it on a display. As such it's important that I can always find the Pi on my network at the same IP address. To do this I added a DHCP reservation with the AirPort Utility (I have an AirPort Extreme). - -
- ![AirPort Utility - DHCP reservation](https://turbo.paulstamatiou.com/uploads/2016/05/pstam_raspi_dhcp_reservation.jpg) +![AirPort Utility - DHCP reservation](https://turbo.paulstamatiou.com/uploads/2016/05/pstam_raspi_dhcp_reservation.jpg) @@ -313,7 +326,9 @@ To do this you'll need to know the MAC address of your Raspberry Pi. You can do Now you can always ssh into your Pi from any computer on your network (or from any computer if you also setup port forwarding) with the same local IP. The default username for Raspbian is `pi` but you will have set your own username for Ubuntu MATE. -
ssh pi@10.0.1.46
+```sh +ssh pi@10.0.1.46 +``` #### Setting up VNC @@ -321,33 +336,35 @@ Unless you have a dedicated display for your Pi, it will probably be annoying to While either SSH'd in or directly on your Pi, install the Tight VNC server: -
sudo apt-get update
+```sh
+sudo apt-get update
 sudo apt-get install tightvncserver
-tightvncserver
+tightvncserver +``` Now you need to enable the VNC server on the Pi. While it's sufficient to just type `tightvncserver` to run it, you'll want to customize a few things to get a higher resolution display, especially if you're accessing it on your LAN. Running the following command will setup a virtual screen with resolution of 1920x1080. You can use any screen resolution you like here within reason: -
stammy@rpi:~$ vncserver :1 -geometry 1920x1200 -depth 24
+```sh
+stammy@rpi:~$ vncserver :1 -geometry 1920x1200 -depth 24
 
 New 'X' desktop is rpi:1
 
 Starting applications specified in /home/stammy/.vnc/xstartup
-Log file is /home/stammy/.vnc/rpi:1.log
+Log file is /home/stammy/.vnc/rpi:1.log +``` If you need to kill the server and change settings you can run `vncserver -kill :1` The VNC server is now running on display **:1**. Download the [VNC Viewer client from realVNC](http://www.realvnc.com/download/) for your Mac and open it up. Type in the IP of your Pi on the network and append the :1 screen, like this: -
- ![realVNC Viewer Mac](https://turbo.paulstamatiou.com/uploads/2016/05/pstam_vncclient_mac.jpg) +![realVNC Viewer Mac](https://turbo.paulstamatiou.com/uploads/2016/05/pstam_vncclient_mac.jpg) Type in the password for your Pi and you're set! You'll quickly notice it's not quite as snappy as if you were using your Pi with a physical display but it can get the job done. +![Ubuntu MATE via realVNC Viewer Mac](https://turbo.paulstamatiou.com/uploads/2016/05/pstam_ubuntumate_vnc_2000.jpg) -
- ![Ubuntu MATE via realVNC Viewer Mac](https://turbo.paulstamatiou.com/uploads/2016/05/pstam_ubuntumate_vnc_2000.jpg) -
Ubuntu MATE 16.04 running on a Raspberry Pi 3 over VNC
+Ubuntu MATE 16.04 running on a Raspberry Pi 3 over VNC Now you can fully control your Pi without the need for a hardware display. You will need to manually start the VNC server on the Pi whenever the Pi is rebooted. I'm usually logged in via SSH and rarely reboot so it's not a huge deal for me to run that line every now and then. But you can configure it to [automatically run at boot](http://elinux.org/RPi_VNC_Server). @@ -356,57 +373,60 @@ But you might be thinking.. **doesn't OS X have it's own screen sharing utility? You're right! OS X is native VNC capable. To get this working we need to make the Pi discoverable via Bonjour and have it to broadcast it's new VNC support in a way that OS X can understand. -
sudo apt-get install netatalk avahi-daemon
+```sh +sudo apt-get install netatalk avahi-daemon +``` We're going to install `netatalk`[4](#footnote-4) which sets up the Apple Filing Protocol so we can also manipulate files on your Pi directly from the OS X Finder. If you're following this guide with Ubuntu MATE, you can leave off the `avahi-daemon` part as Ubuntu seems to come preinstalled with Avahi, the networking service discovery daemon. At this point your Raspberry Pi should be visible and accessible on the local network with your Mac! However, to be able to see the screen sharing capability advertised here you'll need to modify a file: -
sudo nano /etc/avahi/services/rfb.service
+```sh +sudo nano /etc/avahi/services/rfb.service +``` Paste this configuration below and save. We're telling the avahi daemon about RFB (remote framebuffer.. VNC basically) and what port it works on. -
- - <?xml version="1.0" standalone='no'?> - <!DOCTYPE service-group SYSTEM "avahi-service.dtd"> - <service-group> - <name replace-wildcards="yes">%h</name> - <service> - <type>_rfb._tcp</type> - <port>5901</port> - </service> - </service-group> +```xml + + + + %h + + _rfb._tcp + 5901 + + +``` And then restart the daemon: -
sudo /etc/init.d/avahi-daemon restart
+```sh +sudo /etc/init.d/avahi-daemon restart +``` You should now be see a new **Share Screen...** button. Click on that, type in your Pi password and you can now easily VNC into your Pi natively. -
- ![Raspberry Pi visible in the OS X Finder](https://turbo.paulstamatiou.com/uploads/2016/05/pstam_finder_pi_ss.jpg) -
Raspberry Pi visible in the OS X Finder
- -This approach uses netatalk/AFP for sharing your Pi on the network so it will only work for Macs. If you'd like to share files for Windows machines, you'd want to setup Samba sharing. Also, AFP is technically deprecated, so a future-proof solution would be to setup SMB2... but I've always had a heck of a time getting it to work flawlessly and AFP works great for now. +![Raspberry Pi visible in the OS X Finder](https://turbo.paulstamatiou.com/uploads/2016/05/pstam_finder_pi_ss.jpg) +Raspberry Pi visible in the OS X Finder + +This approach uses netatalk/AFP for sharing your Pi on the network so it will only work for Macs. If you'd like to share files for Windows machines, you'd want to setup Samba sharing. Also, AFP is technically deprecated, so a future-proof solution would be to setup SMB2... but I've always had a heck of a time getting it to work flawlessly and AFP works great for now. -#### Taking a look around -### Let's build something +## 看看别人都用它做什么 +##### 一起做些什么 #### Turning it into a NAS Now that you have your Pi and its files completely accessible via the OS X Finder, wouldn't it be neat to add more storage to your Pi, share that volume and backup to it? While I personally don't use my Pi for this ¡ª I [setup a larger Synology 4-disk NAS system](https://paulstamatiou.com/storage-for-photographers-part-2/ "Storage for Photographers (Part 2) - How a 12TB Synology NAS changed my digital life") for my terabytes of photos ¡ª it [can be done](http://www.howtogeek.com/139433/how-to-turn-a-raspberry-pi-into-a-low-power-network-storage-device/ "How to Turn a Raspberry Pi into a Low-Power Network Storage Device") with [a Raspberry Pi](http://www.techradar.com/how-to/computing/how-to-make-a-mac-time-capsule-with-the-raspberry-pi-1319989 "How to make a Mac Time Capsule with the Raspberry Pi"). Just don't expect it to be fast. -[
- ![](https://turbo.paulstamatiou.com/uploads/2015/05/DSC01751-500.jpg) -
+![](https://turbo.paulstamatiou.com/uploads/2015/05/DSC01751-500.jpg) #### Storage for Photographers (Part 2) @@ -419,9 +439,9 @@ There are many small and energy efficient storage options from USB sticks to ext The Raspberry Pi ended up getting so popular that Western Digital actually created a more efficient drive _just_ for the Pi. Called the [WD PiDrive](http://wdlabs.wd.com/products/wd-pidrive-314gb/) it's a 314GB hard drive (314GB as in ¦Ð, get it?) with a native 7mm USB connection. Unfortunately, it's pricey for how many gigabytes you get. -As you might expect with a real NAS, **you can connect the Raspberry Pi to a UPS battery backup**: either a [real desktop-class UPS](https://melgrubb.com/2014/09/05/raspberry-pi-home-server-part-15power-failures/ "Raspberry Pi Home Server: Part 15¨CPower Failures") or a [tiny add-on board like this](http://www.modmypi.com/raspberry-pi/breakout-boards/pi-modules/ups-pico "UPS PIco - Uninterruptible Power Supply & I2C Control HAT") or [this](https://www.pi-supply.com/product/pi-ups-uninterrupted-power-supply-raspberry-pi/ "Pi UPS ¨C Uninterrupted Power Supply for Raspberry Pi") that sits on top of the Pi and has a cell-phone battery with enough battery to let your Pi run for a few hours and safely shut down. +As you might expect with a real NAS, **you can connect the Raspberry Pi to a UPS battery backup**: either a [real desktop-class UPS](https://melgrubb.com/2014/09/05/raspberry-pi-home-server-part-15power-failures/ "Raspberry Pi Home Server: Part 15¨CPower Failures") or a [tiny add-on board like this](http://www.modmypi.com/raspberry-pi/breakout-boards/pi-modules/ups-pico "UPS PIco - Uninterruptible Power Supply & I2C Control HAT") or [this](https://www.pi-supply.com/product/pi-ups-uninterrupted-power-supply-raspberry-pi/ "Pi UPS ¨C Uninterrupted Power Supply for Raspberry Pi") that sits on top of the Pi and has a cell-phone battery with enough battery to let your Pi run for a few hours and safely shut down. -If you don't need the data portion of a real UPS system (being able to tell your Pi it's now running on battery and should shut off soon), you can just get a [good USB battery pack](https://www.amazon.com/Powerful-10000mAh-Anker-PowerCore-Technology/dp/B013HSQXZC/ref=as_li_ss_tl?srs=2528932011&ie=UTF8&qid=1464849921&sr=8-4&keywords=anker+powercore%2B&linkCode=ll1&tag=paulstamatiou-20&linkId=e2f04b6418a0bbb1e5b7890210d64b70 "Anker PowerCore+ 10050 Premium Aluminum Portable Battery Charger ") that you always keep plugged in. Make sure you get a reputable one with the appropriate circuitry to support pass-through charging or build your own with [this PowerBoost circuit](https://www.adafruit.com/products/2465 "PowerBoost 1000 Charger - Rechargeable 5V Lipo USB Boost @ 1A - 1000C") and a 3.7V LiPo battery. +If you don't need the data portion of a real UPS system (being able to tell your Pi it's now running on battery and should shut off soon), you can just get a [good USB battery pack](https://www.amazon.com/Powerful-10000mAh-Anker-PowerCore-Technology/dp/B013HSQXZC/ref=as_li_ss_tl?srs=2528932011&ie=UTF8&qid=1464849921&sr=8-4&keywords=anker+powercore%2B&linkCode=ll1&tag=paulstamatiou-20&linkId=e2f04b6418a0bbb1e5b7890210d64b70 "Anker PowerCore+ 10050 Premium Aluminum Portable Battery Charger ") that you always keep plugged in. Make sure you get a reputable one with the appropriate circuitry to support pass-through charging or build your own with [this PowerBoost circuit](https://www.adafruit.com/products/2465 "PowerBoost 1000 Charger - Rechargeable 5V Lipo USB Boost @ 1A - 1000C") and a 3.7V LiPo battery. You can also setup your Pi to be a [Time Machine backup destination](https://pwntr.com/2012/03/03/easy-mac-os-x-lion-10-7-time-machine-backup-using-an-ubuntu-linux-server-11-10-12-04-lts-and-up/ " Easy Mac OS X (Mountain) Lion and Mavericks 10.7, 10.8 and 10.9 Time Machine backup using an Ubuntu Linux server [11.10, 12.04 LTS and up]") on the network and you can even [install CrashPlan](https://gist.github.com/n8henrie/37d96807e31d94ca0464 "Set up CrashPlan on Raspberry Pi (Raspbian Jessie)") to have all your Pi's files backed up to the cloud as well. But be warned it won't be particularly fast. @@ -438,31 +458,35 @@ Regardless of what drive you get, you'll want to mount it and have netatalk shar /dev/mmcblk0: PTUUID="580a66ff" PTTYPE="dos" /dev/mmcblk0p1: SEC_TYPE="msdos" LABEL="PI_BOOT" UUID="4442-965D" TYPE="vfat" PARTUUID="580a66ff-01" /dev/mmcblk0p2: LABEL="PI_ROOT" UUID="e440adac-fcf9-4b68-9f94-6bfd030f60b3" TYPE="ext4" PARTUUID="580a66ff-02" -/dev/sda1: UUID="9C33-6BBD" TYPE="exfat"
* We're looking for the UUID of the USB device so we can mount the drive based on it's unique id instead of it's location, so it will always mount flawlessly. In this case my drive is the last line with type `exfat`, since it is a large 128GB SDXC card that I plugged in (not the micro-SD card but a USB card reader and SD card just to test this out). You can verify that this is the correct line item by ejecting and running the `sudo blkid` command again to see that the line vanishes. +/dev/sda1: UUID="9C33-6BBD" TYPE="exfat" +```* We're looking for the UUID of the USB device so we can mount the drive based on it's unique id instead of it's location, so it will always mount flawlessly. In this case my drive is the last line with type `exfat`, since it is a large 128GB SDXC card that I plugged in (not the micro-SD card but a USB card reader and SD card just to test this out). You can verify that this is the correct line item by ejecting and running the `sudo blkid` command again to see that the line vanishes. * Create a new directory where we will mount the drive and then have your user account own it. If you are using the default pi username it will just be the following:
sudo mkdir /usb-drive
-sudo chown -R pi:pi /usb-drive
* Now for the real work, we need to add a line to our file systems table file. It is _very important_ that this is typed correctly with the correct UUID and filesystem type for your drive. If this is incorrect your Raspberry Pi will get stuck at boot and you won't even be able to SSH in, you'll have to enter emergency mode to fix the file. +sudo chown -R pi:pi /usb-drive +```* Now for the real work, we need to add a line to our file systems table file. It is _very important_ that this is typed correctly with the correct UUID and filesystem type for your drive. If this is incorrect your Raspberry Pi will get stuck at boot and you won't even be able to SSH in, you'll have to enter emergency mode to fix the file. -
sudo vim /etc/fstab
-
- ![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-edit-fstab-for-usb-device.jpg) +
sudo vim /etc/fstab
+```
+          ![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-edit-fstab-for-usb-device.jpg)
     *   Now add this line to the bottom of your fstab file, making sure to replace XXXX-XXXX with the UUID from the blkid command earlier and using the correct file system type (vfat, exfat, etc):
 
-    
UUID=XXXX-XXXX  /usb-drive     exfat   auto,nofail,uid=1000,gid=100,umask=0002,rw 0 0
* Now we'll add this new drive as an item for netatalk to share. You'll need to edit this file: +
UUID=XXXX-XXXX  /usb-drive     exfat   auto,nofail,uid=1000,gid=100,umask=0002,rw 0 0
+```*   Now we'll add this new drive as an item for netatalk to share. You'll need to edit this file:
 
-    
sudo vim /etc/netatalk/AppleVolumes.default
-
- ![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-edit-netatalk-volumes.jpg) +
sudo vim /etc/netatalk/AppleVolumes.default
+```
+          ![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-edit-netatalk-volumes.jpg)
     *   Scroll to the very bottom and add this line representing the new persistent mount point for your USB storage device:
 
-    
/usb-drive      "USB Drive"
* Reboot. Your drive should now be shared and accessible on the network! +
/usb-drive      "USB Drive"
+```*   Reboot. Your drive should now be shared and accessible on the network!
 
 #### Benchmarking, overclocking and cooling
 
 While I won't dwell on this too much, it's possible to overclock your Raspberry Pi to achieve  higher CPU and RAM speeds. Why would you want to overclock your Pi? You might want to squeeze some extra performance from a CPU-limited process like video transcoding or the like. Or you might just want to see if you can overclock it for fun.
 
-There's a [simple Pi benchmark script](https://github.com/aikoncwd/rpi-benchmark) that includes overclocking documentation so you can run before and after your overclock to measure benefits. There are also quite a few guides on the topic if you're really curious: [Raspberry Pi 3 Overclocking](http://www.jackenhack.com/raspberry-pi-3-overclocking/ "Raspberry Pi 3 Overclocking") and [Pi 3 Overclocking, Stability Testing & Cooling](https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=144391&p=960651 "Pi3 Configuration, Overclocking, Stability Testing & Cooling"). However, **do not attempt overclocking** without adding additional cooling to the Raspberry Pi CPU and RAM.
+There's a [simple Pi benchmark script](https://github.com/aikoncwd/rpi-benchmark) that includes overclocking documentation so you can run before and after your overclock to measure benefits. There are also quite a few guides on the topic if you're really curious: [Raspberry Pi 3 Overclocking](http://www.jackenhack.com/raspberry-pi-3-overclocking/ "Raspberry Pi 3 Overclocking") and [Pi 3 Overclocking, Stability Testing & Cooling](https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=144391&p=960651 "Pi3 Configuration, Overclocking, Stability Testing & Cooling"). However, **do not attempt overclocking** without adding additional cooling to the Raspberry Pi CPU and RAM.
 
 ###### Heatsinks
 
@@ -470,37 +494,30 @@ Actually, even if you don't overclock your Pi but you put it through its paces o
 
 While you could go a bit extreme with a [massive heatsink and fan](https://www.youtube.com/watch?v=WfQMLInuwws "Raspberry Pi 3: More Extreme Cooling"), peltier setup or even a custom watercooling contraption, it's all bound to be overkill unless you are doing some crazy hardware voltage modifications to your Pi. I'm assuming that's not you and just a simple heatsink will do.
 
-There are 2 main chips to consider for cooling: The primary SoC that's on the top of the board and the RAM chip underneath the board. There is also a smaller chip that gets a bit warm near the USB ports and that's the USB and Ethernet controller. I did a bit of research and eventually ended up getting some high-quality (albeit pricey) copper [RAM heatsinks](https://www.amazon.com/gp/product/B002BWXW6E/ref=as_li_ss_tl?ie=UTF8&psc=1&linkCode=ll1&tag=paulstamatiou-20&linkId=2a12faeae15ac183f4fafcda6e879b2d "ENZOTECH Memory Ramsink BMR-C1") and [MOSFET heatsinks](https://www.amazon.com/gp/product/B004CLDIHK/ref=as_li_ss_tl?ie=UTF8&psc=1&linkCode=ll1&tag=paulstamatiou-20&linkId=9eec0bca23273108f9bfc933cc94d134 "Enzotech MOS-C1 MOSFET Heatsinks - 10 Pack") from ENZOTECH. The RAM heatsinks fit well over the SoC and the RAM, but you can also do the same by just placing 4 of the tiny MOSFET heatsinks on each chip.
+There are 2 main chips to consider for cooling: The primary SoC that's on the top of the board and the RAM chip underneath the board. There is also a smaller chip that gets a bit warm near the USB ports and that's the USB and Ethernet controller. I did a bit of research and eventually ended up getting some high-quality (albeit pricey) copper [RAM heatsinks](https://www.amazon.com/gp/product/B002BWXW6E/ref=as_li_ss_tl?ie=UTF8&psc=1&linkCode=ll1&tag=paulstamatiou-20&linkId=2a12faeae15ac183f4fafcda6e879b2d "ENZOTECH Memory Ramsink BMR-C1") and [MOSFET heatsinks](https://www.amazon.com/gp/product/B004CLDIHK/ref=as_li_ss_tl?ie=UTF8&psc=1&linkCode=ll1&tag=paulstamatiou-20&linkId=9eec0bca23273108f9bfc933cc94d134 "Enzotech MOS-C1 MOSFET Heatsinks - 10 Pack") from ENZOTECH. The RAM heatsinks fit well over the SoC and the RAM, but you can also do the same by just placing 4 of the tiny MOSFET heatsinks on each chip.
 
+  
+[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09376-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09376-1500.jpg)
 
+[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09390-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09390-1500.jpg)
 
+[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09392-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09392-1500.jpg)
 
-  
-          [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09376-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09376-1500.jpg)
-    
-  
-  
-          [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09390-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09390-1500.jpg)
-    
-  
-  
-      [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09392-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09392-1500.jpg)
-    
-      [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09397-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09397-1500.jpg)
+[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09397-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09397-1500.jpg)
     
   
 
 
 
-Unfortunately, they are a bit tall so having this on the underside of your Pi can limit your case mounting options. I also got a set of [low profile aluminum heatsinks](https://www.amazon.com/gp/product/B00A88DVTG/ref=as_li_ss_tl?ie=UTF8&psc=1&linkCode=ll1&tag=paulstamatiou-20&linkId=28ccdcc3c6502e804397c1590f214fc5 "LinuxFreak brand Aluminum Heatsink set for Raspberry Pi - Set of 2 Heat Sinks") that would work as well.
+Unfortunately, they are a bit tall so having this on the underside of your Pi can limit your case mounting options. I also got a set of [low profile aluminum heatsinks](https://www.amazon.com/gp/product/B00A88DVTG/ref=as_li_ss_tl?ie=UTF8&psc=1&linkCode=ll1&tag=paulstamatiou-20&linkId=28ccdcc3c6502e804397c1590f214fc5 "LinuxFreak brand Aluminum Heatsink set for Raspberry Pi - Set of 2 Heat Sinks") that would work as well.
 
 With my Pi now heatsink'd up I can let it handle just about any task and not worry about it overheating. You can also get a 5V fan to blow over the heatsinks and [use a script to only spin it up when it gets hot](https://medium.com/@edoardo849/how-to-control-a-fan-to-cool-the-cpu-of-your-raspberrypi-3313b6e7f92c "How to control a fan to cool the CPU of your RaspBerryPi").
 
 
 
-#### Working with the I/O pins
+## 使用I/O引脚
 
-### Pi electronics 101
+##### Pi electronics 101
 
 
 
@@ -508,10 +525,7 @@ Time for the fun part ¡ª tinkering with some electronics and the Pi's General
 
 The Pi 3 ¡ª and Pi Zero, just without the connector pins ¡ª has 40 pins, but 26 of them are GPIO pins accessible to program. The other pins are ground (8), 5V (2), 3.3V (2) and reserved EEPROM pins (2).
 
-
-
-  
-          [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09453-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09453-1500.jpg)
+[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09453-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09453-1500.jpg)
     
   
 
@@ -526,26 +540,18 @@ Instead, the GPIO pin output should just be used as a signal to switch something
 
 To make things easier for tinkering I purchased a [breadboard](https://www.adafruit.com/products/239 "solderless breadboard") so I could prototype little circuits without soldering. I also purchased a [T-Cobbler](https://www.adafruit.com/products/2028 "Pi T-Cobbler Plus - GPIO Breakout") that directly connects the Raspberry Pi pins to the breadboard. And of course various LEDs, wires, transistors, resistors and buttons to play with.
 
-
-
-  
-          [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09490-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09490-1500.jpg)
+[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09490-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09490-1500.jpg)
     
-  
-  
-          [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09486-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09486-1500.jpg)
+[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09486-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09486-1500.jpg)
     
   
 
 
-#### Setup & powering an LED
+#### Setup & powering an LED
 
 First, attach the T-Cobbler board to the breadboard and then to the Pi with the ribbon cable. Make sure the ribbon cable's white wire connects to the corner side of the Pi. Aside from making it easy to physically connect things with the breadboard, the T-Cobbler board also provides you with the GPIO pin labels.
 
-
-
-  
-          [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09497-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09497-1500.jpg)
+[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09497-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09497-1500.jpg)
     
   
 
@@ -560,9 +566,7 @@ But first we should be cautious about how much voltage and current we supply to
 
 Resistors don't have polarity so it doesn't matter which way they are used. LEDs do however. There's the cathode (**-**) that is easy to identify as it's the shorter wire from the LED and there is a flat side of the LED identifying the cathode. The longer wire coming from the LED is the anode (**+**). This can be done various ways with the breadboard, but I started by placing a jumper from GND to the blue power rail and then plugging the LED into the power rail, making sure that the short end of the LED (cathode) stayed on the negative blue rail. Then I connected the resistor from the 5V terminal strip on the breadboard that comes from the Pi to the positive red power rail. Now our LED will light up!
 
-  
-    
-              [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09516-750.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09516-1500.jpg)
+[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09516-750.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09516-1500.jpg)
       
     
   
@@ -575,23 +579,24 @@ This time we just need to connect the LED anode (the long wire) to GPIO pin 17 a
 
 Then we SSH into our Pi ¡ª or directly on it if you've got a display hooked up or are using VNC ¡ª and open up the python interpreter so we can use the python GPIO library. First we need import that library. It should be included in your OS automatically if you're using Ubuntu MATE or Raspbian Jessie.
 
-  
stammy@rpi:~$ python
+```
+stammy@rpi:~$ python
 Python 2.7.11+ (default, Apr 17 2016, 14:00:29)
 [GCC 5.3.1 20160413] on linux2
 Type "help", "copyright", "credits" or "license" for more information.
->>> import RPi.GPIO as GPIO
->>> GPIO.setmode(GPIO.BCM)
->>> GPIO.setup(17, GPIO.OUT)
->>> GPIO.output(17, True)
->>> GPIO.output(17, False)
+>>> import RPi.GPIO as GPIO +>>> GPIO.setmode(GPIO.BCM) +>>> GPIO.setup(17, GPIO.OUT) +>>> GPIO.output(17, True) +>>> GPIO.output(17, False) +``` Then we need to set the pin mode. This determines what we mean when we provide a GPIO pin number: either by the physical pin position (`GPIO.BOARD`), or by the Broadcom pin number (`GPIO.BCM`). The latter is listed on the T-Cobbler for us so I provided the `GPIO.BCM` mode. Then we setup() each GPIO pin to be used and tell the Pi if it will be used for input or output (`GPIO.IN` or `GPIO.OUT`). We'll go with output since we just want to power the LED instead of listen for an input signal. And now we can finally **we can turn the LED on and off** with these commands: `GPIO.output(17, True)` and `GPIO.output(17, False)`. Go ahead and try it a few times! and think about how we're talking to a tiny computer over a network and having it control our electronics for us. Pretty neat. Despite everything being an app or connected device these days it's still fun to be able to control something simple like this. - - [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09519-750.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09519-1500.jpg) +[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09519-750.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09519-1500.jpg) @@ -608,31 +613,25 @@ One way to control your components is with a transistor. I'm using a basic BJT ( Typically you should also use a resistor between the transistor and the GPIO pin to reduce the current it draws. There is a bit more to it ¡ª like how the amount of current applied to the base can vary the collector current as the transistor acts as a simple amplifier, up to a "saturation" point ¡ª but that's best left for [some extra reading if you're curious](https://learn.sparkfun.com/tutorials/transistors/all "Transistors"). -
- ![NPN PN2222 Transistor pinout](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-npn-transistor-schematic2.png) +![NPN PN2222 Transistor pinout](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-npn-transistor-schematic2.png) Okay so we have 3 pins on our transistor: emitter, base, collector (EBC). It's important to note the exact pin layout as it varies by transistor. If you're looking at the flat side of the PN2222 NPN transistor, we have EBC from left to right. The middle base pin is what actually causes the transistor to trigger, making the normally open emitter and collector closed. This is the opposite behavior from a PNP transistor, with [some extra nuances](http://www.learningaboutelectronics.com/Articles/Difference-between-a-NPN-and-a-PNP-transistor "Difference Between an NPN and a PNP Transistor"). -
- ![transistor schematic](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi-3-transistor-led-diagram.jpg) -
While this circuit works for this very simple use, technically you would want to add a pull-down resistor from the base to ground to get it to switch off faster [and for other reasons](http://electronics.stackexchange.com/questions/56010/why-pull-base-of-bjt-switch).
+![transistor schematic](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi-3-transistor-led-diagram.jpg) + +While this circuit works for this very simple use, technically you would want to add a pull-down resistor from the base to ground to get it to switch off faster [and for other reasons](http://electronics.stackexchange.com/questions/56010/why-pull-base-of-bjt-switch). We want to connect the base pin to our GPIO pin 17 along with a resistor. I wanted to use larger resistor but only had my same 220? resistors, so I put a few in series. This introduces enough resistance to lower the current used by the transistor on the GPIO pin but have enough juice to saturate the transistor into a fully on state. Current flows from the collector to the emitter, so I connected a jumper cable from GND to the emitter and then placed the LED[7](#footnote-7) between the Pi's 5V pin and the collector. Then connect the LED anode to the 5V line and the cathode (the flat side of the LED) to the transistor's collector with that same 220? resistor in between. +[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09530-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09530-1500.jpg) - - - [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09530-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09530-1500.jpg) +[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09525-750.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09525-1500.jpg) - [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09525-750.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09525-1500.jpg) - - - -
I forgot to add a resistor from in front of the LED, so it was powered by 5V directly here. No issues but you don't want to be running it like this for more than a bit.
+I forgot to add a resistor from in front of the LED, so it was powered by 5V directly here. No issues but you don't want to be running it like this for more than a bit. Now you can run the same `GPIO.output()` commands from earlier to switch the LED on and off, via the NPN transistor! This is a safer way to control small devices off your GPIO pins. @@ -642,14 +641,11 @@ But what should you do if you need something even heavier duty for controlling a Lets get a relay working for our last experiment. There are several kinds from electromechanical to solid state and more, but the concept is the same: it will close or open any circuit you connect it to when triggered. The difference between our earlier BJT NPN transistor is that it's only on or off (no amplification characteristics) and the circuit you switch on is entirely separate to the switching logic (at least with electromechanical relays) so most relays can support much larger voltages while not interacting with your low voltage circuit. Okay I'm rambling a bit but basically this is what you want if you want to run an even larger device, like a 120V lamp for example (assuming your relay is rated for that). -I ended up getting an electromechanical relay that was [preassembled to just need a control signal](https://www.amazon.com/gp/product/B00VRUAHLE/ref=as_li_ss_tl?ie=UTF8&psc=1&linkCode=ll1&tag=paulstamatiou-20&linkId=097665a19e82d17d0bcccfd7229da356) to make it easy to get started ¡ª it wires up just like our previous transistor. It bakes in the necessary transistor and some safeguards like a flyback spike protection diode for the relay coil. Again, there's [more to read about on the EE side](http://electronics.stackexchange.com/questions/100134/why-is-there-a-diode-connected-in-parallel-to-a-relay-coil "Why is there a diode connected in parallel to a relay coil?") here if you're interested. - - - +I ended up getting an electromechanical relay that was [preassembled to just need a control signal](https://www.amazon.com/gp/product/B00VRUAHLE/ref=as_li_ss_tl?ie=UTF8&psc=1&linkCode=ll1&tag=paulstamatiou-20&linkId=097665a19e82d17d0bcccfd7229da356) to make it easy to get started ¡ª it wires up just like our previous transistor. It bakes in the necessary transistor and some safeguards like a flyback spike protection diode for the relay coil. Again, there's [more to read about on the EE side](http://electronics.stackexchange.com/questions/100134/why-is-there-a-diode-connected-in-parallel-to-a-relay-coil "Why is there a diode connected in parallel to a relay coil?") here if you're interested. - [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09540-750.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09540-1500.jpg) - - [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09544-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09544-1500.jpg) +[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09540-750.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09540-1500.jpg) + +[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09544-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09544-1500.jpg) @@ -668,14 +664,11 @@ While we only touched on using a single GPIO pin as output, there's lots to lear -#### Building a digital photo frame - -### with a 10" 1920x1200 display +## 做一个数码相框 +##### with a 10" 1920x1200 display - - - [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00194-1280.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00194-1500.jpg) +[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00194-1280.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00194-1500.jpg) @@ -703,13 +696,13 @@ I tested the display and everything was working great! I was just amazed at the - [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09125-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09125-1500.jpg) - - [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09150-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09150-1500.jpg) - - - - [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09147-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09147-1500.jpg) +[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09125-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09125-1500.jpg) + +[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09150-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09150-1500.jpg) + + + +[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09147-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09147-1500.jpg) @@ -721,8 +714,8 @@ I was a bit nervous working with this board. The cable running to the display ex - [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09379-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09379-1500.jpg) - +[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09379-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-raspberry-pi3-DSC09379-1500.jpg) + @@ -733,16 +726,12 @@ Now that I had my functioning display, I needed to figure out how to mount it. I I went to a local frame store and **picked up a 9" x 12" frame** with matting. I carefully measured the viewport of the display and cut the sides of the matting to add room. This worked but the matting had a beveled cut so my cuts don't look natural . Eventually I will have the frame store custom cut the matting in the size I need, but this will do for now. +[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC09815-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC09815-1500.jpg) - -
- [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC09815-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC09815-1500.jpg) - -
- [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC09821-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC09821-1500.jpg) - -
- [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC09826-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC09826-1500.jpg) +[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC09821-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC09821-1500.jpg) + + +[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC09826-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC09826-1500.jpg) @@ -754,18 +743,15 @@ I cut peices of cardboard and put them alongside the display to reduce pressure -
- [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC09832-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC09832-1500.jpg) - -
- [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC09840-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC09840-1500.jpg) - -
- [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC09841-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC09841-1500.jpg) - - - - [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00010-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00010-1500.jpg) +[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC09832-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC09832-1500.jpg) + +[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC09840-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC09840-1500.jpg) + +[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC09841-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC09841-1500.jpg) + + + +[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00010-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00010-1500.jpg) @@ -776,18 +762,18 @@ With the back of the frame in place, I still had a bit of room to tuck the Pi aw - - [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00040-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00040-1500.jpg) + +[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00040-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00040-1500.jpg) -Now it was time to give it a test boot. I was powering the Pi and display off separate USB sources so that I had more than enough juice to spare for the Pi. Instead of having to find two USB power adapters, I opted for [this great Anker dual USB adapter](https://www.amazon.com/gp/product/B012WMWPJW/ref=as_li_ss_tl?ie=UTF8&psc=1&linkCode=ll1&tag=paulstamatiou-20&linkId=cdcfeeb2de9fca9e548e87beea54255e "Anker 24W Dual USB Wall Charger PowerPort 2") which provides 2.4 amps per USB port. +Now it was time to give it a test boot. I was powering the Pi and display off separate USB sources so that I had more than enough juice to spare for the Pi. Instead of having to find two USB power adapters, I opted for [this great Anker dual USB adapter](https://www.amazon.com/gp/product/B012WMWPJW/ref=as_li_ss_tl?ie=UTF8&psc=1&linkCode=ll1&tag=paulstamatiou-20&linkId=cdcfeeb2de9fca9e548e87beea54255e "Anker 24W Dual USB Wall Charger PowerPort 2") which provides 2.4 amps per USB port. - - [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00051-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00051-1500.jpg) + +[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00051-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00051-1500.jpg) @@ -807,10 +793,7 @@ I would only need to have a browser that could display in fullscreen or kiosk mo Fortunately, **Firefox's native fullscreen mode did the trick**. I just had to log into Google Photos, select an album and hide the mouse in the corner. To get photos to be the perfect aspect ratio to fill the 1920x1200 display and not have pillar or letterboxing, I created a new album and **uploaded some of my travel photos cropped to a 16:10 aspect ratio**. It worked perfectly! - - - - [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00108-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00108-1500.jpg) +[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00108-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00108-1500.jpg) @@ -823,7 +806,8 @@ I decided to take a stab at automate this by writing and **injecting some JavaSc You can adjust the time by changing the `600000` number (10 minutes in milliseconds) on the last line. -
// ==UserScript==
+```
+// ==UserScript==
 // @name        google photos slower slideshow
 // @namespace   piframe
 // @include     https://photos.google.com/album/*
@@ -855,11 +839,13 @@ function next_or_prev() {
   }
 }
 window.setInterval(function(){next_or_prev()}, 600000);
-
+ +``` **Update:** The issue with this approach is that it relies on the class names of the left and right arrows, which are bound to change with future Google Photos web deploys. **I rewrote this script (below)** to trigger a right arrow key event instead. It keeps trying to go to the next photo and if the URL doesn't change it figures it must be at the last photo so it goes to the first photo. This **requires you to provide the URL of the first photo** in the album you are using. -
  // ==UserScript==
+```
+// ==UserScript==
 // @name        google photos slower slideshow
 // @namespace   piframe
 // @include     https://photos.google.com/album/*
@@ -893,20 +879,21 @@ function next_or_prev() {
   }
 }
 window.setInterval(function(){next_or_prev()}, 600000);
-
+ +``` Now we're in business! With the photo display stuff figured out, I put the Pi Frame in its new home on my bookshelf. I nestled it in between my travel book collection, hooked up an extension cord to the Anker power adapter and hid the cable. - [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00129-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00129-1500.jpg) - - [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00138-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00138-1500.jpg) - - - - [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00151-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00151-1500.jpg) +[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00129-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00129-1500.jpg) + +[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00138-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00138-1500.jpg) + + + +[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00151-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00151-1500.jpg) @@ -921,20 +908,23 @@ I wrote two bash scripts. The first, `display_off.sh`, simply ran this command: The next script to turn the display back on was a bit trickier. This is what I put in my `display_on.sh` script: -
tvservice -p
-chvt 9 && chvt 7
-xrefresh -d :0
+``` +tvservice -p +chvt 9 && chvt 7 +xrefresh -d :0 +``` I tried a lot of stuff before I landed on something that worked. The chvt commands require sudo, so this script must always be run with sudo. I added the bash script to the sudoers file so that it at least doesn't ask for a password. I ran `sudo visudo` and added this line to the end (replace stammy with your Pi's username): -
stammy ALL=NOPASSWD: /home/stammy/display_on.sh
+ +``` +stammy ALL=NOPASSWD: /home/stammy/display_on.sh +``` #### Wiring up a button and fan With these two scripts I could SSH into the Pi and turn the display on and off. But SSHing into the Pi each time I wanted to toggle the display was going to be annoying. I decided to wire up a physical button to run this script for me. I soldered up a push button, hot glued it to the top right corner of the frame for easy access and attached it to GPIO pin 17 and GND. - - - [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00163-750.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00163-1500.jpg) +[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00163-750.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00163-1500.jpg) @@ -946,24 +936,18 @@ I rebuilt the relay circuit I talked about earlier in this article to control a -
- [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00168-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00168-1500.jpg) - -
- [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00172-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00172-1500.jpg) - -
- [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00183-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00183-1500.jpg) +[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00168-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00168-1500.jpg) + +[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00172-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00172-1500.jpg) + +[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00183-500.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00183-1500.jpg) With everything back in place, I put the Pi Frame back on the bookshelf. I just had to **write a python script to detect the button press** then appropriately trigger the display on or off bash script and trigger the fan relay. - - - - [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00201-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00201-1500.jpg) +[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00201-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00201-1500.jpg) @@ -972,7 +956,8 @@ With the button hooked up to GPIO pin 17 I setup that pin to listen for input. O Since I just have the push button connected to GND and a GPIO pin, I use a pull-up resistor so the GPIO pin will read high normally and read low when the button is pushed. This is a bit opposite of what you may expect, thus why the script below only acts when the input is detected as false. The other way to do this is to wire the push button to a 3.3V line and a GPIO pin with a pull-down resistor. That will get the GPIO input to be pulled down to low by default and go high when the button is pressed and the circuit closes. -
import RPi.GPIO as GPIO
+```
+import RPi.GPIO as GPIO
 import time
 import subprocess
 
@@ -994,22 +979,24 @@ while True:
                 display_on = True
                 GPIO.output(27, True)
                 subprocess.call("/home/stammy/display_on.sh", shell=True)
-                time.sleep(0.5)
+ time.sleep(0.5) +``` I connected the relay's signal line to GPIO pin 27 so I just needed to set that as output. Now I just listen for the button input and toggle between turning the display on and off. To actually run the aforementioned bash scripts I use the `subprocess.call()` lines. The `time.sleep()` lines are added in there so that holding the button a bit too long won't run the scripts multiple times. I saved the script as a python file and ran it in a terminal on the Pi. Again, I need sudo here for the chvt commands mentioned above: -
sudo python display_button.python
+
sudo python display_button.python
+```
 
 To make it easier whenever you reboot the Pi, you can add this as a custom application launcher in the top panel. Set it to Type: "Application in Terminal."
 
   
     
-      
+
     
   
 
@@ -1029,11 +1016,11 @@ I'm pretty impressed with the result of this little frame. Impressive, crisp ima
 
 
   
-          [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00203-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00203-1500.jpg)
-    
-  
-  
-          [![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00211-1280.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00211-1500.jpg)
+[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00203-1000.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00203-1500.jpg)
+
+
+
+[![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00211-1280.jpg)](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00211-1500.jpg)
     
   
 
@@ -1041,12 +1028,9 @@ I'm pretty impressed with the result of this little frame. Impressive, crisp ima
 Thanks for reading! If you've enjoyed this post I only ask that you please share it.
 
 
+[1](#r1) 只能运行较老的内核,并且软件支持更糟糕。
 
-
- -[1](#r1) Which can only run older kernels and has worse software support. - -[2](#r2) Such as turning off unused ports, onboard LEDs and reducing on external accessories as well as excess software consuming CPU cycles. [Here's an article](http://www.jeffgeerling.com/blogs/jeff-geerling/raspberry-pi-zero-conserve-energy "Raspberry Pi Zero - Conserve power and reduce draw to 80mA") that talks about doing this for the Pi Zero to reduce idle draw to a mere 80mA +[2](#r2) 例如,关闭不用的端口,板载LED,减少外设以及过度的软件消耗CPU周期。[这里是一篇文章](http://www.jeffgeerling.com/blogs/jeff-geerling/raspberry-pi-zero-conserve-energy "Raspberry Pi Zero - Conserve power and reduce draw to 80mA"),它谈到了对Pi Zero做这些操作,以减少空转,从而逼近仅仅80mA。 [3](#r3) There is actually [a way to go through the initial setup via USB](http://blog.gbaman.info/?p=791 "Raspberry Pi Zero - Programming over USB") without a display at all, but it's a bit more complicated than I'd like to explain in this post. You can also preconfigure and build an image that has SSH ready to go so you can do the entire setup via SSH on boot, or if you use Raspbian it has SSH enabled by default. You'll need to connect via Ethernet instead of Wi-Fi at first and [then follow these steps](http://raspberrypi.stackexchange.com/a/27352 "How to set up Raspberry Pi without a monitor?"). From d0fbe2cd311358955d289a7b83e1dac1f5c95c9c Mon Sep 17 00:00:00 2001 From: ictar Date: Fri, 30 Sep 2016 10:11:49 +0800 Subject: [PATCH 2/2] update --- ...rry Pi - Building a Digital Photo Frame.md | 61 ++++++++++--------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/raw/Getting started with Raspberry Pi - Building a Digital Photo Frame.md b/raw/Getting started with Raspberry Pi - Building a Digital Photo Frame.md index 4492efb..aab4867 100644 --- a/raw/Getting started with Raspberry Pi - Building a Digital Photo Frame.md +++ b/raw/Getting started with Raspberry Pi - Building a Digital Photo Frame.md @@ -152,67 +152,70 @@ Arduino是一个开源的微控制器,有I/O引脚来控制其他电子产品 * **数码相框** - 数码相框并非新玩意;Digital photo frames are nothing new; you probably remember the crappy versions years ago where you stuck an SD card in to play your photos. Well times have changed and tons of connected digital photo frames are on the market now. There's the $299 [Electric Objects EO1](https://www.electricobjects.com/), the $999+ [Klio](http://www.klioart.com/) and the $445+ [Meural digital canvas](https://meural.com/). So now lots of folks have turned to the Pi to build their own versions, including me (at the very bottom of this post!). + 数码相框并非新玩意;你可能还记得多年前的那个蹩脚的版本,那时,你将SD卡插进去来播放你的照片。嗯,时代已经变了,现在,市场上有大量的连接数码相框。有$299的[Electric Objects EO1](https://www.electricobjects.com/),$999+的[Klio](http://www.klioart.com/)和$445+的[Meural数字画布](https://meural.com/)。因此现在,大量的人都转向Pi来构建他们自己的版本,包括我(在这篇文章的最底部)。 ![digital picture frame](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-photo-frame-DSC00138-750.jpg) * **魔镜** - Smart mirrors are probably the most popular Raspberry Pi project in existence right now. They bring memories of futuristic movie interfaces and are relatively simple to build, especially with a large community developing them and [releasing software](https://github.com/MichMich/MagicMirror "Magic Mirror 2 the open source modular smart mirror platform") to drive them. In a nutshell: put a display running a full-page browser with a dark UI displaying info like news, weather or whatever is important to you behind a 2-way mirror and hang it in your house somewhere. There are lots of guides about this online: [1](https://www.reddit.com/r/raspberry_pi/comments/3oktfu/magic_mirror_how_to/ "Magic Mirror how to"), [2](http://michaelteeuw.nl/post/83188136918/magic-mirror-part-v-installing-the-raspberry-pi "Magic Mirror: Part V - Installing the Raspberry Pi"), [3](http://innate.cc/ "Smart Mirror Mini Form Factor Update"), [4](http://blog.dylanjpierce.com/raspberrypi/magicmirror/tutorial/2015/12/27/build-a-magic-mirror.html), [5](https://medium.com/@maxbraun/my-bathroom-mirror-is-smarter-than-yours-94b21c6671ba). + 魔镜可能是当下现存最受欢迎的树莓派项目。它们带来了你对未来电影界面的回忆,并且很简单就可以建立起来,特别是有一个大社区在开发它们,并且[发布软件](https://github.com/MichMich/MagicMirror "Magic Mirror 2 the open source modular smart mirror platform")来驱动它们。简而言之:将一个运行着使用黑色UI,并展示新闻、天气或者任何对你来说重要的东西的全页面浏览器的显示器放在双面镜后,然后把它挂在家里的某个地方。网上有许多关于它的指南:[1](https://www.reddit.com/r/raspberry_pi/comments/3oktfu/magic_mirror_how_to/ "Magic Mirror how to"),[2](http://michaelteeuw.nl/post/83188136918/magic-mirror-part-v-installing-the-raspberry-pi "Magic Mirror: Part V - Installing the Raspberry Pi"),[3](http://innate.cc/ "Smart Mirror Mini Form Factor Update"),[4](http://blog.dylanjpierce.com/raspberrypi/magicmirror/tutorial/2015/12/27/build-a-magic-mirror.html),[5](https://medium.com/@maxbraun/my-bathroom-mirror-is-smarter-than-yours-94b21c6671ba)。 ![smart/magic mirror](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-pi-smart-mirror.jpg) ![smart/magic mirror](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-max-smart-mirror.jpg) - Probably the [most popular magic mirror build](https://medium.com/@maxbraun/my-bathroom-mirror-is-smarter-than-yours-94b21c6671ba). This one was done with a Fire TV Android stick since the creator couldn't find a Pi Zero in stock at the time. Same concept though. + + 也许是[最流行的魔镜构建](https://medium.com/@maxbraun/my-bathroom-mirror-is-smarter-than-yours-94b21c6671ba)。这是用一个Fire电视Android棒完成的,因为创造者在当时买不到Pi Zero。但是是相同的概念。 -* Roll your own motion detecting Dropcam [with motionEyeOS](https://github.com/ccrisan/motioneyeos/wiki "motionEyeOS is a Linux distribution that turns a single-board computer into a video surveillance system.") -* [创建一个闹钟](https://georgecushen.com/spotify-alarm-clock-raspberry-pi-ubuntu-linux/ "Wake Up with Spotify Alarm Clock for Raspberry Pi") that plays music from Spotify -* Setup your own VPN server with [PiVPN (OpenVPN)](http://www.pivpn.io) for when you're not at home and connect to unsecure coffee shop Wi-Fi networks.* Build your own [portable Pi Desktop computer](https://learn.adafruit.com/10-raspberry-pi-desktop) or [tablet](http://francescopochetti.com/pipad-build-tablet-raspberry-pi/): +* [使用motionEyeOS](https://github.com/ccrisan/motioneyeos/wiki "motionEyeOS is a Linux distribution that turns a single-board computer into a video surveillance system."),运转你自己的运动检测Dropcam +* [创建一个闹钟](https://georgecushen.com/spotify-alarm-clock-raspberry-pi-ubuntu-linux/ "Wake Up with Spotify Alarm Clock for Raspberry Pi"),让它播放来自Spotify的音乐 +* 使用[PiVPN (OpenVPN)](http://www.pivpn.io)设置你自己的VPN服务器,当你不在家,并且连接到不安全的咖啡厅的Wi-Fi网络时,你可以用它。 +* 构建你自己的[便携式Pi台式电脑](https://learn.adafruit.com/10-raspberry-pi-desktop)或者[平板](http://francescopochetti.com/pipad-build-tablet-raspberry-pi/): ![Portable Pi Desktop computer](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-adafruit-pidesktop.jpg) ![Portable Pi tablet computer](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-pi-tablet-project.jpg) -* [Build a document scanner](http://www.instructables.com/id/Raspberry-Pi-Based-Document-Scanner-With-Automatic/ "Raspberry Pi Document Scanner With Automatic Upload to Dropbox") that automatically uploads to Dropbox -* Home theater PC with OpenElec, OSMC, Kodi, [RasPlex](https://github.com/RasPlex/RasPlex/releases "Rasplex is a community driven port of Plex Home Theater for the Raspberry Pi") or even [Android TV](https://github.com/peyo-hd/device_brcm_rpi3 "Android TV for Raspberry Pi 3") ([see video](https://www.youtube.com/watch?v=NMDf5thqoMk "Raspberry Pi 3 Running Android Tv OS and N64 , SNES emulator test")) -* Create an ["Onion Pi" Tor proxy](https://learn.adafruit.com/onion-pi/overview "Make a Raspberry Pi into a Anonymizing Tor Proxy") -* Setup an Ad blocker for your whole network with [Pi Hole](https://pi-hole.net/) -* Program your own Pi-based robot with the [GoPiGo robot kit](http://www.dexterindustries.com/GoPiGo/): + +* [构建一个文档扫描仪](http://www.instructables.com/id/Raspberry-Pi-Based-Document-Scanner-With-Automatic/ "Raspberry Pi Document Scanner With Automatic Upload to Dropbox"),它自动上传文档到Dropbox。 +* 连接OpenElec, OSMC, Kodi, [RasPlex](https://github.com/RasPlex/RasPlex/releases "Rasplex is a community driven port of Plex Home Theater for the Raspberry Pi")或者甚至是[Android TV](https://github.com/peyo-hd/device_brcm_rpi3 "Android TV for Raspberry Pi 3")的家庭影院电脑 ([见视频](https://www.youtube.com/watch?v=NMDf5thqoMk "Raspberry Pi 3 Running Android Tv OS and N64 , SNES emulator test"))。 +* 创建一个["洋葱Pi" Tor代理](https://learn.adafruit.com/onion-pi/overview "Make a Raspberry Pi into a Anonymizing Tor Proxy") +* 使用[Pi Hole](https://pi-hole.net/)为你的整个网络设置广告拦截 +* 使用[GoPiGo机器人套件](http://www.dexterindustries.com/GoPiGo/)编程你自己的基于Pi的机器人: ![gopigo robot kit](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-pi-gopigo-robot.jpg) -* DIY plant automatic watering system: [1](http://www.instructables.com/id/Automatic-Plant-Watering-and-Soil-Moisture-Sensing/ "Automatic Plant Watering and Soil Moisture Sensing"), [2](http://www.instructables.com/id/Raspberry-Pi-Irrigation-Controller/ "Raspberry Pi Irrigation Controller"), [3](https://hackaday.io/project/2711-autonomous-watering-system "Autonomous watering system"), [4](https://blog.serverdensity.com/automatically-watering-your-plants-with-sensors-a-pi-and-webhooks/) -* Make a [personal voice assistant](http://www.instructables.com/id/Raspberri-Personal-Assistant/?ALLSTEPS) -* Make a [portable gaming console](http://www.instructables.com/id/Raspberry-Pi-Portable-Games-Console/step6/Assembling-the-Console/), [Porta Pi Arcade system](http://www.instructables.com/id/Build-your-own-Mini-Arcade-Cabinet-with-Raspberry-/) or [Game Boy Zero](https://www.raspberrypi.org/blog/game-boy-zero/ "Game Boy Zero") using with [RetroPie](https://retropie.org.uk/). +* DIY植物自动浇水系统:[1](http://www.instructables.com/id/Automatic-Plant-Watering-and-Soil-Moisture-Sensing/ "Automatic Plant Watering and Soil Moisture Sensing"), [2](http://www.instructables.com/id/Raspberry-Pi-Irrigation-Controller/ "Raspberry Pi Irrigation Controller"), [3](https://hackaday.io/project/2711-autonomous-watering-system "Autonomous watering system"), [4](https://blog.serverdensity.com/automatically-watering-your-plants-with-sensors-a-pi-and-webhooks/) +* 弄个[个人语音助理](http://www.instructables.com/id/Raspberri-Personal-Assistant/?ALLSTEPS) +* 弄个[便携式游戏机](http://www.instructables.com/id/Raspberry-Pi-Portable-Games-Console/step6/Assembling-the-Console/), [便携式Pi街机系统](http://www.instructables.com/id/Build-your-own-Mini-Arcade-Cabinet-with-Raspberry-/)或者使用 [RetroPie](https://retropie.org.uk/)的[Game Boy Zero](https://www.raspberrypi.org/blog/game-boy-zero/ "Game Boy Zero")。 ![Portable Pi gaming console](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-pi-portable-games-console.jpg) ![Porta Pi Arcade](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-pi-arcade.jpg) ![Game Boy Zero](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-pi-gameboy-zero.jpg) -* Turn your Raspberry Pi into a gaming console with the [Lakka](http://www.lakka.tv/ "The open source game console") Linux distro -* Have your Pi run a [Twitter bot that tweets photos](http://blog.bandwidth.com/actually-using-your-raspberry-pi-part-4-twitter-bot/) from the Pi Camera -* DIY Pi-controlled espresso machine using [iSPRESSO](http://ispresso.net/ "iSPRESSO is an appliance modification comprised of Raspberry Pi computer, solid state relays, temp sensor, buttons and a display, a custom Printed Circuit Board, and custom linux shell scripts and a good bit of python code") -* [DIY Amazon Echo](https://github.com/amzn/alexa-avs-raspberry-pi) using Alexa voice service: +* 使用[Lakka](http://www.lakka.tv/ "The open source game console") Linux发行版,把你的树莓派编程一个游戏控制台 +* 让你的Pi运行一个[发照片的Twitter机器人](http://blog.bandwidth.com/actually-using-your-raspberry-pi-part-4-twitter-bot/),照片来自于Pi照相机 +* 使用[iSPRESSO](http://ispresso.net/ "iSPRESSO is an appliance modification comprised of Raspberry Pi computer, solid state relays, temp sensor, buttons and a display, a custom Printed Circuit Board, and custom linux shell scripts and a good bit of python code"),DIY Pi控制的咖啡机 +* 使用Alexa语音服务,[DIY Amazon Echo](https://github.com/amzn/alexa-avs-raspberry-pi): ![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-rpi-diy-alexa.jpg) -* Setup [wireless electrical outlets via RF modules](https://timleland.com/wireless-power-outlets/ "Wireless power outlets") made for the Pi or hack your own [voice-controlled electrical outlets](http://www.instructables.com/id/Wireless-Multi-Channel-Voice-Controlled-Electrical/): +* 为Pi定制[通过RF模块设置无线电源插座wireless electrical outlets via RF modules](https://timleland.com/wireless-power-outlets/ "Wireless power outlets") 或hack你自己的[声控电源插座](http://www.instructables.com/id/Wireless-Multi-Channel-Voice-Controlled-Electrical/): ![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-pi-wireless-voice-outlets.jpg) -* Create your own [BitTorrent downloading box](http://www.howtogeek.com/142044/how-to-turn-a-raspberry-pi-into-an-always-on-bittorrent-box/ "How to Turn a Raspberry Pi into an Always-On BitTorrent Box") -* Make a [Raspberry Pi server cluster](http://makezine.com/projects/build-a-compact-4-node-raspberry-pi-cluster/): +* 创建你自己的[BitTorrent下载盒](http://www.howtogeek.com/142044/how-to-turn-a-raspberry-pi-into-an-always-on-bittorrent-box/ "How to Turn a Raspberry Pi into an Always-On BitTorrent Box") +* 做一个[树莓派服务器集群](http://makezine.com/projects/build-a-compact-4-node-raspberry-pi-cluster/): ![pi cluster](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-picluster.jpg) -* Have the Raspberry Pi [open the door with a Slack chat command](http://blog.tryolabs.com/2016/06/01/raspberrypi-slack-our-humble-contribution-to-the-offices-laziness/ "RASPBERRY PI + SLACK: OUR HUMBLE CONTRIBUTION TO THE OFFICE¡¯S LAZINESS") -* Use it as a server for [Home Assistant](https://home-assistant.io/) or [pimatic](https://pimatic.org/ "pimatic is a home automation framework that runs on node.js. It provides a common extensible platform for home control and automation tasks") for all the connected devices and appliances in your home or [have it run HomeBridge](https://github.com/nfarina/homebridge/wiki/Running-HomeBridge-on-a-Raspberry-Pi "Homebridge is a lightweight NodeJS server you can run on your home network that emulates the iOS HomeKit API.") to allow Siri to control more home automation devices. -* Use your Pi to host any of these [free web applications yourself](https://github.com/Kickball/awesome-selfhosted/blob/master/README.md) -** DIY [Seenote](https://www.getseenote.com/) digital sticky note / to-do list -* [Write a Python web server](http://mattrichardson.com/Raspberry-Pi-Flask/) to control electronics connected to the Pi's GPIO pins from any browser -* Play a [MIDI file over a Tesla coil](https://www.youtube.com/watch?v=KhvExaTCXHA) -* Create a [high-res networked outdoor camera](http://blog.wq.lc/16-megapixel-outdoor-network-camera-on-the-cheap/ "16 Megapixel Outdoor Network Camera on the Cheap"): +* 让树莓派[根据Slack聊天命令开门](http://blog.tryolabs.com/2016/06/01/raspberrypi-slack-our-humble-contribution-to-the-offices-laziness/ "RASPBERRY PI + SLACK: OUR HUMBLE CONTRIBUTION TO THE OFFICE¡¯S LAZINESS") +* 对于你家里所有连接的设备和应用,把它当成[Home Assistant](https://home-assistant.io/)或者[pimatic](https://pimatic.org/ "pimatic is a home automation framework that runs on node.js. It provides a common extensible platform for home control and automation tasks")的服务器,或者[让它运行HomeBridge](https://github.com/nfarina/homebridge/wiki/Running-HomeBridge-on-a-Raspberry-Pi "Homebridge is a lightweight NodeJS server you can run on your home network that emulates the iOS HomeKit API."),从而允许Siri控制更多的家庭自动化设备。 +* 使用你的Pi来自己托管任意[免费的web应用](https://github.com/Kickball/awesome-selfhosted/blob/master/README.md) +** DIY [Seenote](https://www.getseenote.com/) 数字便条 / 待办事项列表 +* [写一个Python web服务器](http://mattrichardson.com/Raspberry-Pi-Flask/)来从任意浏览器控制连接到Pi的GPIO引脚的设备 +* [通过一个特斯拉线圈来播放MIDI文件](https://www.youtube.com/watch?v=KhvExaTCXHA) +* 创建一个[高分辨率网络户外摄像头](http://blog.wq.lc/16-megapixel-outdoor-network-camera-on-the-cheap/ "16 Megapixel Outdoor Network Camera on the Cheap"): ![](https://turbo.paulstamatiou.com/uploads/2016/06/pstam-networked-outdoor-picam.jpg) -* And [many](https://hackaday.io/list/3424-raspberry-pi-projects) more [projects](http://www.instructables.com/id/Raspberry-Pi-Projects/)... +* 以及[许多](https://hackaday.io/list/3424-raspberry-pi-projects)更多的[项目](http://www.instructables.com/id/Raspberry-Pi-Projects/)... #### Pi不大适合做什么?