Mac用串口(ttl)连接树莓派3b+以及串口调试

MacOSX用串口(TTL)连接树莓派

  • 树莓派在没有显示使用时,可以使用usb串口转ttl进行连接。
    USB转ttl线 CP2102下载对应的驱动
    USB转TTL 驱动下载地址:http://pan.baidu.com/s/1mgCFd9m
    安装完成后重启系统,插入 USB to TTL 线可查询串口设备。
1
2
$ ls /dev/tty.usbserial*   #在Mac是这个,去查看。插拔usb能够看到对应的设备
/dev/tty.usbserial

USB转TTL线

usbtoTTL

树莓派3b+引脚图
树莓派3b+引脚图

USB to TTL 线与树莓派针脚对应关系为:
GND -> GND
RXD -> GPIO 14(TXD)
TXD -> GPIO 15(RXD)
VCC -> 悬空 (切记, 不要乱接)

注意: 一定按照上面的对应关系,不要接成一样的。

配置minicom参数

运行

1
sudo minicom -s

进入minicom界面

1
2
3
4
5
6
7
8
9
10
11
12

┌─────[configuration]──────┐
│ Filenames and paths │
│ File transfer protocols │
│ Serial port setup │
│ Modem and dialing │
│ Screen and keyboard │
│ Save setup as dfl │
│ Save setup as.. │
│ Exit │
│ Exit from Minicom │
└──────────────────────────┘

使用上下键选择Serial port setup,回车。此时停留在change which setting? 通过A,B,C,D选项设置对应的参数设置例如下

1
2
3
4
5
6
7
8
9
10
11
12

┌───────────────────────────────────────────────────────────────────────┐
│ A - Serial Device : /dev/modem │
│ B - Lockfile Location : /usr/local/Cellar/minicom/2.7.1/var │
│ C - Callin Program : │
│ D - Callout Program : │
│ E - Bps/Par/Bits : 115200 8N1 │
│ F - Hardware Flow Control : Yes │
│ G - Software Flow Control : No │
│ │
│ Change which setting? │
└───────────────────────────────────────────────────────────────────────┘

配置选项目录

选择"Filenames and paths"

1
2
3
4
5
6
7
8
9
10
11

┌───────────────────────────────────────────────────────────────────────┐
│ A - Download directory : /home/wonux │
│ B - Upload directory : /tmp │
│ C - Script directory : /root/minicom │
│ D - Script program : runscript or /bin/bash │
│ E - Kermit program : │
│ F - Logging options │
│ │
│ Change which setting? │
└───────────────────────────────────────────────────────────────────────┘

常用配置总结:

  • 选择Serial port setup
    配置选项如下:
1
2
3
4
A - Serial Device : /dev/modem 
E - Bps/Par/Bits : 115200 8N1
F - Hardware Flow Control : No
G - Software Flow Control : No
  • 选择Filenames and paths
    配置其中的如下配置项:
1
2
C - Script directory : /root/minicom
D - Script program : /bin/bash

C:脚本文件的存放位置: g运行脚本时的路径 。
D:选择脚本程序: 默认runscript,也可以选择bash脚本格式。

树莓派3b+添加散热外壳

在某宝上买了一个外壳。
树莓派3b+外壳

线与树莓派针脚对应关系为:
红色-> +5v
黑色-> GND #地线
成品

mac串口调试工具minicom

我们使用常用的串口工具,如:minicom, screen 使用 115200 进行连接。它们的安装也非常的方便:

1
2
3
4
5
6
7
8
9
# 安装 minicom
$ brew install minicom
# 进行配置后再进行连接
$ minicom -s

# 安装 screen
$ brew install screen
# 进行连接
screen /dev/tty.usbserial 115200

连接后我们输入默认的账号和密码

1
2
用户名:pi
密码:raspberry

树莓派连接上网设置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB

network={
ssid="######" #wifi 名称
psk="*******" #wifi密码
proto=RSN
key_mgmt=WPA-PSK #加密方式
pairwise=CCMP
auth_alg=OPEN
}

network={
ssid="#######"
psk="**********"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
auth_alg=OPEN
}
~

完整呈现:
呈现raspberry

参考资料: