IoT 硬件:Raspberry Pi Camera

配置

Camera

$ sudo raspi-config
  • 3 Interface Options Configure connections to peripherals
  • P1 Camera Enable/disable connection to the Raspberry Pi Camera
  • Yes
reboot

显存

保证显存 >= 128

  • 查看
$ cat /boot/config.txt | grep gpu_mem
gpu_mem=128
  • 修改
$ vim /boot/config.txt

检测 Camera

如果没有检测出来,可以考虑重新插拔试试。

$ vcgencmd get_camera
supported=1 detected=1

验证

拍照 raspistill

  • 打开摄像头,预览2秒后关闭。
raspistill -t 2000
  • 打开摄像头,5秒后拍照(默认),保存为 image.jpg。
raspistill -o image.jpg
  • 打开摄像头,3秒后拍照,保存为 image.png,宽640:高480。
raspistill -t 3000 -o image.png -e png -w 640 -h 480
  • 打开摄像头,30秒内每2秒保存一张照片。
raspistill -t 30000 -tl 2000 -o image%04d.jpg

IoT 硬件:Raspberry Pi ReSpeaker 智能语音识别双麦克风阵列

树莓派4

硬件概述

烧录系统

wget https://downloads.raspberrypi.org/rpd_x86/images/rpd_x86-2021-01-12/2021-01-11-raspios-buster-i386.iso
dd if=2021-01-11-raspios-buster-i386.iso of=/dev/sdc bs=10M

ReSpeaker 2-Mics Pi HAT

ReSpeaker 2-Mics Pi HAT是专为AI和语音应用设计的Raspberry Pi双麦克风扩展板。 这意味着您可以构建一个集成Amazona语音服务等的功能更强大,更灵活的语音产品。

该板是基于WM8960开发的低功耗立体声编解码器。 电路板两侧有两个麦克风采集声音,还提供3个APA102 RGB LED,1个用户按钮和2个板载Grove接口,用于扩展应用程序。 此外,3.5mm音频插孔或JST 2.0扬声器输出均可用于音频输出。

硬件概述

产品特征

配置

$ sudo raspi-config

打开 I2C

  • 3 Interface Options Configure connections to peripherals
  • P5 I2C Enable/disable automatic loading of I2C kernel module
  • Yes

IoT 硬件:NeoPixel

WS2812B 灯带 一个集控制电路与发光电路于一体的智能外控LED光源。可单独寻址数字 LED 灯。 每个像素都有自己的颜色和亮度。 您可以单独控制它们,并将其设置成任何颜色。 256 灰色级别可调节和 16777216 彩色 24 位全彩显示。

硬件清单

  • NodeMCU ESP32
  • WS2812B 灯带
  • 面包板
  • 3条杜邦线
  • USB数据线

电路图

ESP32 管脚图

开发 import time from machine import Pin from neopixel import NeoPixel from random import randint #GPIO0 pin = 0 #这里用的NeoPixel有60个灯珠 pixel_count = 60 np = NeoPixel(Pin(pin, Pin.OUT), pixel_count) def get_random_rgb_color(): red = randint(0, 255) green = randint(0, 255) blue = randint(0, 255) return (red, green, blue) def random_color(np): for _ in range(0, 10): for pixel_id in range(0, np.

命令brew

安装

brew install putty

FAQ

1、Updating Homebrew... 卡住

$ brew install putty
Updating Homebrew...
  • 方法1:直接关闭brew每次执行命令时的自动更新
$ vim ~/.bash_profile
export HOMEBREW_NO_AUTO_UPDATE=true
$ source ~/.bash_profile
  • 方法2:替换brew源
cd "$(brew --repo)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew-core.git
brew update

2、`initialize': Version value must be a string; got a NilClass () (TypeError) $ brew install putty /usr/local/Homebr

VS Code远程开发 - SSH

架构图

安装

Remote

Local

连接远程主机

  1. 在VS Code中, 按F1,选择Remote-SSH: Connect to Host...输入user@hostname。
  1. VS Code将连接到SSH服务器并进行设置。 VS Code将使用进度通知使您保持最新状态。

  1. 连接后,您将进入一个空窗口。 您始终可以参考状态栏来查看连接到的主机。

  1. 选择菜单:File > Open...

关闭远程连接

  • 选择菜单:File > Close Remote Connection。
  • 您可以简单地退出VS Code,也可以关闭远程连接。

Remote Explorer

管理您的远程连接

在远程主机上打开终端

选择菜单:Terminal > New Terminal

在远程主机调试

在Extensions窗口中选择要在远程主机上安装的调试器,按F5。

FAQ "Visual Studio Code is unable to watch for file changes in this large workspace" (error

VS Code实践

编辑

  • 注释或取消注释 Command+/
  • 格式化文档 Option+Shift+f

选择

  • 多列选择 Option+Shift,按住鼠标左键拖动
  • 多选 Option,按住鼠标左键拖动

转到

  • 转到行号 Ctrl+g
  • 转到文件 Command+p

导航

  • 后退 Ctrl+-
  • 前进 Shift+Ctrl+-

视图

  • 自动换行 Option+z

窗口

  • 显示或隐藏Side Bar Command+b
  • 显示或隐藏Terminal Ctrl+`
  • 多个VS Code实例切换 Command+`
  • 一个VS Code实例中多个窗口切换 Ctrl+Tab

场景

当有一堆图片文件使用键盘进行快速浏览

  1. Command+Shift+e 打开资源管理器。
  2. 使用键盘的上下箭头键选择要浏览的文件。
  3. Space(filesExplorer.openFilePreserveFocus) 打开文件保留焦点。

参考资料