Showing posts with label Raspberry Pi OS.how to. Show all posts
Showing posts with label Raspberry Pi OS.how to. Show all posts

Saturday, July 16, 2022

Fixed: Raspberry Pi OS cannot find 5G Hz WiFi Network

Recently, when I tried 64 bit Raspberry Pi OS (Bullseye) on Raspberry Pi 4B/4G, it's found 5G Hz WiFi Networks cannot be discovered, and connected.

To fix it, I set set WiFi Country to US.


MENU > Preferences > Raspberry Pi Configuration
> select Localisation tab
> Set WiFi Country...
> Select US United States


remark:
I have another Raspberry Pi 4B/8G running 32 bit Raspberry Pi OS (Buster), no this problem.


Thursday, July 14, 2022

Enable Boot from USB for Raspberry Pi 4/400

Raspberry Pi 4, 400 and Compute Module 4 computers use an EEPROM to boot the system. If you want to boot your Raspberry Pi 4/400, the bootloader have to be updated.


Steps in my practice:

Update system using apt

$ sudo apt update
$ sudo apt full-upgrade


Run raspi-config in command line (not GUI version)

$ sudo raspi-config
> Select Advanced Options
> Select Bootloader Version
> Select Latest for the latest stable bootloader release.
> Reboot


reference: https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#raspberry-pi-4-boot-eeprom

rematk:

In my own case, I have two Raspberry Pi 4, tried to run Raspberry Pi OS 64 bit bullseys from Kingston A400 SSD 120GB SATA attached with Orico HDD Adapter Kit USB3.0.

case 1 - Raspberry Pi 4B/4G running 64 bit Raspberry Pi OS 11 (bullseye): no need doing anything, it boot from USB SSD automatically after reboot with original Micro SD removed.

case 2 - Raspberry Pi 4B/8G running 32 bit Raspberry Pi OS 10 (Buster): apt update/full-upgrade, and reboot cannot solve. Have to run raspi-config to select Bootloader Version (Latest I selected).



May be you will interested:
Install and run 64-bit Ubuntu MATE 22.04 LTS on Raspberry Pi 4


Wednesday, July 13, 2022

Raspberry Pi run on ssd via USB

Just install Raspberry Pi 0S 64-bit (bullseye), run o Raspberry Pi 4B/4G Rev 1.2.



Tested with Raspberry Pi Diagnostic SD Card Speed Test.

- The ssd used is Kingston A400 SSD 120GB SATA.
- The adapter is Orico HDD Adapter Kit USB3.0.




Log, rpdiags.txt.
Raspberry Pi Diagnostics - version 0.10
Wed Jul 13 14:40:42 2022

Test : SD Card Speed Test
Run 1
prepare-file;0;0;213472;416
seq-write;0;0;174762;341
rand-4k-write;0;0;22351;5587
rand-4k-read;16478;4119;0;0
Sequential write speed 174762 KB/sec (target 10000) - PASS
Random write speed 5587 IOPS (target 500) - PASS
Random read speed 4119 IOPS (target 1500) - PASS
Test PASS



Compare with the original MicroSD I used, Samsung EVO Plus 128G


Raspberry Pi Diagnostics - version 0.10
Wed Jul 13 17:33:10 2022

Test : SD Card Speed Test
Run 1
prepare-file;0;0;13742;26
seq-write;0;0;32621;63
rand-4k-write;0;0;3040;760
rand-4k-read;13407;3351;0;0
Sequential write speed 32621 KB/sec (target 10000) - PASS
Random write speed 760 IOPS (target 500) - PASS
Random read speed 3351 IOPS (target 1500) - PASS
Test PASS





Update firmware to enable Boot from USB

Make sure to update latest firmware and enable Boot from USB, read Enable Boot from USB for Raspberry Pi 4/400.




Saturday, February 5, 2022

How to check running Raspberry Pi OS version, 32 bit or 64 bit.

To check the bit size (32 bit or 64 bit) of the running Raspberry Pi OS, you can enter the commands:

$ uname -m
aarch64

or:

$ arch
aarch64

You can also check the bit size of the Linux kernel with:

$ getconf LONG_BIT
64

Tested on Raspberry Pi 4B running Raspberry Pi OS 64-bit (bullseye):

Tested on Raspberry Pi 4B running Raspberry Pi OS 32-bit (buster):



Thursday, July 15, 2021

Install PyQt5 for Python3 on Raspberry Pi OS

 To install PyQt5 on Raspberry Pi OS, for Python3, enter the command:

$ sudo apt install python3-pyqt5

Currently, it's 5.11.3.



Raspberry Pi: change screen orientation

To rotate screen in Raspberry Pi OS:

Click on MENU -> Preferences -> Screen Configuration
RIGHT Click on the monitor > Orientation -> Select direction


Tested on 4 inch HDMI IPS Touch Display. Without installing custom driver, the screen will be in vertical (portrait).

Tuesday, July 13, 2021

Install bluepy on Raspberry Pi, for Python3, and examples.

bluepy is a Python interface to Bluetooth LE on Linux.

To install bluepy on Raspberry Pi for Python3, enter the command:

$ sudo apt-get install python3-pip libglib2.0-dev
$ sudo pip3 install bluepy


ref:


bluepy examples:

There are two examples in bluepy, scanner and notification. Here how I modify it for Python3 working on Raspberry Pi, work with ESP32 BLE_uart example.


scanner.py
from bluepy.btle import Scanner, DefaultDelegate

class ScanDelegate(DefaultDelegate):
    def __init__(self):
        DefaultDelegate.__init__(self)

    def handleDiscovery(self, dev, isNewDev, isNewData):
        if isNewDev:
            print("Discovered device", dev.addr)
        elif isNewData:
            print("Received new data from", dev.addr)

scanner = Scanner().withDelegate(ScanDelegate())
devices = scanner.scan(10.0)

for dev in devices:
    print("Device %s (%s), RSSI=%d dB" % (dev.addr, dev.addrType, dev.rssi))
    for (adtype, desc, value) in dev.getScanData():
        print("  %s = %s" % (desc, value))

notification.py
from bluepy import btle

class MyDelegate(btle.DefaultDelegate):
    def __init__(self):
        btle.DefaultDelegate.__init__(self)
        # ... initialise here

    def handleNotification(self, cHandle, data):
        print("\n- handleNotification -\n")
        print(data)
        # ... perhaps check cHandle
        # ... process 'data'


# Initialisation  -------

p = btle.Peripheral("3c:71:bf:0d:dd:6a")
p.setDelegate( MyDelegate() )

# Setup to turn notifications on, e.g.
svc = p.getServiceByUUID("6E400001-B5A3-F393-E0A9-E50E24DCCA9E")
ch = svc.getCharacteristics("6E400003-B5A3-F393-E0A9-E50E24DCCA9E")[0]
#   ch.write( setup_data )

setup_data = b"\x01\00"
p.writeCharacteristic(ch.valHandle+1, setup_data)

# Main loop --------

while True:
    if p.waitForNotifications(1.0):
        # handleNotification() was called
        continue

    print("Waiting...")
    # Perhaps do something else here


Next:

Wednesday, March 24, 2021

Install Visual Studio Code on Raspberry Pi, with apt command.

Visual Studio Code was added to the Raspberry Pi OS APT repository, in both 32-bit and 64-bit variants. Now you can install code with apt command:

$ sudo apt update
$ sudo apt install code



ref:

Friday, March 19, 2021

Install and run rpi-imager (Raspberry Pi Imager) on Raspberry Pi

Raspberry Pi Imager update to v1.6.

To install Raspberry Pi Imager on Raspberry Pi (running Raspberry Pi OS 32-bit), enter the command in Terminal:

$ sudo apt install rpi-imager




Once installed, run it in Start Menu > Accessories > Imager




In my first test, it fail when run remotely using xrdp/Remote Desktop.


but work normally on host locally.





Monday, February 22, 2021

Install MicroPython on ESP32 using Thonny Python IDE, on Raspberry Pi.

Steps to install MicroPython firmware on ESP32 (ESP32-DevKitC V4, with ESP32-WROVER-E) using Thonny Python IDE, on Raspberry Pi/Raspberry Pi OS(32-bit). Include install esptool plug-ins.

Visit http://micropython.org/download/, scroll down to select Generic ESP32 module.
Download firmware (.bin) using either ESP-IDF v3.x or v4.x.

There are various daily firmware for ESP32-based boards, with separate firmware for boards with and without external SPIRAM, using either ESP-IDF v3.x or v4.x.

Non-SPIRAM firmware will work on any board, whereas SPIRAM enabled firmware will only work on boards with 4MiB of external pSRAM.

And currently,
Firmware built with ESP-IDF v4.x, with support for BLE and PPP, but no LAN.
Firmware built with ESP-IDF v3.x, with support for BLE, LAN and PPP. MicroPython v1.14 was the last version to support ESP-IDF v3.x.

If in doubt use v4.x.

Run Thonny

Run in Raspberry Pi OS Start Menu:
> programming > Thonny Python IDE

Install esptool plus-ins:

In Thonny menu:
> Tools > Manager plug-ins...
Search and install esptool

Install MicroPython firmware:

In Thonny menu:
> Run > Select Interpreter...

Select MicroPython (ESP32) from the interpreter or device drop-down box.
Click Install or Update firmware.

Select the USB port connected to ESP32.
Browse to load firmware.
Click Install.

Once Done, MicroPython installed on ESP32.

Example:

upyESP32_scan.py, example to scan available WiFi networks.
import uos
import network

print("----- MicroPython -----")
for u in uos.uname():
    print(u)
print("-----------------------")

sta_if = network.WLAN(network.STA_IF)
print(sta_if)
sta_if.active(True)
for ap in sta_if.scan():
    print(ap)

upyESP32_connect.py, example to connect WiFi network.
import uos
import network

print("----- MicroPython -----")
for u in uos.uname():
    print(u)
print("-----------------------")

def do_connect():
    sta_if = network.WLAN(network.STA_IF)
    if not sta_if.isconnected():
        print('connecting to network...')
        sta_if.active(True)
        sta_if.connect('ssid', 'password')
        while not sta_if.isconnected():
            pass
    print('network config:', sta_if.ifconfig())
    
do_connect()


Next:

Tuesday, January 26, 2021

First Power up Raspberry Pi Pico and install MicroPython firmware, on Raspberry Pi.



It's the first time I plug-in the new Raspberry Pi Pico to Raspberry Pi 4B/4G, install MicroPython firmware on Raspberry Pi Pico using Thonny Python IDE, and play around MicroPython REPL.


Play around in with MicroPython REPL:
To get information:
>>> import uos
>>> uos.uname()

Get CPU frequency in hertz:
>>> import machine
>>> machine.freq()

Get memory info:
>>> import micropython
>>> micropython.mem_info()
Remark to enter boot mode:

In boot mode, the Pico will be recognized as a removable driver named "RPI-RP2". And you can install MicroPython firmware in Thonny (as shown in the video). You can also manually download firmware .uf2 and drag to "RPI-RP2", refer to "Flash the MicroPython firmware" section on MagPi - Programming Raspberry Pi Pico with Python and MicroPython.

In my first power-up of Raspberry Pi Pico, it enter boot mode automatically, no need to press and hold the on board BOOTSEL while powering up, as shown in the video. Once installed, Pico will not enter boot mode automatically. 

To enter boot mode again:
- Disconnect USB cable to Raspberry Pi Pico.
- Press and hold the onboard BOOTSEL button.
- Connect USB cable to Raspberry Pi Pico.
- Pico will be recognized as a removable driver named "RPI-RP2".


Useful Tips: 

More exercise for Raspberry Pi Pico
MicroPython:
Install/Update MicroPython firmware to Raspberry Pi Pico using Thonny Python IDE
CircuitPython:

Arduino Framework:

Friday, January 1, 2021

Raspberry Pi stream camera video using raspivid in rtsp protocol, view in Android using VLC app.

Work on Raspberry Pi 4B/8G running Raspberry Pi OS (32 bit), stream video from Camera Module to port 8000 in rtsp protocol, enter the command:

$ raspivid -o - -t 0 -n -w 800 -h 600 -fps 30| cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8000/}' :demux=h264

where:
-w 800 : width=800
-h 600 : height=600
-fps 30 : 30 frame per second
8000 : the port to stream video

Open VLC App, Open Network Stream
rtsp://<Raspberry Pi IP>:8000/
e.g. rtsp://192.168.1.30:8000/

Wednesday, December 9, 2020

Install GIMP on Raspberry Pi OS

GIMP is a cross-platform image editor available for GNU/Linux, OS X, Windows and more operating systems.

To install GIMP on Raspberry Pi OS, simple enter the command in Terminal:

$ sudo apt-get install gimp


After installed, it's listed in System MENU > Graphics > GNU Image Manipulation Program




Display system info with neofetch

neofetch is a Terminal-based tools to displays information about your operating system, software and hardware in visual way.

To install neofetch to Raspberry Pi OS, enter the command:

$ sudo apt install neofetch



Tuesday, December 8, 2020

Raspberry Pi OS now support FAN control

With Raspberry Pi OS released December 2020, fan control is itroduced.


In Raspberry Pi Configuration, select Performance tab, there is a option of FAN. you can select the GPIO pin to which it is connected and set the temperature at which it turns on and off.  To control the new Raspberry Pi Case Fan.



Friday, December 4, 2020

Test network speed between Raspberry Pi using iPerf3

iPerf3 is a tool for active measurements of the maximum achievable bandwidth on IP networks. It supports tuning of various parameters related to timing, buffers and protocols (TCP, UDP, SCTP with IPv4 and IPv6). For each test it reports the bandwidth, loss, and other parameters.

This post show how to run iPerf3 on two Raspberry Pi to check the network speed between.

On both Raspberry Pi, install iPerf3 by entering command in Terminal:

$ sudo apt install iperf3
After installed.

In the service side, enter the command:
$ iperf3 -s
In the client side, enter command:
$ iperf3 -c <server ip>




Thursday, December 3, 2020

Raspberry Pi link to Bluetooth 5.0 headphones, using Blueman

Blueman is a lightweight, easy to use, Python based, and GPL licensed, GTK+ Bluetooth Manager.

Blueman is designed to provide a simple yet effective means for controlling the BlueZ API and simplifying Bluetooth tasks, such as:

  • Connecting to 3G/EDGE/GPRS via dial-up
  • Connecting to / Creating Bluetooth networks
  • Connecting to input devices
  • Connecting to audio devices
  • Sending / Receiving files via OBEX
  • Pairing

To install Blueman on Raspberry Pi/Raspberry Pi OS, enter the command in Terminal:

$ sudo apt install bluetooth pi-bluetooth bluez blueman

After installed, reboot.

$ sudo reboot

After reboot, it's a shortcut on menu bar, and on MENU > Preferences > Bluetooth Manager.


This video show how to pair Bluetooth 5.0 headphones to Raspberry Pi/Raspberry Pi OS (32 bit) using Blueman. The devices tested are JBL TUNE 215BT + Raspberry Pi 4B/4 inch HDMI IPS Touch Display.



Tuesday, December 1, 2020

Check installed package in Raspberry Pi OS, using dpkg/dpkg-query

To list all installed packages, enter the command in Terminal:

$ dpkg -l

or

$ dpkg-query -l

To list about a specified package:

$ dpkg -l package-name-pattern

or

$ dpkg-query -l package-name-pattern



dpkg is a tool to install, build, remove and manage Debian packages. It can also be used as a front-end to dpkg-deb and dpkg-query. 

dpkg-query is a tool to show information about packages listed in the dpkg database.

With command "-l [package-name-pattern...]" list all known packages matching one or more patterns. If no package-name-pattern is given, list all packages in /usr/local/var/lib/dpkg/status, excluding the ones marked as not-installed (i.e.  those which have been previously purged).

The first three columns of the output show the desired action, the package status, and errors, in that order.

              Desired action:
                u = Unknown
                i = Install
                h = Hold
                r = Remove
                p = Purge

              Package status:
                n = Not-installed
                c = Config-files
                H = Half-installed
                U = Unpacked
                F = Half-configured
                W = Triggers-awaiting
                t = Triggers-pending
                i = Installed

              Error flags:
                <empty> = (none)
                R = Reinst-required




Monday, November 23, 2020

Install CircuitPython to nanoESP32-S2, on Raspberry Pi.

 


MuseLab nanoESP32-S2 is a dev. board with a ESP32-S2 module. This board has 2 USB-C connector, one for Serial (ch340) and one for Native USB (esp32), is supported running CircuitPython.

Currently, nanoESP32-S2 support 4 module:

  • ESP32-S2-WROOM: PCB Antenna, no PSRAM.
  • ESP32-S2-WROOM-I: IPEX Antenna, no PSRAM.
  • ESP32-S2-WROVER: PCB Antenna, with PSRAM.
  • ESP32-S2-WROVER-I: IPEX Antenna, with PSRAM.

My sample is ESP32-S2-WROVER-I.

This video show the steps to flash CircuitPython (latest unstable release CircuitPython 6.1.0-beta.1) on museLab nanoESP32-S2, using Raspberry Pi 4B/8G running Raspberry Pi OS (32 bit).


Install esptool:
$ sudo pip install esptool
Download CircuitPython:
Visit https://circuitpython.org/board/muselab_nanoesp32_s2/ to download CircuitPython (.BIN) for nanoESP32-S2.

The full path of the downloaded file in my case is:
/home/pi/Downloads/adafruit-circuitpython-muselab_nanoesp32_s2-en_US-6.1.0-beta.1.bin

Identify the COM port to attached to ESP32-S2 board, using dmesg:

Before connect to ESP32-S2 board:

Enter the command to clear dmesg buffer:
$ sudo dmesg -c

Connect ESP32-S2 USB marked "ch340".

Enter the command to check the latest attached port:
$ dmesg

found:
ch341-uart converter now attached to ttyUSB0

The COM port is: /dev/ttyUSB0

Erase and Flash ESP32-S2:

Erase:
$ esptool.py --chip auto --port <COM PORT> erase_flash
Flash with downloaded CircuitPython:
$ esptool.py --chip auto --port <COM PORT> -b 460800 --before=default_reset \
--after=hard_reset write_flash --flash_mode dio --flash_freq 40m --flash_size 4MB 0x0000 \
<DOWNLOADED FILE>
Done!
After flashed with CircuitPython, you can now disconnect and reconnect the ESP32-S2 board to the another USB connector marked "esp32".

A new driver name "CIRCUITPY" is attached.


Install Mu:

Mu is a Python Editor, and is suggested to program CircuitPython.

To install Mu on Raspberry Pi OS:
Click the Menu >> Preferences >> Recommmended Software
>> Programing >> Mu

With Mu installed, you can try something with CircuitPython REPL. Refer to the video.


For more exercise related to CircuitPython/ESP32-S2, refer to my another blog posts Embedded things > Hello nanoESP32-S2/CircuitPython

Install esptool on Raspberry Pi OS

esptool.py is a Python-based, open source, platform independent, utility to communicate with the ROM bootloader in Espressif ESP8266 & ESP32 chips. ESP32-S2 is supported started from Version 3.0 (https://github.com/espressif/esptool/releases).

To install esptool on Raspberry Pi OS, enter the command in Terminal:

$ sudo pip install esptool
remark:

In my trial on Raspberry Pi OS, if I install without "sudo", I cannot run it without specify the full path.

Because the esptool.py executable is installed to the hidden directory ~/local/.bin directory. Have to set PATH to esptool, otherwise it cannot be run directly. So I install esptool with "sudo".

To check the version of installed esptool using pip:
$ pip show esptool



Next:
Install CircuitPython to nanoESP32-S2, on Raspberry Pi