「Efficient Android Threading 笔记」- C1 Android Components and the Need for Multiprocessing Android RecyclerView Android Socket Programming Supporting Multiple Screens Make a Reusable UI in Android App Development 如何在 Android Studio 中包含 *.so library,并使用库中定义的方法? 使用 SpannableString 格式化字符串,实现前景色、下划线、超链接、图文混排等 如何使用 bound service 完成进程间通信? 创建自定义视图 Creating custom views 通过 Android Theme & Style 定制应用的样式 「译」Android ViewPropertyAnimator 介绍 Android Animation Interpolator - Android 动画插值器源码笔记 「译」Android Animation in Honeycomb by Chet Haase(Android 3.0系统中的动画机制) 从 Android Sample ApiDemos 中学习 android.animation API 的用法 如何学习 Android Animation? 如何实现 Android ListView「上拉加载更多」? 「译」向Big Nerd Ranch提问:为什么Fragment在Android App开发中非常重要? 分类整理我在 SegmentFault 上针对某些问题作的回答 Android Servcie 后台服务总结笔记 如何在Android设备旋转时暂存数据以保护当前的交互状态? Android Message Handler 消息处理机制总结笔记 如何获取FragmentTabHost中指定标签页的Fragment? Fragment子类必须包含一个public无参构造器 如何更新及替换ViewPager中的Fragment? 如何使用Android UI Fragment开发“列表-详情”界面? 一个Android音频文本同步的英文有声读物App的开发过程 「Android编程权威指南笔记」Android应用本地化 通过jfeinstein10/SlidingMenu实现Android侧滑菜单 为Ubuntu14.04部署Android App的Eclipse开发环境 「Android编程权威指南笔记」使用ListFragment显示列表 「Android编程权威指南笔记」SDK版本与兼容 「Android编程权威指南笔记」Android布局和组件 「Android编程权威指南笔记」UI Fragment 「Android编程权威指南笔记」Activity 第一次开发iOS App和Android的对比总结笔记 「App Training笔记」创建第一个应用 「App Training笔记」开发入门训练大纲 Android APP - 从远程FTP服务器下载文件到本地

上手树莓派

2016年03月19日

关于树莓派

树莓派 是一个只有信用卡大小的计算机。连接显示器、键盘、鼠标、网络后,就是一台完整的计算机。当然性能不好,也不好用,但好玩、可玩。

作为「程序猿要从小培养」这个信条的实践者,树莓派也被应用于儿童编程教育

去掉几乎所有外设接口的核心板 raspberry-zero 只有完整版的 1/3 大小,适合作为物联网的终端数据采集设备。

快速入门

官网新手快速入门 Quick start guide

没有外接显示器、没有键盘、没有鼠标的情况下如何使用树莓派?

至少要有一根网线接入局域网,通过 ssh 远程控制。没有显示器也就无法通过「安装向导」来安装操作系统,所以必须制作一张特殊的启动卡:

制作 boot sdcard 以安装操作系统(针对 MAC)

参考 COMMAND LINE 这一小节。

ssh 远程操作

使用 $ arp -a 命令列出的局域网设备 ?(192.168.0.*),并没有看到类似 raspberrypi.home (192.168.1.8)。既然无法识别树莓派(树莓派的网口灯是绿色,所以应该是已经联网了),只能挨个 IP 测试:


$ arp -a

? (192.168.0.1) at c8:3a:35:5c:ad:c8 on en0 ifscope [ethernet]

? (192.168.0.103) at b8:27:eb:d9:ac:2e on en0 ifscope [ethernet]



$ ssh [email protected]

ssh: connect to host 192.168.0.1 port 22: Network is unreachable



$ ssh [email protected]

The authenticity of host '192.168.0.103 (192.168.0.103)' can't be established.

ECDSA key fingerprint is SHA256:6zCLSeIvX4Cy55dK3mdnWznXfIidzKcCkxJVkuGJHkA.

Are you sure you want to continue connecting (yes/no)? yes

此处输入 yes,继续:


Warning: Permanently added '192.168.0.103' (ECDSA) to the list of known hosts.

[email protected]'s password: 

此处输入默认密码 raspberry,成功登录 raspberry ;-))


The programs included with the Debian GNU/Linux system are free software;

the exact distribution terms for each program are described in the

individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent

permitted by applicable law.

Last login: Fri Feb 26 02:21:14 2016



pi@raspberrypi:~ $ ls

Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos  python_games

虽然安装的是 raspbian-jessie.img,但目前来看和 Ubuntu 某些方面一致,比如包管理工具都是 apt-get,接下来安装 VNC 和 Camera 时会用到。

https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=74176

为 Raspberry 安装 vnc service

除了命令行,还可以通过 VNC。使用 官网给出的方法 时遇到了如下问题:


pi@raspberrypi:~ $ tightvncserver 

perl: warning: Setting locale failed.

perl: warning: Please check that your locale settings:

LANGUAGE = (unset),

LC_ALL = (unset),

LC_CTYPE = "UTF-8",

LANG = "en_GB.UTF-8"

    are supported and installed on your system.

perl: warning: Falling back to a fallback locale ("en_GB.UTF-8").

tightvncserver: Could not create /home/pi/.vnc.

解决问题的方法


$ sudo locale-gen

$ sudo dpkg-reconfigure locales

执行第二条命令时会弹出「Configuring locales」的对话框,勾选需要的,然后「Ok」:

再次启动 tightvncserver 就 OK 了,然后输入密码,正常启动应该会看到 Log file is /root/.vnc/raspberrypi:1.log


pi@raspberrypi:~ $ sudo tightvncserver

You will require a password to access your desktops.

Password: 

Verify:   

Would you like to enter a view-only password (y/n)? n

xauth:  file /root/.Xauthority does not exist



New 'X' desktop is raspberrypi:1



Creating default startup script /root/.vnc/xstartup

Starting applications specified in /root/.vnc/xstartup

Log file is /root/.vnc/raspberrypi:1.log

with full HD resolution:


pi@raspberrypi:~ $ sudo vncserver -kill :1

Killing Xtightvnc process ID 2350



pi@raspberrypi:~ $ sudo vncserver :1 -geometry 1920x1080 -depth 24

New 'X' desktop is raspberrypi:1

Starting applications specified in /root/.vnc/xstartup

Log file is /root/.vnc/raspberrypi:1.log

在 MAC 使用 RealVNC 连接 Raspberry VNC Service

https://www.raspberrypi.org/documentation/remote-access/vnc/mac.md

使用树莓派摄像头模块

https://www.raspberrypi.org/documentation/usage/camera/README.md

拍照

定时拍照

录视频

实时监控

存储空间不够!


pi@raspberrypi:~ $ raspistill -o cam.jpg

mmal: Unable to write buffer to file - aborting



pi@raspberrypi:~ $ df -h

Filesystem      Size  Used Avail Use% Mounted on

/dev/root       3.6G  3.5G     0 100% /



pi@raspberrypi:~ $ ls /u-bash: cannot create temp file for here-document: No space left on device

-bash: cannot create temp file for here-document: No space left on device

解决办法:sudo raspi-config,then select “expand_rootfs”。

https://steve0hh.wordpress.com/2013/02/10/raspberry-pis-no-space-left-on-device-error-message/


pi@raspberrypi:~ $ df -h

Filesystem      Size  Used Avail Use% Mounted on

/dev/root        29G  3.5G   24G  13% /


知识共享许可协议
li2的博客WeiYi.Li 创作,采用 知识共享 署名-非商业性使用 4.0 国际 许可协议进行许可。
© 2011-2022. All rights reserved by WeiYi.Li. Powerd by Jekyll & LinAnYa's Theme