树莓派GPIO库及RS485拓展版驱动安装

1.GPIO

树莓派GPIO库及RS485拓展版驱动安装_第1张图片

1.bcm2835库

wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.71.tar.gz
tar -xvf ./bcm2835-1.71.tar.gz
cd bcm2835-1.71/
./configure 
sudo make check
sudo make install
sudo ldconfig 

2.WiringPi库

git clone https://github.com/WiringPi/WiringPi.git
cd ~/wiringPi
./build

2.SSH密钥

ssh-keygen -t rsa -b 2048 -C [email protected] 

Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): <== 按 Enter
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): <== 输入密钥锁码,或直接按 Enter 留空
Enter same passphrase again: <== 再输入一遍密钥锁码
Your identification has been saved in /root/.ssh/id_rsa. <== 私钥
Your public key has been saved in /root/.ssh/id_rsa.pub. <== 公钥
The key fingerprint is:

cd .ssh
cat id_rsa.pub >> authorized_keys

编辑 /etc/ssh/sshd_config 文件,进行如下设置:

RSAAuthentication yes
PubkeyAuthentication yes
另外,请留意 root 用户能否通过 SSH 登录:

PermitRootLogin yes
当你完成全部设置,并以密钥方式登录成功后,再禁用密码登录:

PasswordAuthentication no
最后,重启 SSH 服务:

[root@host .ssh]$ service sshd restart

3.串口

1.GPIO模拟串口

树莓派GPIO库及RS485拓展版驱动安装_第2张图片

#配置串口
sudo vim /boot/config.txt
#添加
dtoverlay=uart2
dtoverlay=uart3
dtoverlay=uart4
dtoverlay=uart5

###
UART0: GPIO14 = TXD0 -> ttyAMA0     GPIO15 = RXD0 -> ttyAMA0
UART1: ttyS0
UART2: GPIO0  = TXD2 -> ttyAMA1     GPIO1  = RXD2 -> ttyAMA1
UART3: GPIO4  = TXD3 -> ttyAMA2     GPIO5  = RXD3 -> ttyAMA2
UART4: GPIO8  = TXD4 -> ttyAMA3     GPIO9  = RXD4 -> ttyAMA3
UART5: GPIO12 = TXD5 -> ttyAMA4     GPIO13 = RXD5 -> ttyAMA4

2.2-CH RS485 HAT(RS485拓展版)

1.拓展版资料

2-CH RS485 HAT - Waveshare Wiki

2.拓展版驱动

sudo nano /boot/config.txt
#加入如下,int_pin根据实际焊接方式设置:
dtoverlay=sc16is752-spi1,int_pin=24
#重启设备
sudo reboot

3.TTL串口登录

1.树莓派串口配置

sudo raspi-config

进入如下界面

树莓派GPIO库及RS485拓展版驱动安装_第3张图片

上下键选择第3项 Interfacing Options(接口选项),回车进入:

树莓派GPIO库及RS485拓展版驱动安装_第4张图片

选择I6,打开Serial Port 回到主界面 选择finish后重启

2.关闭蓝牙,打开串口,修改/boot下config.txt文件

sudo nano /boot/config.txt
#添加以下内容
dtoverlay=pi3-miniuart-bt

3.修改/boot下cmdline.txt

sudo nano /boot/cmdline.txt
#替换为以下内容
dwc_otg.lpm_enable=0 console=tty1 console=serial0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
#console=tty1 root=PARTUUID=469a1cec-02 rootfstype=ext4 fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles

4.接线

串口模块-----------------------树莓派
GND-----------------------------GND
RX---------------------------------TX
TX---------------------------------RX

你可能感兴趣的:(树莓派,物联网,开源)