准备microsd卡,下载Raspbian系统https://www.raspberrypi.org/
df -h
diskutil list
diskutil unmount xxx
dd bs=4m if=xxx.img of=/dev/xxx
参考http://my.oschina.net/u/2306127/blog/387694
找个路由器,在路由器里找到ip,用xmanager或者ssh登录
#!/usr/bin/python
#coding: utf-8
import smtplib
from email.mime.text import MIMEText
from email.header import Header
import datetime
# 设置发送邮件的账号
from_user = ''
from_password = ''
smtpserver = smtplib.SMTP('smtp.163.com', 25)
smtpserver.login(from_user, from_password)
smtpserver.ehlo()
# 生成邮件并发送
to = ''
my_ip = '树莓派ip地址为%s' % ipaddr
msg = MIMEText(my_ip,'text','utf-8')
today = datetime.date.today()
msg['Subject'] = Header('树莓派ip地址邮件-%s' % today.strftime('%m %d %Y'),'utf-8')
msg['From'] = from_user
msg['To'] = to
smtpserver.sendmail(from_user, [to], msg.as_string())
smtpserver.quit()
# 查找本机ip地址
arg='ip route list'
p=subprocess.Popen(arg,shell=True,stdout=subprocess.PIPE)
data = p.communicate()
split_data = data[0].split()
ipaddr = split_data[split_data.index('src')+1]
#!/usr/bin/python
#coding: utf-8
import smtplib
from email.mime.text import MIMEText
from email.header import Header
import datetime
# 查找本机ip地址
arg='ip route list'
p=subprocess.Popen(arg,shell=True,stdout=subprocess.PIPE)
data = p.communicate()
split_data = data[0].split()
ipaddr = split_data[split_data.index('src')+1]
# 设置发送邮件的账号
from_user = ''
from_password = ''
smtpserver = smtplib.SMTP('smtp.163.com', 25)
smtpserver.login(from_user, from_password)
smtpserver.ehlo()
# 生成邮件并发送
to = ''
my_ip = '树莓派ip地址为%s' % ipaddr
msg = MIMEText(my_ip,'text','utf-8')
today = datetime.date.today()
msg['Subject'] = Header('树莓派ip地址邮件-%s' % today.strftime('%m %d %Y'),'utf-8')
msg['From'] = from_user
msg['To'] = to
smtpserver.sendmail(from_user, [to], msg.as_string())
smtpserver.quit()
配置开机自动连接到wifi,为了方便我配置到我的360随身wifi上
相关命令
iwlist scanning
sudo vi /etc/network/interfaces
<
auto lo
iface lo inet loopback
iface eth0 inet dhcp
auto wlan0
#allow-hotplug wlan0
#iface wlan0 inet manual
iface wlan0 inet dhcp
wpa-conf /etc/wpa.conf
#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
>
sudo vi /etc/wpa.conf
<
network={
[Tab] ssid="你的无线网络名称(ssid)"
[Tab] key_mgmt=WPA-PSK
[Tab] psk="你的wifi密码"
}
>
参考:
http://www.douban.com/note/449341604/?from=tag
http://m.blog.csdn.net/blog/shooter32/45126525
http://blog.chinaunix.net/uid-24017974-id-2644027.html
在/home/pi目录下创建send_ip.py文件,将6中的代码复制过来,在/etc/rc.local文件里添加一行
/usr/bin/python /home/pi/send_ip.py
以上树莓派的准备工作就完成了,可以较为方便的登陆树莓派了,然而也有很多缺陷,比如一定要能联网、在新的wifi环境下不能连接等等问题。