顯示具有 Raspberry pi 標籤的文章。 顯示所有文章
顯示具有 Raspberry pi 標籤的文章。 顯示所有文章

2024年8月27日 星期二

pi 400 as keyboard

編輯/boot/config.txt 添加
dtoverlay=dwc2
sudo modprobe libcomposite

編譯
sudo apt install libconfig-dev git cmake
git clone https://github.com/Gadgetoid/pi400kb
cd pi400kb
git submodule update --init
mkdir build
cd build
cmake ..
make

執行 
sudo modprobe libcomposite
sudo ./pi400kb 

Ctrl + Raspberry 本機使用和 USB 間切換
Ctrl + Shift + Raspberry 退出

2023年11月9日 星期四

raspbian 停用 ssh 密碼 raspberry 檢查

移除 /etc/profile.d/sshpasswd.sh

apt purge libpam-chksshpwd

2022年2月10日 星期四

設定 Raspberry pi zero Wifi AP

#安裝相關軟體
apt install -y iptables dnsmasq hostapd

export uap0=192.168.2.1/24
export dhcpr=192.168.2.2,192.168.88.50,12h

#設定網路界面
cat >/etc/network/interfaces.d/wlan0 <<EOF
auto wlan0
allow-hotplug wlan0

iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
EOF

cat >/etc/network/interfaces.d/uap0 <<EOF
iface uap0 inet static
  address 192.168.2.1
  netmask 255.255.255.0
  network 192.168.2.0
  broadcast 192.168.2.255
  gateway 192.168.2.1
EOF

#設定 dhcpd uap0 界面
echo >>dhcpcd.conf <<EOF
interface uap0
static ip_address=${uap0}
nohook wpa_supplicant
EOF

#設定 dnsmasq 服務
cat >>/etc/dnsmasq.conf <<EOF
interface=uap0
no-dhcp-interface=lo,wlan0
bind-interfaces
server=8.8.8.8
domain-needed
bogus-priv
dhcp-range=${dhcpr}
EOF

#設定 hostapd 服務
cat >/etc/hostapd/hostapd.conf <<EOF
interface=uap0
ssid=piap
hw_mode=g
channel=11
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=password
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
EOF

echo 'DAEMON_CONF="/etc/hostapd/hostapd.conf"'  >>/etc/default/hostapd
systemctl unmask hostapd

#產生執行 script
cat >/root/startap.sh <<EOF
#!/bin/bash
# Create the virtual device
/sbin/iw dev wlan0 interface add uap0 type __ap
ifup uap0

# Route all the packets coming on this interface, this will enable #us to access internet through wlan0

sysctl net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -s 192.168.2.0/24 ! -d 192.168.2.0/24 -j MASQUERADE

systemctl start dnsmasq
systemctl start hostapd
EOF

2021年3月20日 星期六

Raspberry pi zero Serial Gadget

 編輯 /boot/config.txt 加入
dtoverlay=dwc2

編輯 /boot/cmdline 加入
modules-load=dwc2,g_serial

console=serial0,115200 console=tty1 root=PARTUUID=738a4d67-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_serial

執行
sudo systemctl enable getty@ttyGS0.service

Linux 登入方式
screen /dev/ttyACM0 115200

2021年3月8日 星期一

Raspberry pi 關閉 PPI display

fbcpid=$(ps aux|grep  [/]usr/local/bin/fbcp|awk '{print $2}');
kill $fbcpid 2>/dev/null;
case $? in 0) dtparam spi=off;dtparam spi=on;;
*) /usr/local/bin/fbcp & ;;
esac;
exit 0;

Raspberry pi 音效設定

設定 raspi-config
System Options->Audio

修改 /boot/config.txt 確認
hdmi_drive=2

Paspberry pi 4 使用 gpio 筆記

1.wiringPi updated to 2.52 for the Raspberry Pi 4B
wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb

2.update RPi.GPIO
pip install --ignore-installed RPi.GPIO

2021年2月14日 星期日

Raspberry pi 自動登入更改帳號

修改
/etc/systemd/system/getty@tty1.service.d/autologin.conf

Raspberry pi USB 自動掛載

安裝軟體
apt install usbmount -y
 
修改 /lib/systemd/system/systemd-udevd.service
[Service]
PrivateMounts=no
 
執行
systemctl daemon-reload
systemctl restart systemd-udevd

2021年2月8日 星期一

Raspberry Geekworm 2.2 LCD 設定摘要

LCD 驅動程式
sudo rpi-update
wget https://raw.githubusercontent.com/geekworm-com/22LCD-script/master/screen_setup.sh
chmod +x screen_setup.sh
sudo ./screen_setup.sh

How to turn on/off backlight
sudo rpi-update
sudo apt-get install gcc python-pygame python-dev
sudo wget https://pypi.python.org/packages/source/R/RPi.GPIO/RPi.GPIO-0.5.11.tar.gz
sudo tar zxvf RPi.GPIO-0.5.11.tar.gz
cd RPi.GPIO-0.5.11
sudo python setup.py install

gpio -g mode 27 in
gpio -g mode 27 out

按鈕驅動
sudo apt-get update
sudo apt-get install libudev-dev
sudo apt-get install python-pip
sudo pip install rpi.gpio
sudo pip install python-uinput
sudo modprobe uinput
wget https://raspberrypiwiki.com/File:Python-keys.zip

參考文件
https://raspberrypiwiki.com/2.2_LCD
gpio readall
gpio -v

Raspberry pi Danetd錯誤 訊息 danted.service: Failed at step NAMESPACE spawning

編輯 /lib/systemd/system/danted.service
修改 ReadOnlyDirectories=/bin /etc /lib /lib64 /sbin /usr /var
為 ReadOnlyDirectories=/bin /etc /lib -/lib64 /sbin /usr /var

重新執行
systemctl daemon-reload
/etc/init.d/danted start

2020年6月7日 星期日

Raspberry pi Waveshare 3.5 RPi LCD XPT2046 A 設定

git clone https://github.com/waveshare/LCD-show.git
cd LCD-show/
sudo ./LCD35-show

編輯 /boot/config
dtoverlay=waveshare35a:rotate=270
hdmi_force_hotplug=1
#max_usb_current=1
hdmi_group=0
hdmi_mode=1
hdmi_mode=87
hdmi_cvt 640 480 60 6 0 0 0
hdmi_drive=2
#display_rotate=1
#lcd_rotate=2

參考資料
https://t.codebug.vip/questions-171571.htm
https://www.raspberrypi.org/documentation/configuration/config-txt/video.md


2020年6月3日 星期三

Raspberry pi 3 Under-voltage detected! (0x00050005)

編輯 /boot/config.txt 加入

# Disable under-voltage warning
avoid_warnings=1

2020年5月18日 星期一

Raspberry PI3 設定 WiFI AP

0. cat /etc/debian_version
10.3

1.安裝相關軟體
apt install hostapd dnsmasq -y

2.編輯 /etc/hostapd/hostapd.conf
interface=wlan0
ssid=pi-ap
hw_mode=g
channel=1
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=0123456789
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP

3.編輯 /etc/dnsmasq.conf
interface=wlan0
dhcp-range=192.168.13.2,192.168.13.20,255.255.255.0,1h

4.編輯 /etc/dhcpcd.conf
interface wlan0
static ip_address=192.168.13.1/24
static routers=192.168.13.1
static domain_name_servers=8.8.8.8

5.執行
#sudo ip addr add 192.168.13.1/24 dev wlan0
sudo systemctl start dnsmasq
sudo systemctl unmask hostapd
sudo systemctl start hostapd

sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT

Raspberry pi 開機 文字/圖形界面

sudo raspi-config

3 Boot Options
B1 Desktop / CLI
B1 Console


2020年5月14日 星期四

Raspberry pi 更改 console 字體

1.文字視窗指令
sudo dpkg-reconfigure console-setup

2.更改設定檔
sudo vi /etc/default/console-setup
FONTFACE="Terminus"
FONTSIZE="16x32"

3.套用設定
sudo /etc/init.d/console-setup.sh restart

2020年3月28日 星期六

Raspberry pi Zero 開啟 USB OTG Serial

echo "dtoverlay=dwc2" | sudo tee -a /boot/config.txt
echo "dwc2" | sudo tee -a /etc/modules
echo "g_serial" | sudo tee -a /etc/modules

sudo systemctl enable getty@ttyGS0.service

Linux 連接方式
screen /dev/ttyACM0 115200

2020年1月22日 星期三

Raspberry pi 設定無線網路、開啟 ssh

boot 區下 產生檔名 ssh 檔案

boot 區下 產生 wpa_supplicant.conf 檔案內容
country=TW
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="SSID_NAME"
    psk="SSID_KEY"
    key_mgmt=WPA-PSK
    scan_ssid=1
}