一:格式化SD卡SD卡插入读卡器连接电脑,使用SDFormatter对SD卡进行格式化 (重装烧录也要进行着SD卡格式化操作) 二:下载官方镜像http://downloads./raspbian_latest 三:烧录SD卡使用Win32DiskImager将镜像烧录到格式化后的SD卡 SD卡盘根目录(/boot**)下新建一个命名为ssh的文件(无后缀)** 四:Putty连接连接电源和网线,找到raspberry ip, putty连接 物理连接将树莓派通过网线直接连接笔记本电脑,若笔记本电脑已经使用有线方式连接互联网,占用了网口,则需要使用usb网口转换器拓展笔记本网口。 网络设置此时,打开网络适配器设置,此时我们可以看到已经连接互联网的网络和与树莓派连接的网络。 1. 设置网络共享 右击连接至互联网的网络 –> 属性 –> 共享选项卡 –> 勾选“允许其他网络用户通过此计算机的Internet连接来连接” –> 在家庭网络连接下面的下拉菜单中选择 “树莓派的网络” –>点击确认(出现将ip设置为“192.168.137.1”的提示也点击确定) 2.查询树莓派的IP
此命令可查询与笔记本电脑又网络交互的IP地址,在接口:192.168.137.1中找到树莓派的IP(由一个或两个有数值的,可以都试一下) 如果查询不到重新插拔树莓派的网线即可。 树莓派的IP是动态变化的,如果出现连不上需要重新用网线连接,然后重复以上步骤。 3.利用Putty连接(port:22) 如果ip正确会要求输入用户名和密码(pi+raspberry)à连接成功 配置国内源 (如果不配置速度会很慢) https://blog.csdn.net/happygoes/article/details/80715755 五:开启VNCserver因为之前官方系统没有自带VNC,但是现在最新版的官方系统已经自带VNCserver,只需要在设置里启用一下,然后设置就可以用啦。 连接树莓派,记得在IP后面加上端口号,默认是 :1 1、(putty操作)打开树莓派设置 sudo raspi-config,选择 5、Interfacing Options ,然后回车: 2、选择3 VNC,再回车:: 3、选择yes: exit退出 4、安装vim: sudo apt-get install vim 更改配置文件:sudo vim /etc/init.d/vncserver #!/bin/sh ### BEGIN INIT INFO # Provides: vncserver # Required-Start: $local_fs # Required-Stop: $local_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start/stop vncserver ### END INIT INFO # More details see: # http://www./linux/vnc ### Customize this entry # Set the USER variable to the name of the user to start vncserver under export USER='pi’ ### End customization required eval cd ~$USER case “$1” in start) # 启动命令行。此处自定义分辨率、控制台号码或其它参数。 su $USER -c '/usr/bin/vncserver -depth 16 -geometry 1024x768 :1’ echo "Starting VNC server for $USER " ;; stop) # 终止命令行。此处控制台号码与启动一致。 su $USER -c '/usr/bin/vncserver -kill :1’ echo “vncserver stopped” ;; *) echo “Usage: /etc/init.d/vncserver {start|stop}” exit 1 ;; esac exit 0 5、修改权限:
6、设置开机自启动:
7、重启服务器:sudo reboot 六:VNC调整显示分辨率Putty登录 sudo raspi-config 重启后,使用VNC重新连接 七:更新系统安装程序apt-getApt-get update Apt-get upgrade 八:安装python3默认安装为python2.7 sudo apt-get install python3 sudo apt-get install python3-pip 更改默认使用版本: sudo rm /usr/bin/python sudo ln -s /usr/bin/python3.5 /usr/bin/python 使用Python命令,此时默认版本更改为3.5 (通过pip安装pyaudio库、 wave库 、baidu-aip库、wxpy库、opencv库、face_conigintio库) #! /usr/bin/python # coding = utf-8 import urllib.request import json ApiUrl= “http://www.weather.com.cn/data/sk/101230201.html” html=urllib.request.urlopen(ApiUrl) #读取并解码 data=html.read().decode(“utf-8”) #将JSON编码的字符串转换回Python数据结构 ss=json.loads(data) info=ss['weatherinfo’] print('城市:%s’%info['city’]) print('温度:%s度’%info['temp’]) print('风速:%s’%info['WD’],info['WS’]) print('湿度:%s’%info['SD’]) print('时间:%s’%info['time’]) 九.Wifi设置sudo raspi-config 输入wifi名称(不要有中文字符): 输入wifi密码: OK保存 通过VNC进入图形界面选择wifi country
此时可见wifi图标已连接 PUTTY命令行查询无线网卡地址:ifconfig 此时可见无线网卡地址,再通过putty和VNC重新连接这个地址 连接成功后,至此可以移除网线,改用wifi连接 |
|