树莓派ZeroW 安装软件工具(数据远程采集)

树莓派型号:Zero W

树莓派系统:Raspbian,2018-11-13-raspbian-stretch-lite.img

待安装软件工具:

pip Python 包管理工具,提供了对Python 包的查找、下载、安装、卸载的功能
pyserial Python的串口通讯包
python-psutil Process and System Utilities。访问系统CPU,内存,磁盘,网络等;进程管理(判断进程是否存在、获取进程列表、获取进程详细信息);命令行工具的功能(ps,top,lsof,netstat,ifconfig, who,df,kill,free,nice,ionice,iostat,iotop,uptime,pidof,tty,taskset,pmap)
ntp Network Time Protocol。提供时间同步服务
oss2 阿里云对象存储(oss)的Python工具包



电脑和树莓派连接同一个无线网络,使用PuTTY登录SSH(Host Name:raspberrypi.local,Port:22,点击Open)。


image


输入用户名(默认:pi)和密码(默认:raspberry)

image


安装pip


查看有没有安装pip,显示pip还没有装

pi@raspberrypi:~ $ pip --version

image


下载安装脚本get-pip.py

pi@raspberrypi:~ $ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

image


运行安装脚本get-pip.py

pi@raspberrypi:~ $ sudo python get-pip.py

上面默认是从国外的服务器下载相关软件包的,我们最好指定一个国内的软件包镜像源,下载速度会快很多。

pi@raspberrypi:~ $ sudo python get-pip.py -i https://pypi.tuna.tsinghua.edu.cn/simple

显示这个脚本下载安装了pip-20.0.2, setuptools-44.1.0, wheel-0.34.2这三个软件工具。

image


查看pip版本,显示正常,表示pip已经安装成功

pi@raspberrypi:~ $ pip --version

image


安装pyserial


用pip工具安装pyserial,指定国内的镜像源:

pi@raspberrypi:~ $ sudo pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyserial

image


安装oss2


用pip工具安装oss2,指定国内的镜像源:

pi@raspberrypi:~ $ sudo pip install -i https://pypi.tuna.tsinghua.edu.cn/simple oss2

image

image


安装python-psutil

需要用到aptitude来安装python-psutil,这个工具在装系统的时候已经自动安装上了。

如果没装的话先安装:

pi@raspberrypi:~ $ sudo apt-get install aptitude

查看aptitude的版本:

pi@raspberrypi:~ $ python-dev --version

image

安装python-psutil

pi@raspberrypi:~ $ sudo aptitude install python-psutil

image


安装ntp


存储数据帧时需要加上时间戳,ntp服务可以让树莓派与网络时间保持同步。

pi@raspberrypi:~ $ sudo apt-get install ntp

image

选择Y

image

pi@raspberrypi:~ $ sudo apt-get install ntpdate

image

查看当前时间,可以看到默认采用英国时间(BST, British Summer Time)

pi@raspberrypi:~ $ date

image

配置时区

pi@raspberrypi:~ $ sudo dpkg-reconfigure tzdata

在弹出的配置窗口中选择Asia,回车

image

在下一页窗口中,选择Shanghai(按 S 键可以快速定位到S开头的城市),回车确认

image

显示配置结果,时间已经正常了

image

编辑ntp.conf文件

pi@raspberrypi:~ $ sudo nano /etc/ntp.conf

在这两句的后面增加增加国内的ntp服务器地址,保存退出

# You do need to talk to an NTP server or two (or three).
#server ntp.your-provider.example

server ntp.fudan.edu.cn iburst perfer
server time.asia.apple.com iburst
server asia.pool.ntp.org iburst
server ntp.nict.jp iburst
server time.nist.gov iburst

image

重启ntp服务,并查看时间

pi@raspberrypi:~ $ sudo /etc/init.d/ntp restart

pi@raspberrypi:~ $ date

image



>> [入口] 数据远程采集 Step by Step

猜你喜欢

转载自www.cnblogs.com/hotwater99/p/12737451.html