Raspberry: Difference between revisions

From 太極
Jump to navigation Jump to search
 
(11 intermediate revisions by the same user not shown)
Line 93: Line 93:
== Different generations ==
== Different generations ==
* https://en.wikipedia.org/wiki/Raspberry_Pi
* https://en.wikipedia.org/wiki/Raspberry_Pi
* Raspberry Pi 1 B (512MB memory, released 2012), [http://computers.tutsplus.com/tutorials/the-raspberry-pi-b-explored-and-explained--cms-21821 Raspberry Pi model B vs B+]
* Raspberry Pi 1 B (512MB memory, 2x USB 2.0, ethernet 10/100 Mb/s, released 2012), [http://computers.tutsplus.com/tutorials/the-raspberry-pi-b-explored-and-explained--cms-21821 Raspberry Pi model B vs B+]
* [http://www.raspberrypi.org/raspberry-pi-2-on-sale/ Raspberry Pi 2] (released 2015. This has an identical form-factor to the existing Raspberry Pi 1 Model B+)
* [http://www.raspberrypi.org/raspberry-pi-2-on-sale/ Raspberry Pi 2] (released 2015. This has an identical form-factor to the existing Raspberry Pi 1 Model B+)
* [https://www.raspberrypi.org/blog/zero-wh/ Raspberry Pi Zero WH] (released 2017)
* [https://www.raspberrypi.org/blog/zero-wh/ Raspberry Pi Zero WH] (released 2017)
Line 550: Line 550:
chmod +x ./battery_log.sh
chmod +x ./battery_log.sh
nohup ./battery_log.sh > /dev/null 2>&1 &
nohup ./battery_log.sh > /dev/null 2>&1 &
</pre>
<li>On beaglebone black.</br>
nano check_uptime.sh
<pre>
#!/bin/bash
DATE=$(date '+%Y-%m-%d %H:%M:%S')
echo "$DATE - Server is up" >> /home/debian/server_uptime.log
</pre>
chmod +x check_uptime.sh
<pre>
0 * * * * /home/debian/check_uptime.sh
</pre>
</pre>


Line 799: Line 811:


== Check the filesystem on microSD card ==
== Check the filesystem on microSD card ==
[https://platfrastructure.life/post/rpi_boot_repair/ Repairing a Raspberry Pi Boot Partition]
<ul>
<li>Check SD card for any error
<pre>
dmesg | grep -i "mmc"
# OR
journalctl -k | grep -i "mmc\|I/O error\|mmcblk"
</pre>
Look for messages like “mmc0: Timeout waiting for hardware,” “I/O error,” or “Buffer I/O error on dev mmcblk0p2,” which indicate potential SD card problems.
<li>[https://platfrastructure.life/post/rpi_boot_repair/ Repairing a Raspberry Pi Boot Partition]
<pre>
<pre>
# rootfs is ext4  
# rootfs is ext4  
Line 808: Line 828:
sudo dosfsck -t -a -w /dev/sdc1
sudo dosfsck -t -a -w /dev/sdc1
</pre>
</pre>
</ul>


== Secure your Raspberry Pi ==
== Secure your Raspberry Pi ==
Line 819: Line 840:
See [https://www.raspberrypi.org/blog/another-raspbian-desktop-user-interface-update/ the blog] on May 5, 2015.
See [https://www.raspberrypi.org/blog/another-raspbian-desktop-user-interface-update/ the blog] on May 5, 2015.


=== NetworkManager - nmcli ===
=== NetworkManager - nmcli/nmtui ===
* [https://www.raspberrypi.com/documentation/computers/configuration.html#networking Configuration -> Networking] from the official Raspberry Pi Documentation.
<ul>
* [https://pimylifeup.com/raspberry-pi-network-manager/ Installing Network Manager on Raspberry Pi OS] 2022
<li>[https://www.raspberrypi.com/documentation/computers/configuration.html#networking Configuration -> Networking] from the official Raspberry Pi Documentation.
** By default, the Raspberry Pi uses an older software called '''dhcpcd''' for its network handling. It is a bit more complicated to configure and has been superseded by '''Network Manager'''. Note. Bookworm use NM by default.
 
** I follow the instruction to change the default network method from dhcpcd to NetworkManager
<li>In the old days, the network configuration file is typically located at ''/etc/wpa_supplicant/wpa_supplicant.conf''. Currently, Raspberry Pi OS is using '''Network Manager'''. We can confirm this and manage wireless connections by using the commands: '''nmcli device''' or '''sudo systemctl status NetworkManager'''.
** After reboot, the wifi icon shows no connection
 
** I have a USB wifi adapter. I use the USB wifi adapter to connect to my hotspot (not the primary network) and the pi's broadcom BCM43438 combo is connected to my primary network
<li>Two essential commands:
** 'nmcli device wifi list' shows both have 100 SIGNAL though the hotspot one has 130 Mbit/s but the primary network has 2870 Mbit/s
<syntaxhighlight lang='sh'>
** On my hotspot host, I can use '''ip neigh''' to get the connected device's IP, like 10.42.0.xxx. Or using the command '''nmap -sn 10.42.0.0/24'''
nmcli device wifi
<pre>
sudo nmtui
</syntaxhighlight>
<li>[https://pimylifeup.com/raspberry-pi-network-manager/ Installing Network Manager on Raspberry Pi OS] 2022
* By default, the Raspberry Pi uses an older software called '''dhcpcd''' for its network handling. It is a bit more complicated to configure and has been superseded by '''Network Manager'''. Note. Bookworm use NM by default.
* I follow the instruction to change the default network method from dhcpcd to NetworkManager
* After reboot, the wifi icon shows no connection
* I have a USB wifi adapter. I use the USB wifi adapter to connect to my hotspot (not the primary network) and the pi's broadcom BCM43438 combo is connected to my primary network
* 'nmcli device wifi list' shows both have 100 SIGNAL though the hotspot one has 130 Mbit/s but the primary network has 2870 Mbit/s
* On my hotspot host, I can use '''ip neigh''' to get the connected device's IP, like 10.42.0.xxx. Or using the command '''nmap -sn 10.42.0.0/24'''
<syntaxhighlight lang='sh'>
sudo apt install network-manager
sudo apt install network-manager


Line 850: Line 880:
# OR use
# OR use
nmtui  # then go to 'Activate a connection'
nmtui  # then go to 'Activate a connection'
</pre>
</syntaxhighlight>
<li>The network connection profiles are stored in the '''/etc/NetworkManager/system-connections/''' directory.
</ul>


=== Multiple WiFi Networks ===
=== Multiple WiFi Networks ===
Line 1,093: Line 1,125:


== Raspbian repository and mirrors ==
== Raspbian repository and mirrors ==
* https://www.raspberrypi.org/downloads/raspbian/
* http://www.raspbian.org/RaspbianMirrors
* http://www.raspbian.org/RaspbianMirrors
* UMD mirror (http|rsync)://mirror.umd.edu/raspbian/raspbian
* UMD mirror (http|rsync)://mirror.umd.edu/raspbian/raspbian
* Run '''sudo nano /etc/apt/sources.list''' and change the default to a mirror


== Releases lists ==
== Releases lists ==
Line 1,162: Line 1,194:


Some examples:
Some examples:
* :open URL to open a new website
* j/k to scroll down/up
* j/k to scroll down/up
* space or ctrl+d / Ctrl+u to scroll down/up one page
* space or ctrl+d / Ctrl+u to scroll down/up one page
Line 1,238: Line 1,271:


== Turn Raspberry Pi Zero into a USB gadget ==
== Turn Raspberry Pi Zero into a USB gadget ==
* http://blog.gbaman.info/?p=791 (this can only work with the RPi Zero). Allowing ssh, sftp, vnc etc over a single usb cable.
* [https://gpiozero.readthedocs.io/en/stable/pi_zero_otg.html Pi Zero USB OTG]. '''GPIO Zero''' is installed by default in the Raspbian image
* [https://gpiozero.readthedocs.io/en/stable/pi_zero_otg.html Pi Zero USB OTG]. '''GPIO Zero''' is installed by default in the Raspbian image
* [https://www.thepolyglotdeveloper.com/2016/06/connect-raspberry-pi-zero-usb-cable-ssh/ Connect To A Raspberry Pi Zero With A USB Cable And SSH]. The same procedure works on Pi Zero W. Still there is no internet on my zero W unless we create wpa_supplicant.conf under /boot. In summary, we need to modify 2 files and create 1 file.
* [https://www.thepolyglotdeveloper.com/2016/06/connect-raspberry-pi-zero-usb-cable-ssh/ Connect To A Raspberry Pi Zero With A USB Cable And SSH]. The same procedure works on Pi Zero W. Still there is no internet on my zero W unless we create wpa_supplicant.conf under /boot. In summary, we need to modify 2 files and create 1 file.
Line 2,606: Line 2,638:
libcamera-vid --width 1280 --height 720 --framerate 50 -o 50fps.h264
libcamera-vid --width 1280 --height 720 --framerate 50 -o 50fps.h264
</syntaxhighlight>
</syntaxhighlight>
Streaming [https://www.tomshardware.com/how-to/use-raspberry-pi-camera-with-bullseye How To Use Raspberry Pi Cameras with Bullseye]
<syntaxhighlight lang='sh'>
libcamera-vid -t 0 --inline --listen -o tcp://0.0.0.0:8888
# In VLC, Go to Media > Open Network Stream: tcp/h264://raspberrypi.local:8888
# OR through a command line
# vlc tcp/h264://raspberrypi.local:8888
</syntaxhighlight>
There is a latency. Consider gst-launch-1.0 + libcamerasrc. See https://github.com/raspberrypi/libcamera.
</ul>
</ul>


Line 2,749: Line 2,773:
=== Create a button-operated camera ===
=== Create a button-operated camera ===
https://www.raspberrypi.org/magpi-issues/MagPi45.pdf p27
https://www.raspberrypi.org/magpi-issues/MagPi45.pdf p27
=== Streaming ===
[https://www.raspberrypi.com/documentation/computers/camera_software.html#stream-video-over-a-network-with-rpicam-apps Stream video over a network with rpicam-apps] from official Raspberry Pi. The instruction is based on '''Raspberry Pi OS Bookworm''' where it renamed the camera capture applications from libcamera-* to rpicam-*.
<ul>
<li>'''UDP''' method (require the client IP). Prioritizes speed over reliability. It sends data without establishing a connection, resulting in lower latency but potential packet loss. Ideal for real-time applications like live streaming and gaming.
<syntaxhighlight lang='sh'>
libcamera-vid -t 0 --width 1920 --height 1080 --inline -o udp://Client-IP:8888
</syntaxhighlight>
I found VLC closed automatically for some reason. '''ffplay''' seems to be quite stable. Also the streaming does not use much of CPU.
<syntaxhighlight lang='sh'>
ffplay udp://Server-IP:8888 -fflags nobuffer -flags low_delay -framedrop
</syntaxhighlight>
<li>'''TCP''' method. Medium Latency. Suitable for applications where data accuracy is crucial.
<li>'''RTSP''' method. Medium-High Latency.
<syntaxhighlight lang='sh'>
libcamera-vid -t 0 --inline -o - | cvlc stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/stream1}' :demux=h264
</syntaxhighlight>
On the client side (eg Android),
<pre>
vlc rtsp://Server-IP:8554/stream1
</pre>
</ul>
=== Live stream to youtube ===
* [http://www.makeuseof.com/tag/live-stream-youtube-raspberry-pi/ Live Stream to YouTube With a Raspberry Pi] from makeuseof.
* [http://blog.alexellis.io/live-stream-with-docker/ Live stream to YouTube with your Raspberry Pi and Docker]
* [https://www.raspberrypi.com/news/ez-streamer-pi-lets-you-live-stream-from-four-cameras-at-once/ EZ Streamer-Pi lets you live stream from four cameras at once]


=== RTSP and ZoneMinder ===
=== RTSP and ZoneMinder ===
Line 2,793: Line 2,844:
raspivid -o - -t 0 -w 1280 -h 720 -fps 15 -n | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8081/x}' :demux=h264
raspivid -o - -t 0 -w 1280 -h 720 -fps 15 -n | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8081/x}' :demux=h264
</pre>
</pre>
</pre>
Then run,
<pre>
chmod +x rtsp.sh
chmod +x rtsp.sh
./rtsp.sh
./rtsp.sh
Line 2,961: Line 3,013:
  [ - ]  x11-common
  [ - ]  x11-common
</syntaxhighlight>
</syntaxhighlight>
=== Live stream to youtube ===
* [http://www.makeuseof.com/tag/live-stream-youtube-raspberry-pi/ Live Stream to YouTube With a Raspberry Pi] from makeuseof.
* [http://blog.alexellis.io/live-stream-with-docker/ Live stream to YouTube with your Raspberry Pi and Docker]
* [https://www.raspberrypi.com/news/ez-streamer-pi-lets-you-live-stream-from-four-cameras-at-once/ EZ Streamer-Pi lets you live stream from four cameras at once]


=== Bird feed ===
=== Bird feed ===
Line 3,526: Line 3,573:


= Alternatives =
= Alternatives =
== OS ==
* [https://www.msn.com/en-us/money/other/5-operating-systems-you-should-try-if-you-re-new-to-raspberry-pi/ 5 Operating Systems You Should Try If You're New To Raspberry Pi]
[https://www.msn.com/en-us/money/other/5-operating-systems-you-should-try-if-you-re-new-to-raspberry-pi/ 5 Operating Systems You Should Try If You're New To Raspberry Pi]
 
== DietPi ==
DietPi is an extremely lightweight Debian-based OS.
 
* https://github.com/MichaIng/DietPi
* [https://dietpi.com/stats.html Comparison]
* [https://raspberrytips.com/install-dietpi-raspberry-pi/ Complete Guide]
* [https://dietpi.com/forum/t/password-explanation/14415 Password explaination]
* Installation
** Change global software password for DietPi-software installs. The password will be encrypted and saved to /var/lib/dietpi/dietpi-software/.GLOBAL_PW.bin to be used by DietPi-Software as initial password for e.g. web application and frontend logins. This does not affect any previously installed software, just new installs. We especially recommend to change it, if you did not change it in "dietpi.txt" yet. NB: we highly recommend to apply individual passwords for each software title after first login. Would you like to change the global software password now? OK/Cancel.
** Change login password for "root" and "diepi" users? DietPi has two accounts by default: "root" and "dietpi". On first boot, both share the password "dietpi", respectively the one set in "dietpi.txt". It is highly recommended to change this password, ideally, it should be different than the global software password. Would you like to change the login password for "root" and "dietpi" now? OK/Cancel. It seems this does affect the (same) password for root & dietpip.
** A serial/UART console .... would you like to disable it? Yes/No.
 
* Memory is 20.9/477M according to htop (on my RPi 1B, armv6)
* Default username/password is root/dietpi
* Dropbear was used instead of openssh by default
* After a login, it will remind some useful commands
** '''dietpi-launcher''' (can run 'dietpi-config' and 'dietpi-software').
*** DietPi-Drive_Manager: control multiple external drives (eg Samba drives)
*** DietPi-AutoStart
*** DietPi-Services
*** DietPi-Cron: Mailto/cron.minutely/cron.hourly/cron.daily/cron.weekly/cron.monthly
*** DietPi-Backup
*** DietPi-Cleaner
*** DietPi-Sync
*** DietPi-VPN: setup a VPN connection: NordVPN/ProtonVPN/IPVanish/PIA/Custom (need .ovpn file)
*** DietPi-DDNS: DuckDNS/NO-IP/Dynu/FreeDNS/OVH/YDNS/Custom (need Domains & token)
** '''dietpi-config''' (similar to raspi-config)
** '''dietpi-software''': lots of software we can easily install and they are categorized.
*** Desktops: LXDE, MATE, Xfce, LXQt
*** Remote desktop: TigerVNC Server, XRDP, NoMachine, RealVNC Server
*** Media systems: Kodi
*** BitTorrent & download: youtube-dl
*** Cloud & Backup: Syncthing, nextcloud, vaultwarden, File Browser, Rclone
*** Gaming & Emulation: Amiberry
*** Social & Search: mediawiki
*** Camera & Surveillance: RPi Cam Web Interface, motionEye, mjpg-streamer
*** System Stats & management: [https://github.com/tariqbuilds/linux-dash LinuxDash], [https://github.com/phpsysinfo/phpsysinfo phpSysInfo], [https://www.netdata.cloud/ Netdata], [https://xavierberger.github.io/RPi-Monitor-docs/index.html RPi-Monitor], Docker, DietPi-Dashboard, [https://github.com/bastienwirtz/homer Homer]
*** Remote Access
*** Hardware projects
*** System security
*** Webserver stacks
*** DNS servers
*** File servers (ProFTPD, Samba, NFS)
*** VPN servers (tailscale, PiVPN, Wireguard, ZeroTier)
*** Advaced networking (wifi hotspot, tor)
*** Home automation
*** Printing
*** SSH clients (openssh)
*** File server clients (samba client, NFS client)
*** File managers (MC, ViFM)
*** System (Alsa, X.org, FFmpeg, UnRAR)
*** Databases (phpMyAdmin, ...)
*** Network tools (Iperf, iftop, avahi-daemon, ...)
*** Development & programming (git, node.js, python3, vscodium)
*** Text editors (emacs, vim, neovim)
*** Desktop utilities (QuiteRSS, GIMP, xfce power manager)
** htop: Very few processes are running (~10)
** cpu
* It is better to install one software at a time in order to gain more information about a new software. For example when it is installing filebrowser, it shows a new directory "/mnt/dietpi_userdata/filebrowser" was created and the OS user "dietpi" & its credential can be used to log in. The program was installed in /opt/filebrowser. The web URL is http://IP:8084. '''sudo ss -tulpn | grep LISTEN''' can be used to find open ports.
* [https://tailscale.com/download/linux tailscale] can be installed


== SBC ==
== other SBC ==
* [[Beaglebone|BeagleBone Black]] (no built-in wifi or bluetooth)
* [[Beaglebone|BeagleBone Black]] (no built-in wifi or bluetooth)
* [[Udoo|UDOO]] with built-in wifi. Bluetooth relies on USB.
* [[Udoo|UDOO]] with built-in wifi. Bluetooth relies on USB.

Latest revision as of 21:35, 10 November 2024

Raspberry Pi

Miscellaneous

# /etc/network/interfaces  file
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
allow-hotplug wlan0
  wpa-ssid "YOURSSID"
  wpa-psk "YOURPASSWORD
cat /sys/class/thermal/thermal_zone0/temp

This is similar but not the same as the Udoo case where it uses cat /sys/devices/virtual/thermal/thermal_zone0/temp

USB HID keyboard

Pico

Pi zero

R

Cracking the Code: Unveiling the Hidden Language of USB HID Keyboards!

uname

Install 32 bit Raspberry Pi OS

$ uname -a
Linux raspberrypi 6.1.21-v7+ #1642 SMP Mon Apr  3 17:20:52 BST 2023 armv7l GNU/Linux
$ cat /etc/os-release 
PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
NAME="Raspbian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=raspbian
ID_LIKE=debian

Play mp3/mp4

use omxplayer. To control volume

omxplayer -o local --vol -2000 Song_Title.mp3  # 10%
omxplayer -o local --vol -602 Song_Title.mp3   # 50%

Get social: connecting with Raspberry Pi

https://www.raspberrypi.org/blog/connecting-raspberry-pi-social/

Why You Should Stop Using a Raspberry Pi for Everything

http://www.makeuseof.com/tag/stop-using-raspberry-pi-everything/

What is the Intel and AMD CPU equivalent of Raspberry Pi 4

Different generations

Checking Your Raspberry Pi Revision Number & Board Version

raspberrypi-spy

cat /proc/device-tree/model

Raspberry Pi 4 Rev 1.2. How to tell the difference

https://youtu.be/_wt9NTa1UNE

Displayport connection

Does not work if I use a hdmi to displayport converter. In general, 'step up' is not working but 'step down' is OK. See discussion.

Write image to SD card

Disk is write protected

It means the SD card is bad. My SD card is PNY 16GB Elite U1.

Create our own image

Make a self-healing raspberry pi: create a recovery partition. The goal is get the machine back to a clean install; particularly in the situation you don’t have access to another device to do the burning.

  1. Prepare your workspace: apt install
  2. Calculate the image size: fdisk
  3. Create the blank image: dd
  4. Partition the image: sfdisk
  5. Mount the images: losetup, partx, dd
  6. Configure and mount partitions: tune2fs, e2label, e2fsck, resize2fs, mount
  7. Set the boot partition: fdisk, nano
  8. Create the reset scripts: chmod, nano
  9. Fix fstab: cat
  10. Take a snapshot: dd, umount, losetup
  11. Burn and test: dd
  12. Physical reset
  13. Raspberry Pi recovery partition code and scripts

Modify a disk image to create a Raspberry Pi-based homelab May 2020. chroot, qemu-user-static, xz, arm-image-installer (for Fedora).

Remote access

https://www.raspberrypi.org/documentation/remote-access/access-over-Internet/

Several options are available if you don't want to forward your port, for example, Dataplicity.

Headless Raspberry Pi Setup and SSH access

PS. As of the November 2016 release, Raspbian has the SSH server disabled by default. You will have to enable it manually.

For headless setup, SSH can be enabled by placing a file named 'ssh', without any extension, onto the boot partition of the SD card.

For some reason, I got an error ssh: connect to host raspberrypi.local port 22: Connection refused or “No supported key exchange algorithms. One solution is to generate the keys again Or just wait a little longer for Raspbian to generate keys.

It is also useful to give Pi a new hostname (rpi1, rpi2, rpi3, ...). See Change the Hostname of your Pi.

raspi-config on headless Raspberry Pi

Yes, we can still run sudo raspi-config on headless pi.

Change the default password/allow weak password

Follow https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=7684, we can ignore checking the password strength (my own simple passwords can not pass when I use the raspi-config utility).

If I just use passwd to change the password, the password cannot be too short or simple. However if I use sudo raspi-config, it is fine.

If we like to allow weaker passwords, see here.

$ sudo su -
...
# passwd pi
...
# exit
$ 

Note it is a good idea to save the password hint as a text file in the HOME directory in case I forget the non-default password. If I forget the password, I can pop out the SD card and insert it into another machine. Then all files can be seen.

Disable the Annoying SSH Password Warning on Raspberry Pi

Raspbian is not asking for a password for the sudo command

Assign .local domain to Raspberry Pi

Avahi Daemon = Bonjour = Zeroconf = UDP multicast

http://www.howtogeek.com/167190/how-and-why-to-assign-the-.local-domain-to-your-raspberry-pi/

So I can use ssh [email protected] to access RPi. Note the default name may change. This happened when I use a USB wifi dongle.

sudo apt-get update
sudo apt-get install avahi-daemon
# No reboot is necessary for raspberry pi
ps -ef | grep avahi
# avahi-daemon: running [raspberrypi-2.local]
# Or look at the output
sudo systemctl status avahi-daemon

# from other machines or even Raspi itself
ping raspberrypi-2.local

The idea was first discovered in Beaglebone.

Get the internal IP address

# From another computer
ping raspberrypi.local

# Within raspberry pi
hostname -I

Conky approach

https://www.novaspirit.com/2017/02/23/desktop-widget-raspberry-pi-using-conky/ and my conkyrc.

{Pre} $ sudo apt-get install conky -y $ wget -O /home/pi/.conkyrc https://raw.githubusercontent.com/novaspirit/rpi_conky/master/rpi3_conkyrc

I modify .conkyrc file and move NETWORK section to under the 'SYSTEM' section. I also change wlan0 to eth0 since I am using ethernet for connecting to internet.

We can test it by calling conky from the command line (run export DISPLAY=:0.0 if we are calling conky from SSH).

We could make conky running on boot by creating the following two files (+ reboot).

sudo nano /usr/bin/conky.sh
#!/bin/sh
(sleep 4s && conky) &
exit 0
sudo nano /etc/xdg/autostart/conky.desktop
[Desktop Entry]
Name=conky
Type=Application
Exec=sh /usr/bin/conky.sh
Terminal=false
Comment=system monitoring tool.
Categories=Utility;

Note that conky is using 10% CPU (one core) as I see from the htop command. After I remove unnecessary pulling of the system information, it reduces to 4.5% CPU. Another approach is to increase the polling period so that the application is not polling as often.

Conkyrpi.png

Note that the top processes shown on conky are not quite correct. The top command gives the top processes. I saw the inconsistency when I import a large database in MySQL.

Set up a static IP address

Show IP before login

https://askubuntu.com/a/797600

Add one line about eth0 to /etc/issue file. For example on Debian 10,

Debian GNU/Linux 10 \n \l

eth0: \4{eth0}

Run Graphical App on remote computer: export DISPLAY

export DISPLAY=:0
application_name

Please note that when you close your SSH session, most of the time the remote application will close. If you want to disconnect from SSH but leave the application running, you need to launch it in a special way using something like screen (keeps the SSH session running in the background) or nohup, or another method. Here’s an example using nohup:

nohup application_name > /dev/null 2>&1 &

Under voltage

he red LED going out is an indicator that the supply voltage is too low. You should also see a small coloured square in the top corner of the screen. See the posts

Install minimal browser

http://c-mobberley.com/wordpress/index.php/2013/04/30/raspberry-pi-best-fastest-web-browser-for-gui-usage/

Note that at the end of sudo make install, it will create an item in the menu -> Internet. From the installation output,

sudo install -g dialout web /usr/bin
sudo install -g audio piradio /usr/local/bin
sudo chmod +x /usr/local/bin/piradio
sudo cp ./web.desktop /usr/share/applications
sudo cp ./minimalwebbrowser.png /usr/share/pixmaps
sudo cp ./web.1.gz /usr/share/man/man1
sudo cp ./web-omxplayer.sh /usr/local/bin
sudo chmod +x /usr/local/bin/web-omxplayer.sh

Options for displays/monitors

8 Essentials to Keep in Mind When Choosing a Display for Your Raspberry Pi

HDMI screen resolution

If the screen size is small (i.e. you can see black margins on 4 sides), uncomment the line about disable_overscan=1.

# sudo nano /boot/config.txt
disable_overscan=1

On my SainSmart 9" monitor, its native resolution 1024x600 is not supported by Raspberry Pi (/boot/config.txt). The resolution becomes 1280x720 if I don't modify anything.

However, there is a workaround on raspberry pi forum. This technique works on Ubuntu-Mate 15 and Raspbian Jessie versions. The two lines (hdmi_group and hdmi_mode) are quite mysterious on Raspbian Jessie but more clear on Ubuntu-Mate.

...
#hdmi_ignore_edid=0xa5000080
hdmi_cvt=1024 600 60 3 0 0 0
hdmi_group=2
hdmi_mode=87
disable_overscan=1

HDMI CEC

Raspberry Pi: Power On / Off A TV Connected Via HDMI-CEC

HDMI monitor/display

Move a Window Without Clicking the Titlebar

Move a Window Without Clicking the Titlebar in Ubuntu. Hold down either the Control, Alt, or “Win” key then click in the window anywhere, and move your mouse.

For Windows see How to Move Off-Screen Window back On-Screen in Windows 10

Use VNC Connect

Raspbian shipped with VNC connect. We can use Android or iOS to connect to the Raspbian desktop.

Make your own screen from an old laptop

See the Hardware page.

Audio output

https://www.raspberrypi.org/documentation/configuration/audio-config.md

Method 1 (works on Raspbian or Ubuntu)

amixer cset numid=3 1

Method 2 (works only on Raspbian)

sudo raspi-config

Select Option 8 Advanced Options and hit Enter, then select Option A6: Audio and hit Enter.

Method 3. Edit /boot/config.txt and setting hdmi_drive variable or hdmi_ignore_edid_audio variable. See the Raspberry Pi config.txt web page.

Capacitive touch vs resistive touch

https://techexplainer.wordpress.com/2012/04/02/resistive-vs-capacitive-touchscreen/

Resistive touch is used in low cost products. It does not support multi-touch.

The official Raspberry Pi DSI touch display & the Kivy library

800×480 display @60fps, 24-bit colour, FT5406 10 point capacitive touchscreen, 70 degree viewing angle, Metal-backed display with mounting holes for the Pi

Adafruit touch screen for Raspi

  • PiTFT Assembled 320x240 2.8" TFT $35

RCA video output resolution

http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=47527

KVM over IP

Playing DRM videos in chromium browser

How to build a $100 productivity PC with a Raspberry Pi 4

Hardware acceleration video player

Use omxplayer not VLC. When I use omxplayer to play mp4 videos, htop shows CPUs are not used and the playback is quite smooth. VLC will have a hard time playing the mp4 videos (black screen) not to say all 4 cores are 100% busy on Raspi2. Raspberry Pi software update brings VLC media player with hardware-accelerated video playback

lspci -nnk | grep -i vga -A3 | grep 'in use'

It shows 'nouvea' for my PC Desktop which uses NVIDIA gpu. The command does not work on my Ubuntu-Mate.

pi@pi-ubuntu:~$ lspci -nnk | grep -i vga -A3 | grep 'in use'
pcilib: Cannot open /proc/bus/pci
lspci: Cannot find any working access method.

Chromium

How To Enable Hardware Acceleration In Chromium On Raspberry Pi OS (RPi 4)

Memory

When I use 'free -m' or 'htop' command in Raspbian, I see the total memory size only 373MB (Beaglebone black shows 496MB in htop). The reason is Raspbian reserved 128MB for GPU. See

cat /boot/config.txt

Watch youtube with Raspbian

Probably a practical approach is to use 'youtube-dl' program to download the video and then use 'omxplayer' to play it (not streaming anyway). Downloading Youtube Videos to your Raspberry Pi and Play HD Youtube from the Raspberry Pi Command Line

Cast Youtube from your phone

How To Cast YouTube Videos From Your Phone To Raspberry Pi Using YouTube On TV (youtube.com/tv)

Auto Startup Application

You can configure what applications should be started at login (NOT at boot time or on start up), in addition to the default startup applications configured on the system.

When I try to add calibre, I see a new file "calibre.desktop" is added to ".config/autostart/" folder.

[Desktop Entry]
Type=Application
Exec=/usr/bin/calibre
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_US]=Calibre
Name=Calibre
Comment[en_US]=
Comment=

Startup script

sudo nano /etc/init.d/NameOfYourScript # Create script in /etc/init.d

sudo chmod 755 /etc/init.d/NameOfYourScript # Make script executable

sudo /etc/init.d/NameOfYourScript start # Test starting the program

sudo /etc/init.d/NameOfYourScript stop # Test stopping the program

# Register your script to be run at start-up and shutdown, run the following command:
sudo update-rc.d NameOfYourScript defaults

# If you ever want to remove the script from start-up, run the following command:
sudo update-rc.d -f  NameOfYourScript remove

Disk Performance

Raspberry Pi 4 vs Desktop PC

$100 PC VS Raspberry Pi 4 8GB - Can The Pi4 Replace a Desktop PC?

Power consumption comparison

How long does the RPi last on a battery?

  • https://raspberrypi.stackexchange.com/a/19825. If you have a 500mAh battery, that will output 500mA (0.5A) for one hour, or 1000mA (1A) for half an hour. Similarly, a 2000mAh battery will give you 2000mA (2A) for one hour or 1000mA (1A for two hours).
  • Raspberry Pi Battery Life Calculator. For example with RPi 3B + Wifi + Camera + 10,000 mAH lasts 14.2 hours.
  • From my test, RPi 3B + Wifi + Camera (3 hours time-lapse) + 10,000 mAH lasts 10:42 hours.

Bash script to check the RPi status

  • A simple shell script that logs the current status to a text file:
    #!/bin/bash
    
    # Set the log file path and name
    LOG_FILE="/home/pi/battery_log.txt"
    
    while true
    do
      # Get the current time
      CURRENT_TIME=$(date +"%Y-%m-%d %H:%M:%S")
      
      # Get the uptime (in seconds)
      UPTIME_SECONDS=$(cat /proc/uptime | awk '{print $1}')
      
      # Convert uptime to hours, minutes, and seconds
      UPTIME_HOURS=$(bc -l <<< "scale=0; $UPTIME_SECONDS / 3600")
      UPTIME_MINUTES=$(bc -l <<< "scale=0; ($UPTIME_SECONDS % 3600) / 60")
      UPTIME_SECONDS=$(bc -l <<< "scale=0; $UPTIME_SECONDS % 60")
      
      # Log the current status to the file
      echo "$CURRENT_TIME - Uptime: $UPTIME_HOURS:$UPTIME_MINUTES:$UPTIME_SECONDS" >> $LOG_FILE
      
      # Wait for 1 minute before logging again
      sleep 60
    done
    
    chmod +x ./battery_log.sh
    nohup ./battery_log.sh > /dev/null 2>&1 &
    
  • On beaglebone black.
    nano check_uptime.sh
    #!/bin/bash
    DATE=$(date '+%Y-%m-%d %H:%M:%S')
    echo "$DATE - Server is up" >> /home/debian/server_uptime.log
    

    chmod +x check_uptime.sh

    0 * * * * /home/debian/check_uptime.sh
    
  • The script below will check RPi every 60 seconds (need to keep SSH connection)
    #!/bin/bash
    while true
    do
      if ping -c 1 192.168.1.11 &> /dev/null
      then
         date
      else
         break
      fi
      sleep 60
    done
    

Ways to power your raspberry pi

Power Raspberry Pi by AA batteries

http://www.raspberrypi-spy.co.uk/2013/04/raspberry-pi-aa-battery-shoot-out/

This also teaches to know how long the battery will die by using Putty and linux command

watch -n 60 uptime

Power by 9V battery

https://youtu.be/h6Bl0Bckl2k You need a regulator (output 1.5V) such as TS7800/TS7805.

Power Raspberry Pi by Lipo batteries

Solar power

CPU Benchmark

# RPi 1 
pi@raspberrypi:~ $ sysbench --num-threads=1 --test=cpu --cpu-max-prime=20000 --validate run
sysbench 0.4.12:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 1
Additional request validation enabled.


Doing CPU performance benchmark

Threads started!
Done.

Maximum prime number checked in CPU test: 20000


Test execution summary:
    total time:                          1412.6014s
    total number of events:              10000
    total time taken by event execution: 1412.5301
    per-request statistics:
         min:                                132.41ms
         avg:                                141.25ms
         max:                                403.27ms
         approx.  95 percentile:             172.59ms

Threads fairness:
    events (avg/stddev):           10000.0000/0.00
    execution time (avg/stddev):   1412.5301/0.00

The timing 1412s I got is close to 1318s reported by element14.com.

For nBench, my result of cpu floating-point index 1.753 is also close to element14's 1.884.

pi@raspberrypi:~/nbench-byte-2.2.3 $ ./nbench

BYTEmark* Native Mode Benchmark ver. 2 (10/95)
Index-split by Andrew D. Balsa (11/97)
Linux/Unix* port by Uwe F. Mayer (12/96,11/97)

TEST                : Iterations/sec.  : Old Index   : New Index
                    :                  : Pentium 90* : AMD K6/233*
--------------------:------------------:-------------:------------
NUMERIC SORT        :          202.91  :       5.20  :       1.71
STRING SORT         :          30.842  :      13.78  :       2.13
BITFIELD            :      8.2161e+07  :      14.09  :       2.94
FP EMULATION        :          43.409  :      20.83  :       4.81
FOURIER             :          1660.8  :       1.89  :       1.06
ASSIGNMENT          :          2.2719  :       8.65  :       2.24
IDEA                :          702.86  :      10.75  :       3.19
HUFFMAN             :          421.78  :      11.70  :       3.73
NEURAL NET          :          2.7206  :       4.37  :       1.84
LU DECOMPOSITION    :          73.846  :       3.83  :       2.76
==========================ORIGINAL BYTEMARK RESULTS==========================
INTEGER INDEX       : 11.255
FLOATING-POINT INDEX: 3.161
Baseline (MSDOS*)   : Pentium* 90, 256 KB L2-cache, Watcom* compiler 10.0
==============================LINUX DATA BELOW===============================
CPU                 : ARMv6-compatible processor rev 7 (v6l)
L2 Cache            : 
OS                  : Linux 4.1.13+
C compiler          : gcc version 4.9.2 (Raspbian 4.9.2-10) 
libc                : libc-2.19.so
MEMORY INDEX        : 2.415
INTEGER INDEX       : 3.146
FLOATING-POINT INDEX: 1.753
Baseline (LINUX)    : AMD K6/233*, 512 KB L2-cache, gcc 2.7.2.3, libc-5.4.38
* Trademarks are property of their respective holder.

OpenGL

Pi5 vs n100

Picademy

UPS

Books, Magazines, Blogs

Minecraft

Installation

Make sure to use a class 10 (micro)SD card to avoid a hanging problem. This rule applies to other SoC device like Beaglebone and Udoo.

Roll your own Raspberry Pi OS

https://hackaday.com/2018/01/19/roll-your-own-raspberry-pi-os/

64-bit

It is said 64-bit is supported on Pi3/3B/4.

But I have a successful experience on Pi3B but not Pi3. See

Download an image

Raspberry Pi Imager

  • https://github.com/raspberrypi/rpi-imager. To build from the source (needed in eg Debian OS):
    sudo apt install --no-install-recommends build-essential devscripts debhelper cmake git libarchive-dev libcurl4-gnutls-dev liblzma-dev \
        qtbase5-dev qtbase5-dev-tools qtdeclarative5-dev libqt5svg5-dev qttools5-dev libgnutls28-dev \
        qml-module-qtquick2 qml-module-qtquick-controls2 qml-module-qtquick-layouts qml-module-qtquick-templates2 qml-module-qtquick-window2 qml-module-qtgraphicaleffects
    
    git clone --depth 1 https://github.com/raspberrypi/rpi-imager
    cd rpi-imager
    debuild -uc -us
    # rpi-imager_1.8.5_amd64.deb has been generated in the upper dir
    
  • Raspberry Pi Imager update to v1.6. Hit Ctrl-Shift-X to get the advanced options like wifi, locale setting, enable SSH, turn off telemetry. Why not to have a button labeled “Advanced settings”?
  • After Imager finished writing an iso to a USB drive, Imager said we can remove the USB drive.
    • "df -h" does not show the USB drive. This is consistent with the "Disks" application or "sudo mount" command.
    • File manager Files/Nautilus for GNOME shows the USB drive can be umounted?? But if we click it to umount the USB drive, Imager or Etcher cannot find the USB drive unless we unplug and plug the drive again.
    • After running sudo umount /dev/sdX* , Files still shows we can umount the USB drive. And Imager or Etcher can use the USB drive.
    • So, use "df -h" to decide if the USB drive is mounted or can be removed. Use "lsblk" to decide if the USB drive is available by the system like Imager or Etcher.

Raspberry Pi OS 1.1 Bulleye

How To Upgrade To Raspberry Pi OS 11 Bullseye (From Buster)

Format a SD card using SD Formatter (Windows & Mac)

SD Card Speed Test: agnostics

Install an image to a SD card

For example, if I want to install coder, I first download/uncompress the file. Then from the linux command line (assume microSD card is on /dev/sdc)

sudo umount /dev/sdc*
sudo dd bs=4M if=Downloads/coder_v0.4/raspi.img of=/dev/sdc; sync

If I want to watch the progress, I can open another terminal and issue

sudo pkill -USR1 -n -x dd

The output of it still is shown on the 1st terminal where dd is issued. The output looks like

224+0 records in
224+0 records out
939524096 bytes (940 MB) copied, 40.9672 s, 22.9 MB/s
268+0 records in
268+0 records out
1124073472 bytes (1.1 GB) copied, 62.7471 s, 17.9 MB/s

Monitor the progress using pipe viewer

sudo apt-get install pv
dd if=/dev/urandom | pv | dd of=/dev/null

Check the filesystem on microSD card

  • Check SD card for any error
    dmesg | grep -i "mmc"
    # OR
    journalctl -k | grep -i "mmc\|I/O error\|mmcblk"
    

    Look for messages like “mmc0: Timeout waiting for hardware,” “I/O error,” or “Buffer I/O error on dev mmcblk0p2,” which indicate potential SD card problems.

  • Repairing a Raspberry Pi Boot Partition
    # rootfs is ext4 
    umount /dev/sdc2
    sudo fsck /dev/sdc2
    
    # boot partition is fat32
    sudo dosfsck -t -a -w /dev/sdc1
    

Secure your Raspberry Pi

Wifi setup

A new wifi setup is included in the Raspbian. It is called dhcpcd and dhcpcd-ui. The package name is called 'raspberrypi-net-mods'. PS. the old way is called 'wpa_gui'.

See the blog on May 5, 2015.

NetworkManager - nmcli/nmtui

  • Configuration -> Networking from the official Raspberry Pi Documentation.
  • In the old days, the network configuration file is typically located at /etc/wpa_supplicant/wpa_supplicant.conf. Currently, Raspberry Pi OS is using Network Manager. We can confirm this and manage wireless connections by using the commands: nmcli device or sudo systemctl status NetworkManager.
  • Two essential commands:
    nmcli device wifi
    sudo nmtui
  • Installing Network Manager on Raspberry Pi OS 2022
    • By default, the Raspberry Pi uses an older software called dhcpcd for its network handling. It is a bit more complicated to configure and has been superseded by Network Manager. Note. Bookworm use NM by default.
    • I follow the instruction to change the default network method from dhcpcd to NetworkManager
    • After reboot, the wifi icon shows no connection
    • I have a USB wifi adapter. I use the USB wifi adapter to connect to my hotspot (not the primary network) and the pi's broadcom BCM43438 combo is connected to my primary network
    • 'nmcli device wifi list' shows both have 100 SIGNAL though the hotspot one has 130 Mbit/s but the primary network has 2870 Mbit/s
    • On my hotspot host, I can use ip neigh to get the connected device's IP, like 10.42.0.xxx. Or using the command nmap -sn 10.42.0.0/24
    sudo apt install network-manager
    
    # fix "NetworkManager is not running"
    # but it seems it will disconnect the default method 'dhcpcd'
    # in raspbian 11 (bullseye) 32-bit
    sudo /etc/init.d/network-manager start
    # OR
    sudo systemctl start NetworkManager
    
    # List available WiFi networks including SSID, Channel, Rate, Signal, Bars, and Security.
    # The 'RATE' will show something like 130 Mbits/s
    nmcli device wifi list   
    
    nmcli device wifi connect <SSID> password <password>  # Connect to a WiFi network
    
    nmcli con show  # Show all network connections
    
    nmcli con up id <connection_name>  # Bring up a connection
    
    # OR use
    nmtui  # then go to 'Activate a connection'
  • The network connection profiles are stored in the /etc/NetworkManager/system-connections/ directory.

Multiple WiFi Networks

Use a usb wifi dongle instead of build in wifi

USB adapters

File:Wifiusb.jpg

Wi-Fi is currently blocked by rfkill

How to disable "Wi-Fi is currently blocked by rfkill." message?

Processor

Bootloader

Boot from USB

Put rootfs in USB

Network boot (PXE) w/o microSD

USB network in Pi zero

Mount a USB drive at boot

Add the following line to /etc/fstab (change any values if necessary) and then run sudo mount -a

/dev/sda1 /mnt/share ext4 rw,user,auto 0  0

Also consider to change the mode of the new partition eg sudo chmod 777 /mnt/share.

Pi Desktop

https://www.element14.com/community/docs/DOC-83477

Remote desktop

RealVNC server

  • Do not download the binary from RealVNC website since it will have a license issue when we want to connect to RPi
  • VNC Connect and Raspberry Pi
  • Use the instruction at Github
  • The current Raspbian includes a vnc server. We need to enable it. No registration is needed when I use my home network. I tested using iOS vnc app.
  • On linux client side, we can download the binary tar ball and set it executable after untar it.

Connect to Your Raspberry Pi With VNC Connect

Chrome

VNC Viewer

Thin client

Proxmox thin client

Dataplicity

It is not remote desktop but it allows you to access Raspberry Pi from any web browser (no router change, no VPN, no port forward).

To switch to a sudoable account, type su pi. From there you can 'sudo' as normal.

NoMachine

Tips on how to set up your Raspberry Pi for remote access via NoMachine

Web server

WordPress server

How to Host a WordPress Site on Raspberry Pi

Connection to Raspberry Pi with tightvnc

A simple password like 'raspberry' would work. If we need to reset the password, use vncpasswd command.

# Server side
sudo apt-get install tightvncserver
vncserver
# You will require a password to access your desktops.
# Password: 
# Warning: password truncated to the length of 8.
# Verify:   
# Would you like to enter a view-only password (y/n)? n
#
# New 'X' desktop is raspberrypi:1
#
# Creating default startup script /home/pi/.vnc/xstartup
# Starting applications specified in /home/pi/.vnc/xstartup
# Log file is /home/pi/.vnc/raspberrypi:1.log
ps -ef | grep vnc
# pi        3134     1  0 16:59 pts/0    00:00:00 Xtightvnc :1 -desktop X -auth /home/pi/.Xauthority 
# -geometry 1024x768 -depth 24 -rfbwait 120000 -rfbauth /home/pi/.vnc/passwd -rfbport 5901 -fp 
# /usr/share/fonts/X11/misc/,/usr/share/fonts/X11/Type1/,/usr/share/fonts/X11/75dpi/,/usr/share/fonts/X# 11/100dpi/ -co /etc/X11/rgb
# pi        3217  2666  0 17:01 pts/0    00:00:00 grep --color=auto tightvnc

vncserver             # This line seems not necessary
vncserver –kill :1

# Client side; the most common mistake is to forget to add the port number to the IP address.
sudo apt-get install xtightvncviewer
xtightvncviewer 10.42.0.37:1
# It does not work if I just use raspberrypi.local:1 as the address

To start the tightvnc automatically when boot up, check out http://www.penguintutor.com/linux/tightvnc or my note on BBB.

Also note if the server uses '/usr/bin/vncserver :0', then the client uses 'xtightvncviewer 10.42.0.37'. But if the server uses '/usr/bin/vncserver :1', the client should uses 'xtightvncviewer 10.42.0.37:1', etc. Got the idea!

Note that to troubleshoot the message "GDBus Error:org freedesktop.PolicyKit1 Error.Failed; An Authentication agent already exixts for the given subject", follow the instruction at this message.

Connection from Raspberry Pi to Ubuntu

Follow the instruction and install xtightvncviewer using sudo apt-get and it works. To run the vnc client, just type 'xtightvncviewer' on the terminal.

Another instruction of using tightvnc is at http://www.penguintutor.com/linux/tightvnc.

I have successfully to follow the instruction at http://www.hiddentao.com/archives/2013/09/17/setting-up-tightvnc-on-ubuntu-12-04/ to connect to Ubuntu 12.04 (Unity desktop) from Xubuntu. After launching the following line in my local machine

ssh -L 5901:localhost:5901 [email protected]

I open another terminal window and type the following in my local machine

xtightvncviewer localhost:5901

the Ubuntu desktop appears on my local machine.

Connection from Raspberry Pi to Windows (RDP) with freerdp or rdesktop

The idea is to use Raspberry Pi as a thin client. For example, I can open two remote desktop connections to two separate Windows VMs and the RPi is still quite free in terms of its resource.

Method 1 Use xfreerdp program. Use Ctrl+Alt+Enter to toggle between full and regular screen. Non-full-screen-mode is useful if we want to monitor the RPi resource usage while we are using the remote desktop connection.

1. Open a root terminal. Run
apt-get update
apt-get install freerdp
2. Open a regular terminal. Run
xfreerdp -u brb -x l -z 192.168.1.4

Method 2 We can also use rdesktop program. rdesktop is a free, open source client for Microsoft's proprietary RDP protocol. See wiki.archlinux.org for more tips and tricks about rdesktop. {Pre}} 1. Open a root terminal and run apt-get update apt-get install rdesktop 2. Open a regular terminal and run (-f means full screen. Or we can use -g 1280x700 to specify the display resolution) rdesktop -f -u brb 192.168.1.4

Method 3 There is also an interesting project called RPi-TC/Raspberry Pi Thin Client project. I have not tried it yet.

Using a Kindle Fire As a Monitor

Using a Kindle Fire As a Monitor

Raspbian

Desktop vs Console

  • Desktop: 105MB memory
  • Console: 50MB memory

Directly Connect to a Raspberry Pi Without Internet

http://www.makeuseof.com/tag/directly-connect-raspberry-pi-without-internet/

Recovery partition

Make a self-healing raspberry pi: create a recovery partition

Working from home with your Raspberry Pi

https://www.raspberrypi.org/blog/working-from-home-with-your-raspberry-pi/. Set up email, Office, Google Drive, VPN client, Google hangout (video conference), Skype, VPN Connect.

Raspbian desktop for PC

Download it from here.

Tested Debian Stretch version (2019-4-11) on Virtualbox. It can be installed as either 32-bit or 64-bit OS (uname -m).

Raspbian repository and mirrors

Releases lists

Raspbian package repository URL

http://archive.raspbian.org/raspbian/pool/main/r/r-base/

Widevine support to play Amazon Prime,..

Sending an email on boot

See the wiki page - Email IP On Boot.

@reboot sleep 300 && python /home/pi/startup_mailer.py

Fix Dirty COW

https://www.raspberrypi.org/blog/fix-dirty-cow-raspberry-pi/ (10/25/2016)

Kernel building

Create a custom kernel using Vagrant

Emulate Raspbian on Linux/Windows

Emulate Intel X86 on raspberry Pi (ARM)

https://eltechs.com/product/exagear-desktop/ (non-free)

Digital clock format

Right click task bar -> Panel Settings -> Panel applets -> Digital clock -> Preferences -> "%r %a %D" (default is %R). This will give something like "08:19:11 PM Sun 01/21/18".

Browser

GNOME Web/Epiphany browser

This is the default in Raspbian Jessie.

Some annoying thing is the browser is using the DuckDuckGo as the search engine which is not configurable.

Some web pages cannot be shown correctly (see my comment in LuaKit)

LuaKit - an extremely lightweight browser based on webkit and GTK+

This is very cool. It solves the issue of using Web to open http://magazine.odroid.com. It even supports Adobe Flash (eg some videos from Amazon.com)

sudo apt-get install luakit

Mastering keybinds is the key to use it (Even a mouse cannot be used to close a Tab).

Some examples:

  • :open URL to open a new website
  • j/k to scroll down/up
  • space or ctrl+d / Ctrl+u to scroll down/up one page
  • h/l to scroll left/right
  • +/- to zoom in/out.
  • (ctrl + o) OR (shift + h) to go to the previous page. Ctrl + i to go forward.
  • forward slash (/) to search within the page. Use n to find the next occurrance, N to find the previous one.
  • B for bookmark
  • gB to show bookmarks
  • gH to go to home page
  • : command mode
  • Esc normal mode
  • t open webpage in new tab
  • d delete current tab
  • :print print page

We can modify the key bindings. I run

sudo nano /etc/xdg/luakit/binds.lua

and on line 321 about "Go back in the browser history" (search the keyword 'history'): change "H" to "b". Now I can hit the lowercase 'b' button to go back to a previous web page instead of Shift+h.

    key({}, "b", "Go back in the browser history `[count=1]` items.",
        function (w, m) w:back(m.count) end),

Iceweasel browser

This browser looks like a clone of Firefox (firefox is not available in the repository). The version in Raspbian Jessie is 38.4.0. If iceweasel is not installed (e.g. jessie 8.0), we can install it by

sudo  apt-get install iceweasel --no-install-recommends

Firefox browser

See Iceweasel above. Firefox package has been replaced by Iceweasel so it is not available via apt-get install.

Vivaldi browser

http://www.makeuseof.com/tag/vivaldi-best-browser-raspberry-pi/

Chinese input

sudo apt-get install fcitx fcitx-chewing

Reboot. Menu - Preferences - fcitx - click ‘+’ sign - uncheck’Only show current language’ - select chewing. Done. The task bar will show an icon to let you switch the language (ctrl + space bar). Tested on jessie 8.0 and buster 10.

Raspbian uses PIXEL desktop, a modified LXDE desktop environment.

We need to add chewing to the input method. See this postfor a detailed instruction.

Bluetooth keyboard

The GUI program blueman does not work on the pairing step (it does not accept my entered keys) for my bluetooth keyboard (my bluetooth mouse works).

My working example is to use the command line way (bluetoothctl). The bluetoothctl utility is part of the bluez package I think. Raspbian Jessie does not have the bluez-utils package). See https://wiki.archlinux.org/index.php/Bluetooth

# Press the 'connect' button on the bluetooth keyboard first!
$ bluetoothctl # no sudo is needed
[bluetooth] default-agent
[bluetooth] scan on
[bluetooth] pair 90:7F:61:8F:D0:38        # it will ask to enter a pin code
[bluetooth] connect 90:7F:61:8F:D0:38

It is also interesting to see bluetooth related programs under /usr/bin directory. Those programs shown on my Raspbian are quite different from the ones shown on my Ubuntu 14.04.

New Bluetooth GUI in Raspbian

https://www.raspberrypi.org/blog/another-update-raspbian/ (May 13, 2016). This should solve the problem mentioned above though I haven't tried it.

Text editor

Why Coding for Raspberry Pi Is Way Better With Code-OSS, a community compiled version of VS Code, on the Raspberry Pi.

Pi zero

Getting Started with the Raspberry Pi Zero W (mini HDMI) without a Monitor

https://www.losant.com/blog/getting-started-with-the-raspberry-pi-zero-w-without-a-monitor (Raspbian Stretch)

Turn Raspberry Pi Zero into a USB gadget

  • Pi Zero USB OTG. GPIO Zero is installed by default in the Raspbian image
  • Connect To A Raspberry Pi Zero With A USB Cable And SSH. The same procedure works on Pi Zero W. Still there is no internet on my zero W unless we create wpa_supplicant.conf under /boot. In summary, we need to modify 2 files and create 1 file.
    • config.txt (?)
    • cmdline.txt (?)
    • wpa_supplicant.conf (wifi password)
    • /etc/dhcpcd.conf (static IP)
    • ssh
# Stretch lite
pi@raspberrypi:~ $ free -m
              total        used        free      shared  buff/cache   available
Mem:            433          23         336           3          73         359
Swap:            99           0          99
Run sudo raspi-config and sudo apt update after we connect RasPi.

Add USB type A to Raspberry Pi zero

Raspberry Pi Zero with USB socket Type-A expand (solder)

Top 10 Raspberry Pi Zero Projects That Make Use of Its Small Stature

http://lifehacker.com/top-10-raspberry-pi-zero-projects-that-make-use-of-its-1792403310

OpenElec

I use NOOBS to install OpenElec with Raspbian.

Still there is no a regular web browser. Not a joke. Remember OpenElec is installed in multiboot mode through NOOBS. Probably a better approach is to consider Arch-Linux.

There is a program called 'Web viewer'. Wonder when would it be useful.

Need to change 2 settings in order to get date & time correctly.

Another installation method is to download/install the image directly from the OpenELEC website. See

  1. http://openelec.tv/get-openelec
  2. http://wiki.openelec.tv/index.php/HOW-TO:Installing_OpenELEC/Writing_The_Disk_Image

Minimal server

Set up a minimal server on a Raspberry Pi

  • Static IP using IP4
  • Disable IPv6
  • Disable WiFi, Bluetooth, and audio
  • Disable modem service
  • Install Cockpit

Fedora ARM minimal server

Set Up a Test Server on Raspberry Pi. Cockpit.

Email server

Host your own email with projectx/os and a Raspberry Pi

SMS server

Kodi black screen when exit

A temporary solution is use Ctrl + Alt + F2 then Ctrl + Alt + F1. See

    #!/bin/bash
    fbset_bin=`which fbset`
    xset_bin=`which xset`
    xrefresh_bin=`which xrefresh`
    if [ ! -z $fbset_bin ]; then
      DEPTH2=`$fbset_bin | head -3 | tail -1 | cut -d " " -f 10`
    fi
    kodi "$@"
    if [ ! -z $fbset_bin ]; then
      if [ "$DEPTH2" == "8" ]; then
        DEPTH1=16
      else
        DEPTH1=8
      fi
      $fbset_bin -depth $DEPTH1 > /dev/null 2>&1
      $fbset_bin -depth $DEPTH2 > /dev/null 2>&1
    fi
    if [ ! -z $xset_bin ] && [ ! -z $xrefresh_bin ]; then
      if [ -z $DISPLAY ]; then
        DISPLAY=":0"
      fi

      $xset_bin -display $DISPLAY -q > /dev/null 2>&1
        if [ "$?" == "0" ]; then
          $xrefresh_bin -display $DISPLAY > /dev/null 2>&1
        fi
    fi
    VT="$(fgconsole)"
    if [ "$VT" ]; then
      sudo chvt 7
      sudo chvt "$VT"
    fi

and a simpler solution

#!/bin/bash
kodi
if [ "$?" = "0" ]; then
killall kodi
fbset -depth 8 && fbset -depth 16
xrefresh
fi

Corebird - twitter client

We also need automake, autoconf, autogen, intltool packages.

Unfortunately running ./autogen.sh --prefix=/usr gets stuck at the error message 'configure error: valac >= 0.28.0 is required'. At this moment, valac has a version 0.26. See https://packages.debian.org/jessie/valac.

Backup Raspbian

How to Back Up Your Raspberry Pi as a Disk Image Aug 2020. The approach is not to back up directly to a microSD card but to create a compressed disk image that’s even smaller than the amount of used space on the source microSD card you’re backing up. The instruction confused me. If pishink can shrink an image, why do we need to bother gparted? Gparted can shrink a partition on microSD card but pishrink is used to shrink an image file. So the steps

  1. (Optional) Put the Raspberry Pi microSD in another Linux computer and use Gparted to shrink the rootfs partition
  2. Boot from Raspberry Pi from the microSD card
  3. Use the dd command to create an image. Add the count attribute if rootfs has been shrunk. Note: if I follow the instruction to specify the count parameter, I will run into an error pishrink.sh v0.1.2 pishrink.sh: Gathering data ... Error: Can't have a partition outside the disk! pishrink.sh: ERROR occured in line 273: parted failed with rc 1 in the step of calling pishrink.sh. I got the same error no matter I run pishrink.sh from Raspberry Pi or Ubuntu.
  4. Apply pishrink utility to shrink the image file

My case:

# On Pi
# I use gparted to resize SD card's rootfs on another Ubuntu computer
# The writing speed is 13.3 MB/s. So it took about 17000/13.3/60=21 min
# The output img size is 30GB (My SD card is 32 GB)
$ df -h /
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        17G   15G  1.1G  94% /
$ sudo dd if=/dev/mmcblk0 of=/media/pi/ext4/rpi3backup.img bs=4M status=progress
$ sudo umount /dev/sda

# On Ubuntu 18.04
$ sudo pishrink.sh -z -v -a /media/brb/ext4/rpi3backup.img ~/rpi3backup.img.gz
pishrink.sh v0.1.2
pishrink.sh: Copying /media/brb/ext4/rpi3backup.img to /home/brb/rpi3backup.img... ...
pishrink.sh: Gathering data ...
Creating new /etc/rc.local
pishrink.sh: Checking filesystem ...
rootfs: Inode 3266 extent tree (at level 2) could be narrower.  IGNORED.
rootfs: Inode 258285 extent tree (at level 1) could be narrower.  IGNORED.
rootfs: Inode 258318 extent tree (at level 1) could be narrower.  IGNORED.
rootfs: 307763/1072512 files (0.2% non-contiguous), 3887460/4354048 blocks
resize2fs 1.44.1 (24-Mar-2018)
pishrink.sh: Shrinking filesystem ...
resize2fs 1.44.1 (24-Mar-2018)
Resizing the filesystem on /dev/loop0 to 4180645 (4k) blocks.
Begin pass 2 (max = 50911)
Relocating blocks             XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 3 (max = 133)
Scanning inode table          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 4 (max = 38066)
Updating inode references     XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/loop0 is now 4180645 (4k) blocks long.

pishrink.sh: Shrinking image ...
pishrink.sh: Using pigz on the shrunk image ...
/home/brb/rpi3backup.img to /home/brb/rpi3backup.img.gz 
pishrink.sh: Shrunk /home/brb/rpi3backup.img.gz from 30G to 7.1G ...

https://www.raspberrypi.org/documentation/linux/filesystem/backup.md

# Backup
sudo dd bs=4M if=/dev/sdb | gzip > raspbian.img.gz
sudo dd bs=4M if=/dev/sdb | pigz -9 > raspbian.img.gz
# Restore
gunzip --stdout raspbian.img.gz | sudo dd bs=4M of=/dev/sdb

See also

SD Card Copier

Raspbian Menu > Accessories > SD Card Copier. It works. The SD card size can be smaller than the original one as long as it has a larger size than the current "/dev/root" partition. After the microSD card has been used once by SD Card Copier, then it can not be used again by the utility (the SD card is labelled in Copy to Device option but it's greyed out. Note even the File Manager cannot mount it in Raspbian but Ubuntu still can auto mount the microSD card). Why? When I insert a ext4-formatted USB drive, the SD Card Copier can use it.

piclone

https://github.com/raspberrypi-ui/piclone

PiShrink

  • https://github.com/Drewsif/PiShrink. PiShrink is a bash script that automatically shrink a pi image (assume you have ) that will then resize to the max size of the SD card on boot. This will make putting the image back onto the SD card faster and the shrunk images will compress better. In addition the shrinked image can be compressed with gzip and xz to create an even smaller image.
    $ sudo pishrink.sh pi.img
    

Others

How to transfer a Raspbian image from a 16GB MicroSD card to an 8GB SD card

Backup server

Git server

Host Git Server on RaspberryPi! | 4K TUTORIAL

USB over ip

Its mainuse is to let you access data on USB drives stored on other hardware.

Top 10 Apps You Should Install on Your Raspberry Pi

RAID

How to Set up RAID-1 on the Raspberry Pi, the Easy Way

NAS

ownCloud

OpenMediaVault

NextCloudPi

https://ownyourbits.com/nextcloudpi/

Proxy server

How to Use a Raspberry Pi as a Proxy Server (with Privoxy)

DNS server

Pi-hole

One way to test it is to open the Android app 'Taiwan Radio' or 'FainTV'. You will see the ads cannot be loaded anymore. In fact, this also fixed the buffering problem when I use the 'Taiwan Radio' app.

Install on Pi

  • No 'sudo'
  • Uncheck to install lighttpd since I have apache installed already
curl -sSL https://install.pi-hole.net | bash
  • I am using wifi and it works fine
  • New directories /var/www/html/admin (main directory) and /var/www/html/pihole (only 2 files) are created.
  • At the end it will say the install log is in /etc/pihole
  • The web interface is at http://pi.hole/admin or http://192.168.x.x/admin. The Admin Webpage login password will be shown on the text UI and the terminal too (remember to save it).
  • The pi-hole admin password can be reset by pihole -a -p
  • Ports 53 and 80 need to be opened. sudo netstat -tulpn | grep LISTEN
  • To change the interface from eth0 to wlan0, use pihole -r to reconfigure. see Change ip adress
  • My current pi-hole version is v4.4 (2020-04), AdminLTE v4.3.3 and FTL v4.3.1. pihole -v It also shows what is the latest versions.
  • On my Dasung non-ereader tablet (Android 8.1.0) it does not have DNS option on WiFi network. I install DNSPipe. It seems to work. It does ask something related VPN, why?

Local DNS Record This allows you to map your own domains to your private network.

Update

$ pihole -up

After I upgrade to 5.0, the stats on the dashboard is not working. A solution is here. sudo apt install php7.0-sqlite and sudo service apache2 restart. Use php -v to check your PHP version before confirming the exact module name to install.

Uninstall

sudo rm -rf /etc/.pihole /etc/pihole /opt/pihole \
  /usr/bin/pihole-FTL /usr/local/bin/pihole \
  /var/www/html/pihole /var/www/html/admin
$ pihole uninstall
....
  [i] The following dependencies may have been added by the Pi-hole install:
    dhcpcd5 git iproute2 whiptail cron curl dnsutils iputils-ping lsof netcat psmisc sudo unzip wget idn2 sqlite3 libcap2-bin dns-root-data libcap2 lighttpd php7.0-common php7.0-cgi php7.0-sqlite3 php7.0-xml php-intl 
  [?] Do you wish to go through each dependency for removal? (Choosing No will leave all dependencies installed) [Y/n] n
  [✓] Removed Web Interface
  [✓] Removed /etc/cron.d/pihole
  [✓] Removed lighttpd configs
  [✓] Removed config files
  [✓] Removed pihole-FTL
  [✓] Removed pihole man page
  [✓] Removed 'pihole' user
...

Migrating Pi-Hole from lighttpd to apache

sudo apt-get remove lighttpd

Whitelist

Use pi-hole as the only DNS

On my Android galaxy tab s6 lite, I set up two DNSs. Even pi-hole is the 1st DNS, for some reason, the 2nd DNS was used. So ads are not blocked.

I can try checking the Pi-hole logs to see if there are any issues or errors that could be causing delays in resolving queries. I can access the logs by logging in to the Pi-hole web interface and navigating to the “Tools” section and then selecting “Tail pihole.log”. This will show you a live view of the Pi-hole log file and you can see if there are any issues or errors that could be causing delays in resolving queries.

I can also try adjusting the cache size in Pi-hole. Please note that increasing the cache size may improve performance, but it will also increase memory usage. You should choose a cache size that is appropriate for your system’s resources.

sudo nano /etc/dnsmasq.d/01-pihole.conf
# Find the line that starts with cache-size and change the value
sudo service pihole-FTL restart

VPN server

VPN client

How to Install a VPN on Your Raspberry Pi

IPV6 connectivity

https://raspberrypi.stackexchange.com/questions/37/ipv6-connectivity

There are no hardware limitations for IPv6 connectivity, only software must support it. On Arch distribution, IPv6 is enabled by default, so if you have a router with DHCPv6 or RA, you will automatically get connected to the IPv6 internet.

Raspbian supports IPv6, but the kernel module is not loaded by default (which is a crying shame in the wake of recent developments). IPv6 can be enabled at run time by modprobe ipv6 command or at boot time by appending ipv6 to /etc/modules.

Connect your dumb USB printer to your home network

Raspberry Pi Print Server: Setup a Network Printer. The steps are

  1. Installing the Raspberry Pi Print Server Software (Cups)
  2. Setting up SAMBA for the Pi Print Server (Samba)
  3. Adding a printer to CUPS
  4. Adding a Raspberry Pi Print Server to Windows

Done!

Another instruction How to set up a print server on a Raspberry Pi

6 Ways to Print With a Raspberry Pi

NagiosPi: Turn Your Raspberry Pi into a Network Monitoring Tool

Embedded Linux

What I Wish I’d Known When I Was an Embedded Linux Newbie from Linux Journal.

How to Install Windows Software on Raspberry Pi Using Wine

https://www.makeuseof.com/tag/install-windows-software-raspberry-pi/

Virtualization

Rpi-Monitor: monitor a Linux system

Monitor/manage multiple raspberry pis

Use a systemd unit/service file to control an application to start when Raspberry pi boots up

  • Systemd Essentials: Working with Services, Units, and the Journal
    # Start the service
    sudo systemctl start nginx.service
    # Stop the service
    sudo systemctl stop nginx.service
    # Restart the service
    sudo systemctl restart nginx.service
    # Reload the service
    sudo systemctl reload nginx.service
    
    # Enable a service to start automatically at boot
    sudo systemctl enable nginx.service
    # Disable the service again
    sudo systemctl disable nginx.service
    
    # List all active unit files
    systemctl
    systemctl | grep epaper.service 
    # Note: ps -ef won't detect epaper.service
    
    # List all the units installed on the system
    systemctl list-unit-files
  • See Raspberry PI 3 E-paper 2.7 inch Clock and Weather Display example from E-ink section.
  • Configure Docker to start on boot

Install node.js

Install Node.js and Npm on Raspberry Pi

Share your keyboard and mouse between computers with Barrier

Share your keyboard and mouse between computers with Barrier

Create a GUI app by GTK+

Ultrasonically detect bats with Raspberry Pi

Mate Ubuntu

The desktop looks good. But it does not include Mathematica software nor Arduino. It does include Scratch, Sonic Pi (under Programming) and Minecraft Pi (under Games).

After Raspi2 is on for several days with Firefox browser use, the memory is getting lost even Firefox is closed. top command shows /usr/sbin/irqbalance ate 48% memory. It works when I use sudo kill -9 to stop the process. See some discussions at askubuntu.com set ENABLED=0 in /etc/default/irqbalance.

The system looks very stable. See my screenshots below.

Mate1510Raspbery.png Mate1510Raspbery2.png

Ubuntu-mate 16.04 on Rpi 3B+

64-bit Ubuntu and more

SSH server

The website said the server is not installed by default. To install it, run sudo apt install openssh-server

To start it at startup,

sudo systemctl enable ssh.service

Change to use static IP

Use GUI network manager

Install more screensaver themes

http://greyblake.com/blog/2013/02/02/install-more-screensavers-on-mate-desktop/

Take a look at the .desktop files under /usr/share/applications/screensavers.

Web browser

Ubuntu-Mate includes Firefox. I can feel FF is more slow than the browser in Raspbian.

Printer

(Update 12/11/2016): the instruction below using PPD file still has a problem when I print pdf files. The instruction here solves the problem. The idea is to download the official Linux driver (<linux-brprinter-installer-2.1.1-1.gz>) from brother website HL-5250DN.

When I try to add a new Printer (network printer, Brother HL-5250DN) through automatic detected method, I got an error "server-error-internal-error". When I looked at the /var/log/cups/error_log file, it showed "empty PPD file". The following two pages are helpful.

The manual approach mentioned in bugs.launchpad.net (#6) works.

  1. System -> Adminstration -> Printers -> Add
  2. Enter URI and specify ipp://192.168.1.88:631/ipp as the Device URI (the address is obtained through the nmap command and look for port 631)
  3. Check the 2nd option 'Provide PPD file' instead of the 1st one 'Select printer from database'.
  4. Browse the location of the PPD file
  5. Continue the procedure until the end. We can print a test page to make sure the setup is successful.

The printer test page said the driver is BR5250_2.PPD and version 1.03.

PS. About the technology terms

Kodi

After I used apt-get to install Kodi, Kodi will not be able to launch:( On Raspbian, the Kodi installed by apt-get works!!!

Operating Systems for Various Purposes

Twister OS

Twister OS Gallery

Arch Linux

Kodi can be installed in ArchLinux by installing the kodi-rbp package. See wiki.archlinux.org.

Android

pi-top

I pledged pi-topCEED ($99 + shipping is $25). The hardware looks cool: 14 inch, 1366x768 resolution (like an old laptop/Hanns.G monitor) & a GPIO card that helps to connect 3 wires from pi-top hub to Raspberry Pi. One problem is after connecting the wires from pi-top hub to Raspberry Pi, there is not enough space for me to slide in the cover.

Unfortunately the pi-top OS is unstable (tested 7/1/2016).

  • first try - screen flicked & is frozen
  • I download the image (homepage -> Community -> FAQ) and write it to the sd card - works great but after another boot the screen appeared and then disappeared.

I found when I connect the wires of 3-pins with a wrong direction, Raspi still works (pi-top OS & Raspbian). It seems only the 5v and gnd pins are needed.

For some reason, after I shut down the computer the back light is still on. The software from rricharz in github can let Rasbpian users to change the brightness of the screen and also power off the pi-top (bright light off). The original post is on the pi-top forum with the subject 'Using standard Raspbian Jessie on pi-top'.

40-pin connector vs jumper cables. We can use Google account to join.

  • The current pi-topCEED webpage
  • Detect and configure pi-top hubs and accessories on Github
  • pi-topHub-v1 used by pi-topSEED. The hub is responsible for managing the display and audio signals.

Some pictures (left: Pi-top, middle: pi-top hub, right: raspberry pi 3 with a GPIO card). The pin numbers are sequential.

  • Cable 1: connect to pins 4 (red to 5v) & 6 (black to GND).
  • Cable 2: connect to pins 19, 21 & 23 (3 holes face down). All are SPI pins.
  • Cable 3: connect to pin 26. SPI pin.

Pitop1.jpg Pitophub.jpg Raspi3.jpg

Backlight: When the display goes to blank, the backlight is still on. With Pi-Top Sirius OS, it (see the Github page) provides a python command to turn the backlight off. The problem is this has to be done manually (pt-brightness --backlight 0 ). And after we did it manually we are unable to see the screen; so it is difficult to interact with the system ? (simple experiment: pt-brightness --backlight 0; sleep 15; pt-brightness --backlight 1 )

Maybe it is possible to add a button/switch to launch a command for controlling the backlight.

  • Using a push button with Raspberry Pi GPIO. This works after we change the callback function. Step 1. Run the script ‘’python push_button.py’’, step 2. Run ‘’pt-brightness —backlight 0’’ when we want to turn off the backlight 3. Press the button when we want to turn back the backlight.
import os
def button_callback(channel)
    os.system(‘date; pt-brightness —backlight 1’)

pi-topOS

It is based on LXDE but the desktop looks very modern (thumbs up). It is based on the latest Raspbian (Buster).

I feels the theme is like Pop!_OS. Very clean and good icon/font size on pi-topCeed.

File:Pitopos.png

Media server

How to Set Up a Raspberry Pi Media Server: 7 Ways 2020

Plex

DVR

How to build a cheap cord-cutting DVR using Raspberry Pi

Kodi/XBMC and OpenElec

  • Install Kodi on Raspbian
  • For some reason, I did not find 'Display Mode' option in the System > Settings > System > Video Output in the OpenElec. When I install Kodi (14.2 Mar 27 2015) in Ubuntu 14.04, I can see this option.

Then OpenElec from NOOB works fine.

How to fix Youtube daily limit exceeded

https://kodihome.blogspot.com/

How to Set Up a Kodi Remote Control

https://www.makeuseof.com/tag/set-up-kodi-remote-control/

7 Essential Kodi Tips for New Users

http://www.makeuseof.com/tag/essential-kodi-tips-new-users/

12 Ways to Make Kodi the Best Media Player for You

http://www.makeuseof.com/tag/make-kodi-best-media-player/

The 12 Best Kodi Add-Ons for Watching Live News

https://www.makeuseof.com/tag/best-kodi-add-ons-live-news/

What is OpenElec

Unlike other Kodi solutions, OpenELEC is not based on Ubuntu. In fact, it's not based on any Linux distribution; OpenELEC has been built from scratch specifically to act as a media center. That means it doesn't include drivers for things that just won't be used like 3G cards and graphics tablets, for example.

OpenELEC, however, only includes software required to run Kodi. Because of that it is tiny (roughly 150MB), it installs literally in minutes, and, it can boot extremely quickly in 5-20 seconds, depending on the hardware type used.

In addition, OpenELEC is designed to be managed as an appliance: it can automatically update itself and can be managed entirely from within the graphical interface. Even though it runs on Linux, you will never need to see a management console, command terminal or have Linux knowledge to use it.

Default folders for OpenElec

OpenELEC:~ # ls
backup       emulators    music        screenshots  videos
downloads    lost+found   pictures     tvshows
OpenELEC:~ # df -h
Filesystem                Size      Used Available Use% Mounted on
devtmpfs                165.2M         0    165.2M   0% /dev
/dev/mmcblk0p5          159.8M    103.7M     56.1M  65% /flash
/dev/mmcblk0p6           13.3G    706.6M     11.9G   5% /storage
/dev/loop0               93.9M     93.9M         0 100% /
tmpfs                   170.2M         0    170.2M   0% /dev/shm
tmpfs                   170.2M      4.6M    165.6M   3% /run
tmpfs                   170.2M         0    170.2M   0% /sys/fs/cgroup
tmpfs                   170.2M      4.0K    170.2M   0% /tmp
tmpfs                   170.2M    412.0K    169.8M   0% /var
/dev/mmcblk0p1          820.2M    744.4M     75.8M  91% /var/media/RECOVERY
/dev/mmcblk0p3           27.0M      1.2M     23.5M   5% /var/media/SETTINGS

Youtube plugin error

How to Fix Kodi’s YouTube “Quota Exceeded” Problem

How to Cast YouTube and Other Web Videos to Kodi (Like the Chromecast)

No sound

http://forum.kodi.tv/showthread.php?tid=130371

Click on the Volume icon and raise the volume from the default -60dB to a higher value.

Fix date/time in OpenElec

http://www.htpcbeginner.com/fix-openelec-incorrect-time-raspberry-pi/

Note the original post does not work on the current Kodi 14.1. The utility /usr/sbin/ntpdate is not found. Search the keyword 'daCaPo says' on the above webpage and following his answer does solve the problem. nano /storage/.config/autostart.sh and add the following

#!/bin/sh
(sleep 30; \
/sbin/ntpd -p pool.ntp.org; \
)&

Then chmod +x /storage/.config/autostart.sh. No need to reboot.

UPnP

When I enable the UPnP server function in Kodi, the Kodi can be found in the UPnp client program eg VLC (desktop), BubleUPnP, BSPlayer, Kodi, ....

The Kodi server will be seen to have Music Library and Video Library. The files in Video Library are the same as what I have in the Kodi but the Music Library does not have any songs (it only has Categories like Genres, Artists, Albums, Songs, Years, Top 100, Recently added albums, Recently played albums). According to this Kodi's wiki page: Your audio files MUST have a valid ID tag for them to work properly in the Kodi music library. . Probably it is for this reason, the songs do not appear in the UPnP client software (except the BSPlayer which can find all my songs in the music directory, but BSPlayer does not show my image files in the pictures directory. Such a pity!)

Display Chinese characters

http://forum.kodi.tv/showthread.php?tid=81081

Go to System - Settings - Appearance - Font and choose 'Arial'.

Add-ons

The USTV VoD and Navi-X and USTVNow (require US citizen & registration, free NBC, CBS, ABC, CW, FOX & PBS channels) work well. Just download the zip files in the linux and install them from xbmc -> system -> add ons -> install from local zip files.

Take a screenshot

ssh and run

kodi-send --action="TakeScreenshot"

A new file <screenshot000.png> will be saved under screenshots folder.

LXDE (same as Lubuntu) X11 desktop environment used by Raspbian OS

Inside .config/lxpanel is a directory with the name of your current lxsession profile - and inside this is a further subdirectory called panels.Each file in this directory is the definition of a single panel. See Magpi33.pdf.

Screenshots

Taking a screenshot

scrot

Quick launch bar

To add lxterminal to quick launch bar,

Right click any empty space on taskbar
-> Panel Setting
-> Panel Preferences
-> Panel Applets
-> Application launch bar & Edit
-> Accessories & lxterminal 

We can use the same procedure to add Midori to the quick launch bar.

Keyboard shortcut

The shortcuts are defined in the file ~/.config/openbox/lxde-rc.xml

For example,

  • open the lxpanelctl menu, click Ctrl + ESC.
  • open launch an application, click Windows + r.
  • Toggle full screen, Alt + F11.
  • Launch task manager, Ctrl + Alt + Del.

Get internet by sharing the internet from another machine

  • https://wiki.archlinux.org/index.php/Internet_Share
  • static iP. Set up host eth0 IP and then set up RPi IP:
    • In Windows, allow Internet sharing. An IP of 192.168.0.2 will be automatically assigned to the Laptop's network card. Make static IP of 192.168.0.2 in Rasp Pi. Enter subnet mask and gateway (192.168.0.1). Also make an entry in /etc/resolv.conf with nameserver=192.168.0.1. Reboot and Rasp Pi will get Net all right.
    • In Linux, An IP of 10.42.0.37 will be assigned to eth0 card. Make static IP of 10.42.0.37 in Rasp Pi. Enter subset mask and gateway (10.42.0.1). Also make an entry in /etc/resolv.conf with nameserver=10.42.0.1. Reboot and Rasp Pi will get Net all right.
    • Other thoughts:
sudo nano /etc/network/interfaces

iface eth0 inet static
address 192.168.100.1
netmask 255.255.255.0
network 192.168.100.0
broadcast 192.168.100.255
gateway 192.168.100.254

The gateway is important and in most cases will always point to your firewalls, switch or routers IP address.

In my current setting, the host machine's eth0 has IP 10.42.0.1 (inet addr). The RPi has IP 10.42.0.37 and gateway 10.42.0.1.

$ netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 wlan0
10.42.0.0       0.0.0.0         255.255.255.0   U         0 0          0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 wlan0
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 wlan0

And /etc/resolv.conf may be worth to be changed too. /etc/hostname and /etc/hosts are unnecessary.

An example of /etc/resolv.conf (set up linux DNS) shown from my RPi is

nameserver 10.42.0.1

But maybe another choice is nameserver 8.8.8.8.

Some tools for discovering the IPs in a network include Fing (iOS/Android) or Scapy (python).

Get internet from mobile tethering

https://github.com/InitialState/rpi-gps/wiki/10%20Part%203.%20Mobile%20Data

IP scan tools

  • arp-scan utility
    sudo apt install arp-scan
    sudo arp-scan --interface=INTERFACE_NAME --localnet  # eg wlan0
  • arp Address Resolution Protocol (fastest, installed by default). No "sudo" is required; i.e. "sudo" give the same result.
    sudo apt install net-tools
    arp -a 
    arp -a -i eth1      # if eth1 comes from a USB ethernet adapter
  • nmap command
  • fing (ios, android, linux, windows). Command line usage
    sudo fing -n 192.168.1.1/24

    where /24 means 'network prefix' size 24 bits. Check wikipedia classless inter domain routing. For example, CIDR notation 192.168.100.0/24 would be equivalent to 192.168.100.0/255.255.255.0.

  • Angry ip scanner cross platform. open source. It shows all instead of found ip's.
  • netbios. It does not discover linux boxes, however.
  • The 4 Best Network Scanning and Enumeration Tools
    • nmap
    • Zenmap (GUI of nmap)
    • Nessus
    • Netdiscover

Use Raspberry Pi as a Tunnel Gateway/Router

Clustering

Five years of Raspberry Pi clusters 2020. The Docker load-balanced LED cluster Raspberry Pi is interesting!

with 2 Pis

This Linux Journal article teaches how to run GlusterFS Server on two Raspberry Pis. This is also called redundant filesystem. So if one Pi is down, the other keeps the system up.

4 Pis

http://makezine.com/projects/build-a-compact-4-node-raspberry-pi-cluster/. It also shows how to display IP on 1 4pins 16x2 LCD (worked for Arduino & Raspberry Pi). No fancy software were installed to make the cluster.

Hadoop

Qt on Raspberry Pi

Check out https://qt-project.org/wiki/Qt-RaspberryPi

Native build Qt

http://qt-project.org/wiki/Native_Build_of_Qt5_on_a_Raspberry_Pi

Qt-Creator

Ubuntu Snappy

Some more information about ubuntu snappy (username/password is ubuntu/ubuntu):

Suppose I connect my Raspberry Pi 2 get its internet through my computer's USB-ethernet adapter. Then once RPi 2 is on, I can open my browser on my host PC and go to http://webdm.local:4200/. It shows

SnappyRaspPi.png

Note that the SNAPPY UBUNTU CORE image for RPi seems buggy. For example, {Pre} ubuntu@localhost:~$ sudo su root@localhost:/home/ubuntu# dpkg-reconfigure tzdata cp: cannot create regular file '/etc/localtime.dpkg-new': Read-only file system

Current default time zone: 'America/New_York' Local time is now: Thu Jan 1 01:01:42 UTC 1970. Universal Time is now: Thu Jan 1 01:01:42 UTC 1970.

debconf: DbDriver "config": could not write /var/cache/debconf/config.dat-new: Read-only file system

root@localhost:/home/ubuntu# snappy info release: ubuntu-core/devel frameworks: webdm apps: root@localhost:/home/ubuntu# snappy versions Traceback (most recent call last):

 File "/usr/bin/snappy", line 25, in <module>
   status = Main().__main__()
 File "/usr/lib/python3/dist-packages/snappy/main.py", line 195, in __main__
   return callback(args)
 File "/usr/lib/python3/dist-packages/snappy/main.py", line 334, in _do_versions
   click_versions = ClickDataSource().versions(all)
 File "/usr/lib/python3/dist-packages/snappy/click.py", line 189, in versions
   all_updates_list = repo.get_upgradable()
 File "/usr/lib/python3/dist-packages/click/repository.py", line 183, in get_upgradable
   headers={"content-type": "application/json"})
 File "/usr/lib/python3/dist-packages/click/network.py", line 70, in http_request
   curl.perform()

pycurl.error: (60, 'server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none')

Docker

Docker swarm

Databases

How to set up a Postgres database on a Raspberry Pi

Coding

https://code.org/

Scratch

THE SCRATCH OLYMPICS

Connect Arduino to Raspberry Pi

Connect to cell network

Connect Your Raspberry Pi to a Cell Network

openFrameworks (oF)

openFrameworks is an open source C++ toolkit designed to assist the creative process by providing a simple and intuitive framework for experimentation.

GPIO experiments

RPi.GPIO & gpiozero python libraries

https://www.raspberrypi.org/magpi-issues/Essentials_GPIOZero_v1.pdf#page=10

from RPi import GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(4, GPIO.IN, GPIO.PUD_UP)
while GPIO.input(4):
    pass
print("Button pushed!")

vs

from gpiozero import Button
btn = Button(4)
while not btn.is_pressed:
    pass
print("Button pushed!")

Processing

Shutdown/power off

Tested on pi 3b. For some reason, after I shut down the system, the power LED is still on and the board is still receiving power from the power supply.

  • On a Pi 3B, the red LED functions as a power supply monitor. If the Pi is being supplied with the correct voltage, the red LED will be on steadily. This is true, even if the Pi has been shutdown. Power LED on shutdown - Pi3,
  • The power LED on the Pi 3B+ is connected across 5V and 0V so lights up whenever power is supplied, whether through the micro-USB connector, GPIO or test points. The LED can however be shorted out and turned off by using the STATUS_LED_R control line. (solved) Disable red power led on 3B+
  • I click shutdown and red light stays on
  • Power usage:
    • Time-lapse script: 4 W
    • Idle: 2.6-3 W
    • Power off: 0.5 W

Power off and on

http://raspi.tv/2012/making-a-reset-switch-for-your-rev-2-raspberry-pi

When we use a diy wire to connect two holes, it will shutdown the RPi immediately. If we disconnect the 2 holes, it will power on the RPi again. I tested it on my Model B running the OpenElec OS. COOL:)

For model B+/Pi 2 model B, see this post. This post also provides another way (GPIO pins 5&6) to shut down RPi.

This has pictures for all raspi models.

How to Add a Power Button to Your Raspberry Pi, lynda.com.

Power from GPIO pins

Connect to console using TTL/Serial cable

I purchased the TTL cable through dealextream.com. The RaspPi is power by the microUSB (Or we can use the 5V pin on TTL module to connect to 5V on RaspPi. If I try to use 3.3V pin on TTL module to connect to either 3.3V or 5V on RaspPi, it does not work). The connection is done by

   RaspPi    TTL
   =========
   5V          5V
   GND       GND
   TX (14)   RX
   RX (15)   TX

Note that it takes 45 seconds for the screen to respond when I tested it using Putty. The ACT and PWR lights should be on. The tuturial on adafruit is helpful.

Ftdi2ttlRaspPi.png

C libraries

GPIO layout

Node-RED

lynda.com

WebIOPi

WebIOPi is a REST framework and a webapp which allows you to control Raspberry Pi's GPIO. It does not require apache to be installed. So we can use web browser from Android to control the GPIO in Raspbery Pi ... Another choice is Web.py.

Run Python using webiopi module

sudo python -m webiopi 8000

Start/stop the background service

sudo /etc/init.d/webiopi start
sudo /etc/init.d/webiopi end

Start webiopi at startup:

sudo update-rc.d webiopi defaults

Note that we shall browse to http://localhost:8000/ instead of http://localhost:8000/webiopi. If something is still wrong, use a different port. The default user is "webiopi" and password is "raspberry".

It seems the code is still not stable. I kept getting a message "Error response" Error code 404. Message: Not Found. Error code explanation: 404 = Nothing matches the given URI.

Web.py

See the article The Python Pit - drive your Raspberry Pi with a mobile phone in http://www.themagpi.com/en/issue/9.

Circuit and Electronics

Blink a single LED

I follow the instruction in https://projects.drogon.net/raspberry-pi/gpio-examples/tux-crossing/gpio-examples-1-a-single-led/ to install gpio program/library in raspberry pi. Here is the result

  • without PI cobbler: check out my video Raspberry Pi + single LED success.
  • with PI cobbler: see the picture below. The soldering part is not easy for a beginner. Be sure to follow some instruction on youtube videos to begin with. Note that the white stripe is on the edge closest to the SD card.
SingleLED.jpg
  • Another example by using C++ code. No extra library needs to be installed. http://hertaville.com/2012/11/18/introduction-to-accessing-the-raspberry-pis-gpio-in-c/. The site also shows the program to create the diagram is from http://www.fritzing.org.
  • Python approach. Here it is assumed pin 9 (or 6) is used for GND and pin 11 for GPIO17 (see the GPIO layout above). The LED was connected using a 330 ohm resistor in series with pin 9 (or 6) and 11 to limit the current. Note use “sudo” to run the python code.
    import RPi.GPIO as GPIO  
    import time  
    # blinking function  
    def blink(pin):  
            GPIO.output(pin,GPIO.HIGH)  
            time.sleep(1)  
            GPIO.output(pin,GPIO.LOW)  
            time.sleep(1)  
            return  
    # to use Raspberry Pi board pin numbers  
    GPIO.setmode(GPIO.BOARD)  
    # set up GPIO output channel  
    GPIO.setup(11, GPIO.OUT)  
    # blink GPIO17 50 times  
    for i in range(0,50):  
            blink(11)  
    GPIO.cleanup()
  • LED test by gpiozero library.
  • Google: raspberry pi python led

RGB

http://www.instructables.com/id/Using-a-RPi-to-Control-an-RGB-LED/?ALLSTEPS

16x2 LCD

http://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi. The '16x2' LCD means it can show 16 characters per row and there are 2 rows in total. Each character consists of 8x5 (height x width) dots.

RpyLCD.jpg

http://makezine.com/projects/build-a-compact-4-node-raspberry-pi-cluster/ also tells how to show the IP on the LCD.

8x8 Matrix LED Backpack (I2C)

http://learn.adafruit.com/matrix-7-segment-led-backpack-with-the-raspberry-pi/overview

MatrixLED.jpg

Another more versatile output from the 8x8 matrix is by using C program. See Mark Williams blog.

I also create a version of launching LED using R. See my youtube video. <youtube>TwoWrPp6_iw</youtube>

Weather Matrix Display

IR Remote with XBMC

http://learn.adafruit.com/using-an-ir-remote-with-a-raspberry-pi-media-center

Stepper motor

Sound sensor

Set up a sound sensor with the Raspberry Pi

I modify the code by

  1. adding a counter in the code for my own interest. See this post for declaring a variable as global.
  2. adding a timestamp to show when an event happened

Note I am connect OUT pin of the sensor to BCM26 on my pi zero.

If I install tmux on my pi zero, I can run the python code, disconnect ssh and connect to it again to see how many time a sound has been detected.

#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import datetime

#GPIO SETUP
channel = 26
GPIO.setmode(GPIO.BCM)
GPIO.setup(channel, GPIO.IN)
counter = 0

def callback(channel):
        global counter
        if GPIO.input(channel):
                counter += 1
                print("Sound Detected! {0} {1}".format(counter,datetime.datetime.now()))
        else:
                counter += 1
                print("Sound Detected! {0} {1}".format(counter,datetime.datetime.now()))

GPIO.add_event_detect(channel, GPIO.BOTH, bouncetime=300) 
GPIO.add_event_callback(channel, callback) 

# infinite loop
while True:
        time.sleep(1)

KOOKYE Smart Home Sensor Kit

CamJam Edukit 3 Robotics Kit

Ryanteck Budget Robotics Kit

https://www.indiegogo.com/projects/ryanteck-budget-robotics-kit-for-raspberry-pi

The software control is based on Spacebrew

HummingBird robot

http://www.hummingbirdkit.com/learning/tutorials/raspberry-pi

Add a push button

Speech synthesis and a push button

Festival speech package

sudo apt-get install festival
# Add voice file
sudo apt-get install festvox-rablpc16k # British English
sudo apt-get install festvox-kallpc16k # American English

Speaking

echo "Hello World!" | festival --tts

wget http://history.eserver.org/jefferson-inaugural.txt
festival --tts jefferson-inaugural.txt

Speak Easier: Flite

sudo apt-get install flite

flite -t "All good men come to the aid of the rebellion"
flite -f jefferson-inaugural.txt

flite -lv
flite -voice awb -t "The Raspberry Pi is a great Maker platform!"

Fun Uses for Speech

sudo apt-get install fortune-mod
fortune | flite

Wav output

flite -t "Shall we play a game?" -o wargames1.wav
aplay wargames1.wav

Reading the Weather

sudo apt-get install weather-util
weather washington
weather -q fips1600190345 | flite

Playing sounds using push buttons (Python).

Use a Simple Button to Control LED

http://raspi.tv/2013/rpi-gpio-basics-6-using-inputs-and-outputs-together-with-rpi-gpio-pull-ups-and-pull-downs

The following site has some elaboration about 'pull down' of resistors. http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/robot/buttons_and_switches/

Get a Flashing Meeting Reminder with a Raspberry Pi

http://makezine.com/projects/get-a-flashing-meeting-reminder-with-a-raspberry-pi/

Using a servo motor, PWM

LED dimming using software PWM (pulse-width modulation)

http://raspi.tv/2013/how-to-use-soft-pwm-in-rpi-gpio-pt-2-led-dimming-and-motor-speed-control

Reading analog input using external ADC (analog to digital converter) MCP3008

http://learn.adafruit.com/reading-a-analog-in-and-controlling-audio-volume-with-the-raspberry-pi/overview

Reading temperature

https://learn.adafruit.com/adafruits-raspberry-pi-lesson-11-ds18b20-temperature-sensing?view=all

Raspberry Pi has no ADC (Analog to Digital Converter), it cannot directly use an analog temperature sensor like the TMP36.

http://www.cyberciti.biz/faq/linux-find-out-raspberry-pi-gpu-and-arm-cpu-temperature-command/.

I got 74C on my RP3B CPU when it is idle (leave it outside 89F)! What is the maximum temperature a Raspberry Pi 3 can be exposed to? Bring RP3B indoor can reduce the temperature to 60C. I'm using pi-top OS based on Debian 11 bullseye.

# CPU
vcgencmd measure_temp
# OR
cpu=$(</sys/class/thermal/thermal_zone0/temp)
echo "$((cpu/1000)) c"

and putting them together

#!/bin/bash
# Script: my-pi-temp.sh
# Purpose: Display the ARM CPU and GPU  temperature of Raspberry Pi 2/3 
# Author: Vivek Gite <www.cyberciti.biz> under GPL v2.x+
# -------------------------------------------------------
cpu=$(</sys/class/thermal/thermal_zone0/temp)
echo "$(date) @ $(hostname)"
echo "-------------------------------------------"
echo "GPU => $(/opt/vc/bin/vcgencmd measure_temp)"
echo "CPU => $((cpu/1000))'C"

For my Raspberry Pi 3, the temperature is 52C when it is idle. The temperature can go up to 84C when I build R 3.3.1.

For Pi Zero W, the temperature is 59C when I build R.

How to Get a Discord or Slack Alert If Your Raspberry Pi Is Too Hot. Webhook.

MCP23017 GPIO expander (extra 16 pins)

Serial Peripheral interface (SPI)

MIDI port

Camera

# Still image 2592 x 1944
raspistill -vf -hf -o cam.jpg # -vf and -hf is to fix upside-down
gpicview cam.jpg # View the image

# Video 
raspivid -o myvid.h264 -t 60000   
# 60 seconds. Default is 6 seconds which generates 10MB for 1080p, 6.4MB for 720p.
# it will show a preview 'window'
raspivid -t 60000 --nopreview -o output.h264
raspivid -o myvid.h264 -t 60000 -vf -hf # fix upside-down
raspivid -o myvid.h264 -w 1280 -h 720   # 1280 x 720 instead of 1920 x 1080
raspivid -o myvid.h264 -w 1280 -h 720 -rot 180 # rotation 180 degree
raspivid -o myvid.h264 -w 1280 -h 720 -b 8000000  
# “8000000” is a bitrate of 8000Kbs (kilo bits per second) or 8Mb (8 mega bits per second). 
# The default is usually 17000000.

# One problem with h264 file is it does not contain the duration metadata.
# If we convert h264 to mp4, the mp4 file will contain the duration metdata

# convert h264 to mp4
sudo apt install ffmpeg
ffmpeg -framerate 30 -i input.h264 -c copy output.mp4
# OR
sudo apt-get install -y gpac
MP4Box -fps 30 -add myvid.h264 myvid.mp4

# play the video
omxplayer myvid.h264
Omxplayer —-win 0,0,800,640 myvid.h264
omxplayer myvid.mp4
sudo usermod -a -G motion pi
sudo chown motion:motion /home/pi/images
sudo service motion start

To rotate the image, change 'rotate 0' to 'rotate 180' by sudo nano /etc/motion.conf (still not right).

Detect camera

libcamera-hello --list-cameras

This should report a list of detected cameras and their operating modes. If it reports "No cameras available" or your camera is not listed then these instructions are for you. [https://forums.raspberrypi.com/viewtopic.php?t=362707 What to do if your camera is not detected].

New commands vs legacy camera

  • If I enable legacy camera support, then the new libcamera-hello command will not work. If I disable legacy camera, the new libcamera-hello works again.
  • Raspberry Pi Documentation about Raspberry Pi Cameras.
  • The `libcamera-still` and `libcamera-vid` commands were introduced as part of the `libcamera` framework, which came into the spotlight with the release of the Debian 11 (Bullseye) based Raspberry Pi OS. This new release replaced the familiar `raspistill` and `raspicam` camera commands with a new suite of open-source tools dedicated to getting the most from all of the official Raspberry Pi cameras¹. The exact release date is not specified, but it was sometime before November 14, 2021. As of February 7, 2023, the official `pycamera2` library has been provided for `libcamera`, making it easier for users to call Python demos.
  • Camera software from the official Raspberry Pi Documentation
    • Search "Pi 3" on the documentation.
    • On Raspberry Pi 3 and earlier devices running Bullseye you need to re-enable Glamor in order to make the X-Windows hardware accelerated preview window work. To do this enter sudo raspi-config at a terminal window and then choose Advanced Options, Glamor and Yes. Finally quit raspi-config and let it reboot your Raspberry Pi.
  • How To Use Raspberry Pi Cameras with Bullseye
  • Examples
    Still pictures
    libcamera-hello 
    libcamera-hello -t 0  # need to switch of terminal and Ctrl+c
    
    libcamera-still -o output.jpg
    
    libcamera-still -o output.jpg -t 5000 --width 1920 --height 1080
    
    libcamera-still -t 60000 --datetime -n --timelapse 2000 
    # take a picture every 2 seconds (-t means timeout/delay in milliseconds) and last for 60 seconds 
    # The format of the file will be MMDDhhmmss.jpg, where MM and DD are the month and date number, 
    #     and hh, mm and ss are hours, minutes and seconds.
    # taking a picture every second (--timelapse 1000) is difficult for the camera.
    
    # SSH
    nohup libcamera-still -o output.jpg  > /dev/null 2>&1 
    
    nohup libcamera-still -o output.jpg --width 1920 --height 1080 > /dev/null 2>&1
    
    nohup libcamera-still --width 1920 --height 1080 -t 10800000 --datetime -n --timelapse 30000 > /dev/null 2>&1 &
    # take a photo every 30 seconds, and last for 3 hours. So totally there are 360 photos.
    # If we convert them to a video with 24 fps, it will last for only 15 seconds.
    # it takes about 150MB. 
    
    nohup libcamera-still --width 1920 --height 1080 -t 10800000 --datetime -n --timelapse 5000 > /dev/null 2>&1 &
    # Every 5 seconds + 3 hours = 2160 pictures = 90 seconds if we consider 24 fps.
    
    nohup libcamera-still --width 1920 --height 1080 -t 7200000 --datetime -n --timelapse 5000 > /dev/null 2>&1 &
    # Every 5 seconds + 2 hours = 1440 pictures = 60 seconds if we consider 24 fps.
    
    tiv $(ls -t *.jpg | head -1)  # look at the picture through a terminal

    Videos

    libcamera-vid -t 10000 -o test.h264 # 640x480, 30 fps, 2.7MB for 10 seconds
                                        # default is -t 5000 (5 seconds)
    
    libcamera-vid --width 1920 --height 1080 -o full_hd.h264 -t 10000 # 30 fps, 7MB for 10 seconds
    
    libcamera-vid --width 1280 --height 720 --framerate 50 -o 50fps.h264

hardware/sensor

Connect camera module

  • Raspberry Pi, the blue part (non-metal) on the cable faces the ethernet port.
  • On camera module, the blue (non-metal) part is on the same side as the white plastic holder.
  • The above rule applies to Pi zero W too. That is, the non-metal part faces up and the metal part faces down.

How to connect Raspberry Pi camera module to Raspberry Pi Zero W and the official case

Just Enough Raspberry Pi. The book/site include pictures of different versions of Raspi with large size (cool!). For Raspi Zero W, it shows v1.1 whose camera connector is smaller than a regular Raspi. The camera cable included in pi zero case is a must (one side is regular size and the other side is smaller).

I also find my camera connector is broken when I try to tighten it. Just slide a piece of thick paper or cardboard will solve the problem; see here and Broken retaining clip on Camera Board.

Pi camera mount

PiCameraApp

PiCameraApp

Connect a USB camera

Use as a USB Webcam

Raspberry Pi Zero USB Webcam

Fisheye Cam

160° Fish Eye

Dash Cam

Time-lapse

  • Shell script 1: Taking pictures. This can create a one-minute video according to the script 2 below. To kill the processes, run pkill libcamera-still
    #!/bin/bash
    
    # Define the duration in minutes
    DURATION_MINUTES=180
    
    # Define the timelapse in seconds
    TIMELAPSE_SECONDS=30
    
    # Convert minutes to milliseconds
    DURATION=$((DURATION_MINUTES * 60 * 1000))
    
    # Convert seconds to milliseconds
    TIMELAPSE=$((TIMELAPSE_SECONDS * 1000))
    
    # Run the libcamera-still command with the converted duration and timelapse
    nohup libcamera-still --width 1920 --height 1080 -t $DURATION --datetime \
          -n --timelapse $TIMELAPSE > /dev/null 2>&1 &
  • Shell script 2: Overlay date and time. See also convert options.
    LOCATION=NorthEast
    for img in *.jpg; do
      convert "$img" -gravity $LOCATION -pointsize 24 -fill yellow \
              -annotate +10+10 "%[exif:DateTimeOriginal]" "$img"
    done
  • Shell script 3: Convert images into a video
    ffmpeg -framerate 24 -pattern_type glob -i "*.jpg" -c:v libx265 -crf 28 output.mp4 
    # OR fps=12 with a slightly larger file size
    ffmpeg -framerate 12 -pattern_type glob -i "*.jpg" -c:v libx265 -crf 28 output.mp4

    "-framerate 24" sets the framerate for the video. You can adjust this value as needed. "-vcodec libx265" sets the video codec to libx265, which is a more efficient codec for compression. "-crf 28" sets the Constant Rate Factor (CRF) to 28. The CRF is a quality-controlled variable bitrate, lower values would result in higher quality and larger files, higher values would result in lower quality and smaller files. See CRF Guide & H.264 Video Encoding Guide from ffmpeg website.

  • 5 Ways to Use the Raspberry Pi Camera Module for Time-Lapse Photography
  • How to Shoot Time-Lapse Videos with Raspberry Pi
  • Time-lapse animations with a Raspberry Pi. Every 60 seconds takes a picture.
    convert -delay 10 -loop 0 image*.jpg animation.gif   # very very slow, gif file 63MB

    -delay 10: This option sets the delay between frames in the GIF. The value is in hundredths of a second, so -delay 10 means each frame will be displayed for 0.1 seconds. -loop 0: This option sets how many times the animation will loop. A value of 0 means the animation will loop indefinitely.

  • Shell script (not python): Raspberry Pi Time-Lapse in Four Easy Steps, Raspberry Pi 5: Video Editing, Video Calling & Passive Cooling
  • How often to take pictures for time-lapse video. The interval between each shot in a time-lapse sequence, also known as the time-lapse interval, can vary greatly depending on the subject and the desired effect. Here are some general guidelines:
    • For scenes with minimal movement, such as a calm day with little wind and cloud movement, you might want to set an interval of one shot every 30 seconds.
    • For scenes with a lot of movement, you might want to set an interval of one shot every 5 seconds or less.
    • If you have a specific length for the final video in mind, you can calculate the interval. For example, if you want a 30-second video at 25 frames per second (fps), you’ll need 750 frames (30 seconds * 25 fps). If your shooting duration is 2 hours (7200 seconds), then your interval would be approximately 10 seconds (7200 seconds / 750 frames).

Remote viewing

A Remote Viewing Camera With Raspberry Pi

Create a button-operated camera

https://www.raspberrypi.org/magpi-issues/MagPi45.pdf p27

Streaming

Stream video over a network with rpicam-apps from official Raspberry Pi. The instruction is based on Raspberry Pi OS Bookworm where it renamed the camera capture applications from libcamera-* to rpicam-*.

  • UDP method (require the client IP). Prioritizes speed over reliability. It sends data without establishing a connection, resulting in lower latency but potential packet loss. Ideal for real-time applications like live streaming and gaming.
    libcamera-vid -t 0 --width 1920 --height 1080 --inline -o udp://Client-IP:8888

    I found VLC closed automatically for some reason. ffplay seems to be quite stable. Also the streaming does not use much of CPU.

    ffplay udp://Server-IP:8888 -fflags nobuffer -flags low_delay -framedrop
  • TCP method. Medium Latency. Suitable for applications where data accuracy is crucial.
  • RTSP method. Medium-High Latency.
    libcamera-vid -t 0 --inline -o - | cvlc stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/stream1}' :demux=h264

    On the client side (eg Android),

    vlc rtsp://Server-IP:8554/stream1
    

Live stream to youtube

RTSP and ZoneMinder

RPi Cam (Live stream and Cam Web Interface)

http://elinux.org/RPi-Cam-Web-Interface as used in portable streaming camera and it supports motion detection as seen on Web controlled Raspberry Pi Camera.

It also supports recording videos manually (MotionEye cannot).

The installation is quite simple and the basic installation just works (1/21/2017) with my Pi Camera v2. By default, I can access the live stream by visiting http://raspberrypi.local/html/. The web interface allows me to change camera settings (eg flip image), record video, record image, timelapse, etc. Quite amazing. The first screenshot shows one text dialog during installation and the 2nd screenshot shows the web interface. By default, the live stream will be auto-start. It can be installed on Raspbian-Lite too.

sudo apt-get update
sudo apt-get dist-upgrade

git clone https://github.com/silvanmelchior/RPi_Cam_Web_Interface.git
cd RPi_Cam_Web_Interface
chmod u+x *.sh
./install.sh

RPi Cam Web.png RPi Cam Web2.png

How to Use Raspberry Pi as a PC Webcam

How to Use Raspberry Pi as a PC Webcam

Security Camera: motion and motionEyeOS

See motionEye.

Intruder detection

http://www.instructables.com/id/Intruder-Detector-With-Raspberry-Pi-and-Pushbullet/

Raspberry Pi dog detector

Raspberry Pi dog detector

Chat Bot prevented a burglary

How a Chat Bot prevented a burglary

Pan and tilt security camera controlled by Arduino

http://www.makeuseof.com/tag/diy-pan-and-tilt-network-security-cam-raspberry-pi/

Slow motion

http://www.averagemanvsraspberrypi.com/2015/07/raspberry-pi-camera-module-slow-motion-video.html

Motion triggered infrared wildlife camera, night version camera

Solar powered nature camera

Baby monitor

SleePi sounds alarm when Raspberry Pi detects sleepiness

SleePi sounds alarm when Raspberry Pi detects sleepiness

Tiddlybot

Tiddlybot.jpg

The battery it includes is Nokia BL-5C 1020mAh 3.7V 3.8Wh ~ $5.35 US. Note that the battery has 3 pins. One of them labelled as T is for temperature.

To turn off the robot, switch the slider to the buzzer.

To run a small dhcp server, it uses udhcpd.

pi@raspberrypi ~ $ sudo service --status-all
 [ ? ]  alsa-utils
 [ - ]  bootlogs
 [ ? ]  bootmisc.sh
 [ ? ]  cgroup-bin
 [ ? ]  checkfs.sh
 [ ? ]  checkroot-bootclean.sh
 [ - ]  checkroot.sh
 [ - ]  console-setup
 [ + ]  cron
 [ + ]  dbus
 [ ? ]  dphys-swapfile
 [ ? ]  fake-hwclock
 [ + ]  hostapd
 [ - ]  hostname.sh
 [ ? ]  hwclock.sh
 [ + ]  ifplugd
 [ - ]  kbd
 [ - ]  keyboard-setup
 [ ? ]  killprocs
 [ ? ]  kmod
 [ - ]  lightdm
 [ - ]  motd
 [ ? ]  mountall-bootclean.sh
 [ ? ]  mountall.sh
 [ ? ]  mountdevsubfs.sh
 [ ? ]  mountkernfs.sh
 [ ? ]  mountnfs-bootclean.sh
 [ ? ]  mountnfs.sh
 [ ? ]  mtab.sh
 [ ? ]  networking
 [ - ]  nfs-common
 [ + ]  ntp
 [ ? ]  plymouth
 [ ? ]  plymouth-log
 [ - ]  procps
 [ ? ]  raspi-config
 [ ? ]  rc.local
 [ - ]  rmnologin
 [ - ]  rpcbind
 [ - ]  rsync
 [ + ]  rsyslog
 [ ? ]  screen-cleanup
 [ ? ]  sendsigs
 [ + ]  ssh
 [ - ]  sudo
 [ + ]  triggerhappy
 [ + ]  udev
 [ ? ]  udev-mtab
 [ ? ]  udhcpd
 [ ? ]  umountfs
 [ ? ]  umountnfs.sh
 [ ? ]  umountroot
 [ - ]  urandom
 [ - ]  x11-common

Bird feed

Raspberry Pi catches the early bird

View Stonehenge in real time via Raspberry Pi

View Stonehenge in real time via Raspberry Pi and the site.

Unlock your PC with a pushup or two (Machine learning)

Unlock your PC with a pushup or two

ESP8266

Connect an ESP8266 to your RaspberryPi

IFTTT

See Fridge monitor (p41-45) of TheMagPi September 2015.

Control a 12V lamp with GPIO ZERO

http://raspi.tv/2015/gpio-zero-test-drive-making-light-of-security

Grandpa scarer & Laser cutter

https://www.raspberrypi.org/learning/grandpa-scarer/worksheet/

Color sensing

https://www.raspberrypi.org/blog/colour-sensing-raspberry-pi/

Relay

Smart suitcase

http://www.instructables.com/id/How-to-Make-a-Smart-Suitcase-With-a-Raspberry-Pi/

Identify Bird Sounds With BirdNET-Pi

Identify Bird Sounds With BirdNET-Pi on Raspberry Pi

Other cool stuff

Hosting Without The Need to Port Forward, Tunnelling

See SSH > Awesome tunneling

Home Automation

Uses in office

11 Uses for a Raspberry Pi Around the Office. DNS Server, Toilet Occupied Sign, Honeypot Trap for Hackers, Print Server, Network Attached Storage, Ticketing Server, Digital Signage, Directories and Kiosks, Basic Intranet Web Server, Penetration Tester, VPN Server, and Wireless Coffee Machine.

Track Internet Dropouts

GPS tracker

http://blog.initialstate.com/new-python-gps-tracker/

Retro Game Console/Emulator

pygame

Three great games from GameMaker: Studio

https://www.raspberrypi.org/blog/three-great-gamemaker-games-raspberry-pi/

Raspberry Pi Based Wireless FM Microphone

http://www.instructables.com/id/Raspberry-Pi-Based-Wireless-Microphone/?ALLSTEPS

Dashboard/Kiosk by dashing.io

balenaCloud Dashboard

Build a Raspberry Pi Desktop Dashboard

Ashley’s top five projects for Raspberry Pi first-timers

https://www.raspberrypi.org/blog/ashleys-top-five-projects-for-raspberry-pi-first-timers/

5 Raspberry Pi Digital Signage Projects You Should Try

https://www.makeuseof.com/tag/raspberry-pi-digital-signage-projects/

6 Raspberry Pi tutorials to try out

https://opensource.com/article/20/3/raspberry-pi-tutorials

  • VPN server
  • Create an object-tracking camera
  • Photo slideshow
  • Retro game
  • Build a clock for your entertainment center

Go to space

OpenCV

Wii Remote, bluetooth

Wii balance board

WiiBalBoard.jpg

sudo apt-get install autoconf autogen automake gcc bluetooth libbluetooth3-dev \
          libgtk2.0-dev pkg-config python2.7-dev flex bison git-core \
          libbluetooth-dev python-pygame python-tk
          # NOTE: libbluetooth2-dev becomes libbluetooth3-dev now
          #       python2.5-dev becomes python2.7-dev now
sudo apt-get install bluez
                                                   # no need to create wiibalance directory
git clone https://github.com/abstrakraft/cwiid.git # the svn method does not work
                                                   # 131 commits. Last commit is Feb 21, 2010.
cd cwiid
aclocal
autoconf  # if something messed up, run 'autoreconf'

# Follow http://wiki.labomedia.org/index.php/Blender:Wiimote_:_Compilation_de_cwiid_sur_Linux_Mint_12
#   to fix an error "wmdemo undefined reference to symbol str2ba" when running 'make'
#   That is, edit wmdemo/Makefile.in line 11
#   LDLIBS += -lcwiid -lbluetooth
# make clean
sed -i 's/lcwiid/lcwiid -lbluetooth/g' wmdemo/Makefile.in
./configure        # no need of '--libdir=/usr/lib'
make
sudo make install

# Test Wii remote with GUI
sudo wmgui/wmgui

cd python
sudo python setup.py install
#  install the Wii balance board software:
git clone git://github.com/videntity/python-omhe.git
cd python-omhe
sudo python setup.py install

# Install pycurl; see https://www.raspberrypi.org/forums/viewtopic.php?f=32&t=103188
sudo apt-get install python-pycurl
sudo python ./omhe/hardware/wiibalance/wiibal-weighdemo.py     
# Strangely, the code is for bal board but the instruction is for Wiimote
# Just ignore this test and/or its result

wget http://abstrakraft.org/cwiid/raw-attachment/ticket/63/scalesgui.py
wget http://abstrakraft.org/cwiid/raw-attachment/ticket/63/system.ini
chmod a+x scalesgui.py
nano system.ini # On my 800x480 display, I change <system.ini> file
                # width=1200 -> 800, height=960 -> 420, size=300 -> 50
                # On Pi-top (1366 x 768), I use width = 1200, height = 650
nano scalesgui.py # change line 170 in order to change kg to pounds
                  # weight_sprite.weight = weight*2.20462
                  # change line 161 to use 'q' letter instead of 'F1' to quit the program
                  # if event.key == K_q:
sudo python ./scalesgui.py  # better to keep pressing the red sync button until ...
                            # <system.ini> and <scalesgui.py> are in the same dir
#  To exit the program you should press the “F12” key.
#  I change the code in scalesguy.py to use the 'q' key to quit the program.

Robot control

Compile R from source

Tested on R 3.0.1

  • cd R-3.0.1
  • ./configure --with-recommended-packages=no
  • sudo apt-get install openjdk-7-jdk
  • nano src/library/tools/R/install.R and pass "perl = TRUE" to sub()
SHLIB_EXT <- sub(".*= ", "", grep("^SHLIB_EXT", mconf, value = TRUE), perl = TRUE)
SHLIB_LIBADD <- sub(".*= ", "", grep("^SHLIB_LIBADD", mconf, value = TRUE), perl = TRUE)

to get rid of the error gcc: error: SHLIB_LIBADD: No such file or directory.

  • make

Temperature/Humidity Sensors for Data Analysis in R

Setting Up Raspberry Pi Temperature/Humidity Sensors for Data Analysis in R

Google Coder

PS. Code is based on node.js (Early version of shiny-server also depends on node.js).

http://pi.gadgetoid.com teaches us how to install Coder on a Raspberry Pi running on Raspbian. Note that Coder can turn Raspberry Pi into a web server. We can develop the code on a remote computer.

In fact, it is possible to run Code for Raspberry Pi on your own PC. Just run 7 lines of script at here. Note: My experience shows it is safe to use the version on Sep-17-2013; otherwise you'll get the following error when using 'nodejs server.js'

$ nodejs server.js
no certificate found. generating self signed cert.

module.js:337
    throw new Error("Cannot find module '" + request + "'");
          ^
Error: Cannot find module '/home/pi/coder/coder-base/apps/auth/app'

So the successful steps to install coder on Ubuntu is

  1. download zip file from Sep-17-2013 tree
  2. cd coder-base; npm install
  3. modify 'config.js'
  4. launch it by 'node server.js'.

I don't have to use sudo when I use 'npm install' and 'node server.js'.

The password requirement for coder is at least 6 characters, at least one lower case and at least 2 upper cases or numbers.

Also, on Ubuntu it will complain the user 'pi' does not exist. So we shall do this 'sudo adduser pi' too. Pick the same password as we use in coder (eg Raspberry99).

Update: After I played with it, I found Coder does not let us work on more than one HTML, CSS or Javscript file. This makes the development more difficult.

Another choice is to run Cloud9 IDE on RPi. The Cloud 9 IDE was preinstalled on Beaglebone black/

Wolframe Mathematica

For some reason, the Mathematica is not shown on the menu (it only happened on self-installed version). We can start Mathematica from the command line

/usr/bin/mathematica

We can try a 3D plot like seen in youtube

Plot3D[Sin[x*y], {x,0,Pi}, {y,0,Pi}]

The following screenshot shows how to calculate the derivative of f(x)=sin(x)*exp(2x) using Wolfram.

  • Note that the language is case-sensitive. For example, sin[x] is not recognized and it should be Sin[x].
  • Wolfram language uses square brackets instead of parentheses for function's arguments.
  • See this page for Wolfram language & system documentation.
  • Another way is to type D[Sin[x] * Exp[2x], x]

WolframPi.png

Note that Mathematica is a GUI program so it is kind of slow when it is running on Raspberry Pi. The Wolfram program is a command line interface program so it is much faster although we can not do any plotting there.

Use RaspPi as Media Center

http://www.packtpub.com/raspberry-pi-media-center/book

IN-FLIGHT entertainment system

https://youtu.be/QESAI93Uqyg

Record TV

Bitcoin Miner

How to Track Satellite (ISS) Fly-Bys with Raspberry Pi

How to Track Satellite Fly-Bys with Raspberry Pi

Wifi extender

# 1. Update
sudo apt update; sudo apt upgrade

# 2. Install software
sudo apt install dnsmasq hostapd

# 3. Setup wlan0 (if this has been done before, go to step 5)
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

# 4. Create an entry of 
network={
  ssid=" "  
  psk=" " 
}

# 5. Setup dhcpcd
sudo nano /etc/dhcpcd.conf

# 6. Add lines 
interface wlan1
static ip_address=192.168.220.1/24
static routers=192.168.220.0

# 7. Restart dhcpd service
sudo service dhcpcd restart

# 8. Adjust hostapd configuration
sudo nano /etc/hostapd/hostapd.conf

# 9. Adjust the ssid=, wpa_passphrase= and 
#    driver= line to the best driver for your device,
interface=wlan1
driver=nl80211

hw_mode=g
channel=6
ieee80211n=1
wmm_enabled=1
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
macaddr_acl=0
ignore_broadcast_ssid=0

auth_algs=1
wpa=2
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP

ssid=Pi3-Extender
wpa_passphrase=raspberry

# 10. 
sudo nano /etc/default/hostapd

# 11. 
Replace the line
#DAEMON_CONF=""
with 
DAEMON_CONF="/etc/hostapd/hostapd.conf"

# 12. 
sudo nano /etc/init.d/hostapd

# 13.
Replace the line 
#DAEMON_CONF=
with 
DAEMON_CONF=/etc/hostapd/hostapd.conf

# 14. setting up dnsmasq
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig

# 15. 
sudo nano /etc/dnsmasq.conf

# 16. add the following lines
interface=wlan1       # Use interface wlan1  
listen-address=192.168.220.1   # Specify the address to listen on  
bind-interfaces      # Bind to the interface
server=8.8.8.8       # Use Google DNS  
domain-needed        # Don't forward short names  
bogus-priv           # Drop the non-routed address spaces.  
dhcp-range=192.168.220.50,192.168.220.150,12h # IP range and lease time

# 17. forward all traffic from our wlan1 connection over to our wlan0 connection
sudo nano /etc/sysctl.conf

# 18. 
Replace the line
#net.ipv4.ip_forward=1
with
net.ipv4.ip_forward=1

# 19. 
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

# 20. configure a NAT between our wlan0 interface and our wlan1 interface. 
sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE  
sudo iptables -A FORWARD -i wlan0 -o wlan1 -m state --state RELATED,ESTABLISHED -j ACCEPT  
sudo iptables -A FORWARD -i wlan1 -o wlan0 -j ACCEPT

# 21.
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

# 22.
sudo nano /etc/rc.local

# 23.
Find the line
exit 0
Add ABOVE:
iptables-restore < /etc/iptables.ipv4.nat

# 24.  start the two services and enable them in systemctl.
sudo systemctl unmask hostapd
sudo systemctl enable hostapd
sudo service hostapd start
sudo service dnsmasq start

# 25. sudo nano /etc/network/interfaces 
allow-hotplug wlan0
iface wlan0 inet dhcp
# wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
allow-hotplug wlan1

# 26. sudo reboot

I can see the SSID. But I cannot connect to that.

sudo systemctl status hostapd
sudo systemctl status dnsmasq

Converting Any USB Device to A Wireless USB

Converting Any USB Device to A Wireless USB using Raspberry Pi Zero. VirtualHere $49.

Raspberry Pi Wifi Ethernet Bridge

DIY Raspberry Pi Wifi Ethernet Bridge (2/26/2023). Raspberry pi connected to internet through wifi. Another device (or a hub if we want to connect multiple devices) connects to Raspberry Pi by an ethernet cable and gets internet through Pi's wifi.

Share internet

  • Turn your Raspberry Pi into a WiFi Router using OpenWrt. It works and quite stable.
    • Very small (16MB). I've downloaded 64-bit version (22.03-5).
    • I connect RPI to a display/monitor for a quick setup which is necessary before we can use OpenWRT.
    • No need to use web interface.
    • I got a speed of 28Mb/s at best using RPI 3b.
cd /etc/config
vi network
vi wireless
reboot network /etc/init.d/network restart
  • Wireless Bridge
    • The main use cases for wireless bridges are:
      • Extending a wired network wirelessly to an area without cables
      • Connecting two wired networks in different buildings wirelessly instead of pulling cables
      • Connecting a wired network to a wireless one and vice versa
    • How to Turn an Old Router Into a Wireless Bridge. A wireless bridge is a connection type where you join two or more local area networks (LAN) wirelessly. By combining two networks together through a wireless bridge, you essentially make one larger network where all devices are connected and have access to the internet. This allows devices on the two previously separated networks to communicate with each other as if they were on the same local network.

Turn Raspi into a wireless hotspot / access point

(2023/8/2) Going Camping? Jellyfin on Raspberry Pi Is the Perfect Offline Media Server

(2022/9/12) How to Turn a Raspberry Pi Into a Wi-Fi Access Point by using Network Manager (instead of using dhcpcd file) from the latest Raspberry Pi OS update.

I am using TP-LINK TP-WN722N wifi adapter.

Midi keyboard

Bike computer

https://www.raspberrypi.org/blog/bike-computer-for-the-myopic/ This build uses the Kindle as a display

OctoPrint

The snappy web interface for your 3D printer.

Connect your printer to a small embedded and WiFi enabled device such as the popular Raspberry Pi, install OctoPrint on it and you have an instant wireless printer.

Orange Pi

Mozilla Project Things

https://iot.mozilla.org/

E-ink

E-ink

Magic mirror

How to measure particulate matter

Designing a Raspberry Pi Based Intelligent Ultrasonic Bat Detector App

Designing a Raspberry Pi Based Intelligent Ultrasonic Bat Detector App

Calculate pi

  • See this tweet
    > pi
    [1] 3.141593
    
    > k <- seq(0, 10^7)
    > 4 * sum((-1)^k / (2*k + 1))
    [1] 3.141593
    
    > k <- seq(1, 10^7)
    > sqrt(6 * sum(1 / k^2))
    [1] 3.141593
    
    > f <- function(n) if(n) sqrt(1/2 + 1/2*f(n-1)) else sqrt(1/2)
    > 2 / prod(sapply(0:11, f))
    [1] 3.141593
    
  • Estimating pi with Monte Carlo simulation

8086

Raspberry Pi HAT Brings 1984 CPU to 2022

Alternatives

DietPi

DietPi is an extremely lightweight Debian-based OS.

  • https://github.com/MichaIng/DietPi
  • Comparison
  • Complete Guide
  • Password explaination
  • Installation
    • Change global software password for DietPi-software installs. The password will be encrypted and saved to /var/lib/dietpi/dietpi-software/.GLOBAL_PW.bin to be used by DietPi-Software as initial password for e.g. web application and frontend logins. This does not affect any previously installed software, just new installs. We especially recommend to change it, if you did not change it in "dietpi.txt" yet. NB: we highly recommend to apply individual passwords for each software title after first login. Would you like to change the global software password now? OK/Cancel.
    • Change login password for "root" and "diepi" users? DietPi has two accounts by default: "root" and "dietpi". On first boot, both share the password "dietpi", respectively the one set in "dietpi.txt". It is highly recommended to change this password, ideally, it should be different than the global software password. Would you like to change the login password for "root" and "dietpi" now? OK/Cancel. It seems this does affect the (same) password for root & dietpip.
    • A serial/UART console .... would you like to disable it? Yes/No.
  • Memory is 20.9/477M according to htop (on my RPi 1B, armv6)
  • Default username/password is root/dietpi
  • Dropbear was used instead of openssh by default
  • After a login, it will remind some useful commands
    • dietpi-launcher (can run 'dietpi-config' and 'dietpi-software').
      • DietPi-Drive_Manager: control multiple external drives (eg Samba drives)
      • DietPi-AutoStart
      • DietPi-Services
      • DietPi-Cron: Mailto/cron.minutely/cron.hourly/cron.daily/cron.weekly/cron.monthly
      • DietPi-Backup
      • DietPi-Cleaner
      • DietPi-Sync
      • DietPi-VPN: setup a VPN connection: NordVPN/ProtonVPN/IPVanish/PIA/Custom (need .ovpn file)
      • DietPi-DDNS: DuckDNS/NO-IP/Dynu/FreeDNS/OVH/YDNS/Custom (need Domains & token)
    • dietpi-config (similar to raspi-config)
    • dietpi-software: lots of software we can easily install and they are categorized.
      • Desktops: LXDE, MATE, Xfce, LXQt
      • Remote desktop: TigerVNC Server, XRDP, NoMachine, RealVNC Server
      • Media systems: Kodi
      • BitTorrent & download: youtube-dl
      • Cloud & Backup: Syncthing, nextcloud, vaultwarden, File Browser, Rclone
      • Gaming & Emulation: Amiberry
      • Social & Search: mediawiki
      • Camera & Surveillance: RPi Cam Web Interface, motionEye, mjpg-streamer
      • System Stats & management: LinuxDash, phpSysInfo, Netdata, RPi-Monitor, Docker, DietPi-Dashboard, Homer
      • Remote Access
      • Hardware projects
      • System security
      • Webserver stacks
      • DNS servers
      • File servers (ProFTPD, Samba, NFS)
      • VPN servers (tailscale, PiVPN, Wireguard, ZeroTier)
      • Advaced networking (wifi hotspot, tor)
      • Home automation
      • Printing
      • SSH clients (openssh)
      • File server clients (samba client, NFS client)
      • File managers (MC, ViFM)
      • System (Alsa, X.org, FFmpeg, UnRAR)
      • Databases (phpMyAdmin, ...)
      • Network tools (Iperf, iftop, avahi-daemon, ...)
      • Development & programming (git, node.js, python3, vscodium)
      • Text editors (emacs, vim, neovim)
      • Desktop utilities (QuiteRSS, GIMP, xfce power manager)
    • htop: Very few processes are running (~10)
    • cpu
  • It is better to install one software at a time in order to gain more information about a new software. For example when it is installing filebrowser, it shows a new directory "/mnt/dietpi_userdata/filebrowser" was created and the OS user "dietpi" & its credential can be used to log in. The program was installed in /opt/filebrowser. The web URL is http://IP:8084. sudo ss -tulpn | grep LISTEN can be used to find open ports.
  • tailscale can be installed

other SBC