设置静态IP

对于Debian和Linux系统来说,设置静态IP,修改/etc/network/interfaces配置文件。而raspian系统需要在/etc/dhcpcd.conf中设置。具体参数设置如下:

  1. #指定接口 eth0以太网,或者wlan0无线网
  2. interface eth0
  3. #指定静态IP,/24表示子网掩码为255.255.255.0,/16表示子网掩码为255.255.0.0
  4. static ip_address=192.168.1.20/24
  5. #路由器/网关IP地址
  6. static routers=192.168.1.1
  7. #自定义DNS服务器
  8. static domain_name_servers=114.114.114.114

sudo reboot重启raspian系统
使用命令ifconfig查看IP设置是否成功。
如果是无线网wlan0,sudo vim /etc/wpa_supplicant/wpa_supplicant.conf可以查看和修改WIFI保存的账号和密码。

系统字体

image.png

系统配置

sudo raspi-config

控制台显示开发板引脚

打开开发板接口示意图:pinout

默认登录名和密码

树莓派系统默认登录名:pi
默认登录密码:raspberry

查看CPU温度

查看主板温度: sudo /opt/vc/bin/vcgencmd measure_temp
获取raspberrypi CPU温度:vcgencmd measure_temp

OLED SSD1306配置引脚

OLED 12864 SSD1306模块引脚配置:
GND 任意一个0v
VCC 任意一个5v/3.3v
D0(SCLK) 23号物理接口
D1(MOSI) 19号物理接口
RST 11号物理接口
DC(数据与命令选择) 13号物理接口

安装包

sudo apt-get install package_name
sudo apt-get remove package_name(删除软件包)

GPIO特殊功能引脚

  • PWM (pulse-width modulation)
    • Software PWM available on all pins
    • Hardware PWM available on GPIO12, GPIO13, GPIO18, GPIO19
  • SPI
    • SPI0: MOSI (GPIO10); MISO (GPIO9); SCLK (GPIO11); CE0 (GPIO8), CE1 (GPIO7)
    • SPI1: MOSI (GPIO20); MISO (GPIO19); SCLK (GPIO21); CE0 (GPIO18); CE1 (GPIO17); CE2 (GPIO16)
  • I2C
    • Data: (GPIO2); Clock (GPIO3)
    • EEPROM Data: (GPIO0); EEPROM Clock (GPIO1)
  • Serial
    • TX (GPIO14); RX (GPIO15)

      gpiozero

      gpiozero A simple interface to GPIO devices with Raspberry Pi.

config.txt

config.txt相当于PC机的BIOS,在/boot目录下。

  • vcgencmd get_config : this displays a specific config value, e.g. vcgencmd get_config arm_freq.
  • vcgencmd get_config int: this lists all the integer config options that are set (non-zero).
  • vcgencmd get_config str: this lists all the string config options that are set (non-null).

图像相关

raspberrypi拍照命令:raspistill -v -o test.jpg
图像编辑软件pinta:
sudo apt-get install pinta
图像查看器eog:
sudo apt-get install eog

其他

pi@raspberrypi: pi是用户名,raspberrypi是主机名
SMBus (System Management Bus) is a subset from the I2C protocol
CS(SPI 片选) 24号物理接口
控制台清屏:clear

A pipe allows the output from one command to be used as the input for another command. The pipe symbol is a vertical line |. For example, to only show the first ten entries of the ls command it can be piped through the head command ls | head

Use grep to search inside files for certain search patterns. For example, grep “search” *.txt will look in all the files in the current directory ending with .txt for the string search. The grep command supports regular expressions which allows special letter combinations to be included in the search.

Shell Script用各类命令预先放入到一个文件中,方便一次性执行的一个程序文件,主要是方便管理员进行设置或者管理用的。