树莓派随笔
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了树莓派随笔相关的知识,希望对你有一定的参考价值。
- 1.2GHz 四核 Broadcom BCM2837 64 位 ARMv8 处理器
- 板载 BCM43143 WiFi
- 板载低功耗蓝牙 (BLE) 蓝牙和wifi使用的是BCM43438芯片,博通公司的
- 1GB RAM
- 4 个 USB 2 端口
- 40 针扩展 GPIO
- HDMI 和 RCA 视频输出
查看ip地址
[email protected]:~ $ hostname -I
192.168.1.105 192.168.43.75
查看文件 cat 《文件名》
创建目录 mkdri 《文件夹名》
删除目录
[email protected]:~ $ hostname -I
192.168.1.105 192.168.43.75
查看文件 cat 《文件名》
创建目录 mkdri 《文件夹名》
删除目录
rmdri 《文件夹名》
2016/4/20 19:50
统安装的是官网上最新的RASPBIAN JESSIE,接了显示屏可以看到系统正常启动,但是用putty串口通信的时候,启动信息全是乱码。putty的字符集已经设为UTF-8了。
连键盘输入的时候都是乱码
树莓派3串口和蓝牙串口混用了,网上有篇帖子专门说了这个问题的解决方法,用串口调试就不能用蓝牙了
然后用了hss 可以连这个软件xshell这样就可以,没啥遇到的问题,问题还是在liunx系统的使用,我用到是指令,还是不太知道指令的作用。
用指令下载安装vim,这个害我好久了。
sudo apt-get install -y vim
查看内存卡使用情况
df -hl
切换路径,就是不同文件地方
cp
gpio安装
WiringPi简介
WiringPi是应用于树莓派平台的GPIO控制库函数,WiringPi遵守GUN Lv3。wiringPi使用C或者C++开发并且可以被其他语言包转,例如python、ruby或者php等。WiringPi中的函数类似于Arduino的wiring系统,这使得熟悉arduino的用户使用wringPi更为方便。
树莓派具有26个普通输入和输出引脚。在这26个引脚中具有8个普通输入和输出管脚,这8个引脚既可以作为输入管脚也可以作为输出管脚。除此之外,树莓派还有一个2线形式的I2C、一个4线形式的SPI和一个UART接口。树莓派上的I2C和SPI接口也可以作为普通端口使用。如果串口控制台被关闭便可以使用树莓派上的UART功能。如果不使用I2C,SPI和UART等复用接口,那么树莓派总共具有8+2+5+2 =17个普通IO。wiringPi包括一套gpio控制命令,使用gpio命令可以控制树莓派GPIO管脚。用户可以利用gpio命令通过shell脚本控制或查询GPIO管脚。wiringPi是可以扩展的,可以利用wiringPi的内部模块扩展模拟量输入芯片,可以使用MCP23x17/MCP23x08(I2C 或者SPI)扩展GPIO接口。另外可通过树莓派上的串口和Atmega(例如arduino等)扩展更多的GPIO功能。另外,用户可以自己编写扩展模块并把自定义的扩展模块集成到wiringPi中。WiringPi支持模拟量的读取和设置功能,不过在树莓派上并没有模拟量设备。但是使用WiringPi中的软件模块却可以轻松地应用AD或DA芯片
方案A——使用GIT工具
如果在你的平台上还没有安装GIT工具,可以输入以下命令:
sudo apt-get install git-core
如果在这个过程中出现错误,尝试更新软件,例如输入以下指令:
sudo apt-get update
sudo apt-get upgrade
紧接着可以通过GIT获得wiringPi的源代码
git clone git://git.drogon.net/wiringPi
若需要更新wiringPi。
cd wiringPi
git pull origin
进入wiringPi目录并安装wiringPi
cd wiringPi
./build
build脚本会帮助你编译和安装wiringPi
查看是否安装成功
gpio readall
编程C语言
用vim编写一个c文件
vim name1.c
用gcc编译c文件
gcc name1.c -o name1
运编译文件
./name1
2016/4/21 19:51
定位语法错误需要借助 make 命令
make
首先声明一下,他妈的这个和直接的c编译指令是不同的,因为这个不同导致我在这里浪费了一个下午。
我用c语言编译的办法编译会出现没有定义一些函数。
然后通过gcc编译。-lwiringPi表示动态加载wiringPi共享库 gcc test.c -lwiringPi
执行程序 sudo ./a.out
make
首先声明一下,他妈的这个和直接的c编译指令是不同的,因为这个不同导致我在这里浪费了一个下午。
我用c语言编译的办法编译会出现没有定义一些函数。
然后通过gcc编译。-lwiringPi表示动态加载wiringPi共享库 gcc test.c -lwiringPi
执行程序 sudo ./a.out
用过linux的都知道,在linux下编译链接程序,如果不加-o参数,生成的binary代码的名字都是默认的a.out。一不小心,a.out还会覆盖上次其他code生成的binary代码。
蓝牙
[email protected]:~ $ sudo bluetoothctl //开启蓝牙命令
[NEW] Controller B8:27:EB:47:FF:4A raspberrypi [default]
[bluetooth]# list //列表
Controller B8:27:EB:47:FF:4A raspberrypi [default]
[bluetooth]# scan on //扫描
Discovery started
[CHG] Controller B8:27:EB:47:FF:4A Discovering: yes
[NEW] Device 10:2A:B3:A3:6A:5B 红米手机
[CHG] Device 10:2A:B3:A3:6A:5B RSSI: -63
[CHG] Device 10:2A:B3:A3:6A:5B RSSI: -73
[NEW] Device 84:73:03:70:A1:03 haohanlin
[CHG] Device 10:2A:B3:A3:6A:5B RSSI: -63
[CHG] Device 10:2A:B3:A3:6A:5B RSSI: -73
[CHG] Device 10:2A:B3:A3:6A:5B RSSI: -64
[bluetooth]# pair 84:73:03:70:A1:03 //连接配对
Attempting to pair with 84:73:03:70:A1:03
[CHG] Device 84:73:03:70:A1:03 Connected: yes
[CHG] Device 84:73:03:70:A1:03 Modalias: bluetooth:v0046p0802d0903
[CHG] Device 84:73:03:70:A1:03 UUIDs:
00001105-0000-1000-8000-00805f9b34fb
0000110a-0000-1000-8000-00805f9b34fb
0000110c-0000-1000-8000-00805f9b34fb
0000110f-0000-1000-8000-00805f9b34fb
00001112-0000-1000-8000-00805f9b34fb
00001115-0000-1000-8000-00805f9b34fb
00001116-0000-1000-8000-00805f9b34fb
0000111f-0000-1000-8000-00805f9b34fb
0000112f-0000-1000-8000-00805f9b34fb
00001132-0000-1000-8000-00805f9b34fb
00001200-0000-1000-8000-00805f9b34fb
00001800-0000-1000-8000-00805f9b34fb
[CHG] Device 84:73:03:70:A1:03 Paired: yes
Pairing successful
[CHG] Device 84:73:03:70:A1:03 Connected: no
[bluetooth]# trust 84:73:03:70:A1:03 //获得信任
[CHG] Device 84:73:03:70:A1:03 Trusted: yes
Changing 84:73:03:70:A1:03 trust succeeded
[CHG] Device 10:2A:B3:A3:6A:5B RSSI: -74
[CHG] Device 10:2A:B3:A3:6A:5B RSSI: -65
[NEW] Controller B8:27:EB:47:FF:4A raspberrypi [default]
[bluetooth]# list //列表
Controller B8:27:EB:47:FF:4A raspberrypi [default]
[bluetooth]# scan on //扫描
Discovery started
[CHG] Controller B8:27:EB:47:FF:4A Discovering: yes
[NEW] Device 10:2A:B3:A3:6A:5B 红米手机
[CHG] Device 10:2A:B3:A3:6A:5B RSSI: -63
[CHG] Device 10:2A:B3:A3:6A:5B RSSI: -73
[NEW] Device 84:73:03:70:A1:03 haohanlin
[CHG] Device 10:2A:B3:A3:6A:5B RSSI: -63
[CHG] Device 10:2A:B3:A3:6A:5B RSSI: -73
[CHG] Device 10:2A:B3:A3:6A:5B RSSI: -64
[bluetooth]# pair 84:73:03:70:A1:03 //连接配对
Attempting to pair with 84:73:03:70:A1:03
[CHG] Device 84:73:03:70:A1:03 Connected: yes
[CHG] Device 84:73:03:70:A1:03 Modalias: bluetooth:v0046p0802d0903
[CHG] Device 84:73:03:70:A1:03 UUIDs:
00001105-0000-1000-8000-00805f9b34fb
0000110a-0000-1000-8000-00805f9b34fb
0000110c-0000-1000-8000-00805f9b34fb
0000110f-0000-1000-8000-00805f9b34fb
00001112-0000-1000-8000-00805f9b34fb
00001115-0000-1000-8000-00805f9b34fb
00001116-0000-1000-8000-00805f9b34fb
0000111f-0000-1000-8000-00805f9b34fb
0000112f-0000-1000-8000-00805f9b34fb
00001132-0000-1000-8000-00805f9b34fb
00001200-0000-1000-8000-00805f9b34fb
00001800-0000-1000-8000-00805f9b34fb
[CHG] Device 84:73:03:70:A1:03 Paired: yes
Pairing successful
[CHG] Device 84:73:03:70:A1:03 Connected: no
[bluetooth]# trust 84:73:03:70:A1:03 //获得信任
[CHG] Device 84:73:03:70:A1:03 Trusted: yes
Changing 84:73:03:70:A1:03 trust succeeded
[CHG] Device 10:2A:B3:A3:6A:5B RSSI: -74
[CHG] Device 10:2A:B3:A3:6A:5B RSSI: -65
[CHG] Device 84:73:03:70:A1:03 RSSI: -72
开启蓝牙:/etc/init.d/bluetooth start
扫描设备:hcitool scan
关闭板载蓝牙的方法:
1.SSH登录树莓派3后,输入下面命令关闭hciuart使用uart0.
sudo systemctl disable hciuart
2.编辑/lib/systemd/system/hciuart.server 将 “ttyAMA0”修改为“ttyS0”
sudo nano /lib/systemd/system/hciuart.service
将 “ttyAMA0”修改为“ttyS0”
保存退出
3.更新并重启
sudo apt-get update
sudo apt-get upgrade
sudo reboot
WIFI设置
[email protected]:~ $ sudo iwlist wlan0 scan //扫描wifi
wlan0 Scan completed :
Cell 01 - Address: FC:D7:33:F1:AC:EA //第一wifi
Channel:1
Frequency:2.412 GHz (Channel 1)
Quality=35/70 Signal level=-75 dBm
Encryption key:on
ESSID:"WVLan" //名字
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
9 Mb/s; 12 Mb/s; 18 Mb/s
Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s
Mode:Master
Extra:tsf=0000000000000000
Extra: Last beacon: 70ms ago
IE: Unknown: 000557564C616E
IE: Unknown: 010882848B960C121824
IE: Unknown: 030101
IE: Unknown: 0706434E20010D20
IE: Unknown: 2A0100
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: Unknown: 32043048606C
IE: Unknown: 2D1A6E101BFFFFFF0000000000000000008000000000000000000000
IE: Unknown: 331A6E101BFFFFFF0000000000000000008000000000000000000000
IE: Unknown: 3D1601050500000000000000000000000000000000000000
IE: Unknown: 341601050500000000000000000000000000000000000000
IE: WPA Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: Unknown: DD180050F2020101010003A4000027A4000042435E0062322F00
IE: Unknown: DD0900037F01010000FF7F
Cell 02 - Address: 00:B0:C6:37:78:C1 //第二wifi
Channel:1
Frequency:2.412 GHz (Channel 1)
Quality=27/70 Signal level=-83 dBm
Encryption key:on
ESSID:"SSL\xC2\xA0Robotic\xC2\xA0Tech\xC2\xA0park-3F"
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s
24 Mb/s; 36 Mb/s; 54 Mb/s
Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 48 Mb/s
Mode:Master
Extra:tsf=0000000000000000
Extra: Last beacon: 70ms ago
IE: Unknown: 001B53534CC2A0526F626F746963C2A054656368C2A07061726B2D3346
IE: Unknown: 010882840B162430486C
IE: Unknown: 030101
IE: Unknown: 0506000100008602
IE: Unknown: 2A0100
IE: Unknown: 2F0100
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: Unknown: 32040C121860
IE: Unknown: 2D1AEC191BFFFF000000000000000000000000000000000000000000
IE: Unknown: 3D1601080400000000000000000000000000000000000000
IE: Unknown: DD090010180213F42C0000
IE: Unknown: DD180050F2020101000003A4000027A4000042435E0062322F00
Cell 03 - Address: F0:B4:29:1A:6A:4A
Channel:8
Frequency:2.447 GHz (Channel 8)
Quality=52/70 Signal level=-58 dBm
Encryption key:on
ESSID:"xiaomi_slam_team"
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s
24 Mb/s; 36 Mb/s; 54 Mb/s
Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 48 Mb/s
Mode:Master
Extra:tsf=0000000000000000
Extra: Last beacon: 70ms ago
IE: Unknown: 00107869616F6D695F736C616D5F7465616D
IE: Unknown: 010882848B962430486C
IE: Unknown: 030108
IE: Unknown: 2A0104
IE: Unknown: 32040C121860
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : TKIP
Pairwise Ciphers (2) : CCMP TKIP
Authentication Suites (1) : PSK
IE: Unknown: 46053208010000
IE: Unknown: 2D1ABC091BFFFF000000000000000000000000000000000000000000
IE: Unknown: 3D1608080400000000000000000000000000000000000000
IE: Unknown: 7F080400000000000040
IE: Unknown: DD770050F204104A0001101044000102103B000103104700100970722EE244777F96FCE4580BDC3874102100067869616F6D691023000352324410240004303030311042000233321054000800060050F20400011011000C5869616F4D69526F75746572100800022008103C0001031049000600372A000120
IE: Unknown: DD090010180206001C0000
IE: WPA Version 1
Group Cipher : TKIP
Pairwise Ciphers (2) : CCMP TKIP
Authentication Suites (1) : PSK
wlan0 Scan completed :
Cell 01 - Address: FC:D7:33:F1:AC:EA //第一wifi
Channel:1
Frequency:2.412 GHz (Channel 1)
Quality=35/70 Signal level=-75 dBm
Encryption key:on
ESSID:"WVLan" //名字
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
9 Mb/s; 12 Mb/s; 18 Mb/s
Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s
Mode:Master
Extra:tsf=0000000000000000
Extra: Last beacon: 70ms ago
IE: Unknown: 000557564C616E
IE: Unknown: 010882848B960C121824
IE: Unknown: 030101
IE: Unknown: 0706434E20010D20
IE: Unknown: 2A0100
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: Unknown: 32043048606C
IE: Unknown: 2D1A6E101BFFFFFF0000000000000000008000000000000000000000
IE: Unknown: 331A6E101BFFFFFF0000000000000000008000000000000000000000
IE: Unknown: 3D1601050500000000000000000000000000000000000000
IE: Unknown: 341601050500000000000000000000000000000000000000
IE: WPA Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: Unknown: DD180050F2020101010003A4000027A4000042435E0062322F00
IE: Unknown: DD0900037F01010000FF7F
Cell 02 - Address: 00:B0:C6:37:78:C1 //第二wifi
Channel:1
Frequency:2.412 GHz (Channel 1)
Quality=27/70 Signal level=-83 dBm
Encryption key:on
ESSID:"SSL\xC2\xA0Robotic\xC2\xA0Tech\xC2\xA0park-3F"
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s
24 Mb/s; 36 Mb/s; 54 Mb/s
Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 48 Mb/s
Mode:Master
Extra:tsf=0000000000000000
Extra: Last beacon: 70ms ago
IE: Unknown: 001B53534CC2A0526F626F746963C2A054656368C2A07061726B2D3346
IE: Unknown: 010882840B162430486C
IE: Unknown: 030101
IE: Unknown: 0506000100008602
IE: Unknown: 2A0100
IE: Unknown: 2F0100
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: Unknown: 32040C121860
IE: Unknown: 2D1AEC191BFFFF000000000000000000000000000000000000000000
IE: Unknown: 3D1601080400000000000000000000000000000000000000
IE: Unknown: DD090010180213F42C0000
IE: Unknown: DD180050F2020101000003A4000027A4000042435E0062322F00
Cell 03 - Address: F0:B4:29:1A:6A:4A
Channel:8
Frequency:2.447 GHz (Channel 8)
Quality=52/70 Signal level=-58 dBm
Encryption key:on
ESSID:"xiaomi_slam_team"
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s
24 Mb/s; 36 Mb/s; 54 Mb/s
Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 48 Mb/s
Mode:Master
Extra:tsf=0000000000000000
Extra: Last beacon: 70ms ago
IE: Unknown: 00107869616F6D695F736C616D5F7465616D
IE: Unknown: 010882848B962430486C
IE: Unknown: 030108
IE: Unknown: 2A0104
IE: Unknown: 32040C121860
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : TKIP
Pairwise Ciphers (2) : CCMP TKIP
Authentication Suites (1) : PSK
IE: Unknown: 46053208010000
IE: Unknown: 2D1ABC091BFFFF000000000000000000000000000000000000000000
IE: Unknown: 3D1608080400000000000000000000000000000000000000
IE: Unknown: 7F080400000000000040
IE: Unknown: DD770050F204104A0001101044000102103B000103104700100970722EE244777F96FCE4580BDC3874102100067869616F6D691023000352324410240004303030311042000233321054000800060050F20400011011000C5869616F4D69526F75746572100800022008103C0001031049000600372A000120
IE: Unknown: DD090010180206001C0000
IE: WPA Version 1
Group Cipher : TKIP
Pairwise Ciphers (2) : CCMP TKIP
Authentication Suites (1) : PSK
IE: Unknown: DD180050F2020101840003A4000027A4000042435E0062322F00
[email protected]:~ $ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf ///连接wifi
network={
ssid="The_ESSID_from_earlier"
psk="Your_wifi_password"
}
在本示例网络中,我们应该添加为:
network={
ssid="testing"
psk="testingPassword"
}
network={
ssid="The_ESSID_from_earlier"
psk="Your_wifi_password"
}
在本示例网络中,我们应该添加为:
network={
ssid="testing"
psk="testingPassword"
}
现在按ctrl+x键然后按y键,最后再按回车键。
以上是关于树莓派随笔的主要内容,如果未能解决你的问题,请参考以下文章