Raspberry pi Tips and Tricks

04 Jun 2019

If you ever worked with raspberry pi, you know how many times you need google around to find a particular sulution. From enabling ssh first time to enabling uart speed, you need to google around and find the soulution that really works. This is a list of frequent things you may need to configure in raspberry pi. This assumes you are running Raspbian Stretch with desktop.

Enable ssh

create an empty file in /boot/ssh

Connect to WiFi on boot

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB



network={
        ssid="insert_your_hidden_SSID_here"
        scan_ssid=1
        psk="insert_your_wifi_password_here"
        key_mgmt=WPA-PSK
}

Disable rainbow screen

sudo nano /boot/config.txt

disable_splash=1

Disable boot logs

sudo nano /boot/cmdline.txt

Change the console from tty1 to

console=tty3 

Add this to the end of the line. 'loglevel=0' removes most of the messages from the boot. You can also use 'loglevel=3', but some boot messages may re-appear.

quiet splash loglevel=0 logo.nologo vt.global_cursor_default=0

If you are going to use Plymouth add this:

plymouth.ignore-serial-consoles 

Change boot animation

Change raspbian plymouth theme

cd /usr/share/plymouth/themes/

Clone this repository.

sudo git clone https://github.com/krishnan793/PlymouthTheme-TheRun.git

Install the theme.

sudo update-alternatives --install /usr/share/plymouth/themes/default.plymouth default.plymouth /usr/share/plymouth/themes/PlymouthTheme-TheRun/PlymouthTheme-TheRun.plymouth 100

Select the default theme.

sudo update-alternatives --config default.plymouth

Update the initramfs image.

sudo update-initramfs -u

sudo nano /etc/plymouth/plymouthd.conf

Theme=pix to

Theme=PlymouthTheme-TheRun

Waveshare 7 inch display

sudo nano /boot/config.txt

hdmi_force_hotplug=1
config_hdmi_boost=0
overscan_left=0
overscan_right=0
overscan_top=0
overscan_bottom=0
disable_overscan=0
hdmi_cvt=1024 600 60 6 ##
framebuffer_width=1024 ##
framebuffer_height=600 ##
hdmi_group=2
hdmi_mode=1
hdmi_mode=87

Rotate display

sudo nano /boot/config.txt

lcd_rotate=2 

or

display_rotate=0 
  • display_rotate=0 Normal
  • display_rotate=1 90 degrees
  • display_rotate=2 180 degrees

Set display brightness

sudo echo 50 > /sys/class/backlight/rpi_backlight/brightness

To make it persistent add the above statement in /etc/rc.local (before exit 0)

Switch off display

sudo echo 1 > /sys/class/backlight/rpi_backlight/b1_power

Switch on display

sudo echo 0 > /sys/class/backlight/rpi_backlight/b1_power

To remove low power indication (lightning icon)

sudo nano /boot/config.txt

avoid_warnings=1

Hide cursor

sudo nano /etc/lightdm/lightdm.conf

[Seat:*]
xserver-command=X -nocursor 

Start app in fullscreen with desktop on boot

Make sure you enable auto login using sudo raspi-config

sudo nano /etc/xdg/autostart/smart_room.desktop

[Desktop Entry]
Type=Application
Name=smart_room
Comment=Kivy RPI Infoscreen
NoDisplay=false
Exec=chromium-browser http://192.168.1.5/src/home.html --start-fullscreen
NotShowIn=GNOME;KDE;XFCE;

Start app in fullscreen without desktop on boot

Make sure you enable auto login using sudo raspi-config

sudo nano /etc/lightdm/lightdm.conf

[Seat:*]
user-session=myxclient

sudo nano /usr/share/xsessions/myxclient.desktop

[Desktop Entry]
Type=Application
Name=smart_room
Comment=Kivy RPI Infoscreen
NoDisplay=false
Exec=/home/pi/start.sh
NotShowIn=GNOME;KDE;XFCE;

sudo nano /home/pi/start.sh

#!/bin/bash
/usr/bin/chromium-browser --kiosk --app=https://www.google.com --start-fullscreen --window-size=1024,600 --window-position=0,0

UART

The SoCs used on the Raspberry Pis have two built-in UARTs, a PL011 and a mini UART. both are 3.3V devices. By default, on Raspberry Pis equipped with the wireless/Bluetooth module (Raspberry Pi 3 and Raspberry Pi Zero W), the PL011 UART is connected to the Bluetooth module, while the mini UART is used as the primary UART and will have a Linux console on it. On all other models, the PL011 is used as the primary UART.

For pi3 & zero

  • /dev/ttyS0 (mini UART) primary UART symlink to /dev/serial0
  • /dev/ttyAMA0 (PL011) bluetooth module symlink to /dev/serial1

The baud rate of the mini UART is linked to the core frequency of the VPU (VideoCore processor) on the VC4 GPU.

Steps to enable mini UART

  1. add enable_uart=1 in /boot/config.txt
  2. remove console=serial0 from /boot/cmdline.txt

default baud rate is: 115200




Comments