Posts Tagged ‘rpi’

1 Comment

Scanning the WiFi network with the Raspberry Pi Pico W

Friday, July 22nd, 2022

Let’s try the Wifi features of the new Raspberry Pi Pico W.

The Pico W has two Wifi interfaces:

  • network.STA_IF, the station interface
  • network.AP_IF, the access-point interface

network.STA_IF

The station (or standard) interface, can be used to connect the Pico W to another 2.4GHz WiFi access point. This seems to be the default.

network.AP_IF

The access-point interface can be used to turn your Pico W into a WiFi access-point that can connect up to 4 devices at the moment.

Use the Pico W to scan access points

Let’s try out the station interface, network.STA_IF.

Using micropython it’s really a breeze:


import network
import binascii
wlan = network.WLAN() #  network.WLAN(network.STA_IF)
wlan.active(True)
networks = wlan.scan() # list with tupples with 6 fields ssid, bssid, channel, RSSI, security, hidden
i=0
networks.sort(key=lambda x:x[3],reverse=True) # sorted on RSSI (3)
for w in networks:
      i+=1
      print(i,w[0].decode(),binascii.hexlify(w[1]).decode(),w[2],w[3],w[4],w[5])

In most example code you need to specify the interface, but apparently it defaults to the standard station network.STA_INF interface.

The output is a list with tupples that according to the docs should contain six fields ssid, bssid, channel, RSSI, security, hidden.

The bssid is the same as the hardware unique MAC-address.

There are five values for security:

  1. open (0)
  2. WEP (1)
  3. WPA-PSK (2)
  4. WPA2-PSK(3)
  5. WPA/WPA2-PSK (4)

and two for hidden:

  1. visible (0)
  2. hidden (1)

The docs states that for hidden 0 = visible and  1 = hidden, but actually the output I get, some twenty networks(!?) gives no 0, but several undocumented values for hidden: 1,2,3,4,5,7.

Twenty WiFi-networks? Yes, I do work in a city. And that’s only the 2.4GHz band. 🙁

So what does those values mean, what is there more than visible or hidden?

Also the security results differ with outputs from 0 (=open), most 5, but some report 7.

What do those values for security mean?

Is it a bug or a (undocumented) feature?

No Comments

Raspberry Pie with a Taste of Chocolate, the funny Desktop Droste effect

Tuesday, June 28th, 2022

The original Droste Effect

Trying out the new Ubuntu 22.04 on my Raspberry Pi 400, I was surprised by the smoothness of the new Ubuntu distribution. Much better impression then the first time I tried Ubuntu on the RPI, I think that was the 20.10 release.

A funny thing to try out, especially if you love fractals or you are an admirer of the Dutch graphic artist Escher who’s work features features mathematical and even impossible objects, is the subject of this post.

Another returning phenomenon in his drawings and paintings is the Droste-effect , and I’ll shwo you how to create a Droste effect on your Raspberry Pi with a few mouse-clicks.

Creating a Droste effect on your Raspberry Pi

Yes, you can do that with just a couple of mouse-clicks, you don’t need a mathematical package or a graphical editor like Gimp or so.

Trying out the new Gnome Desktop Sharing feature, which let you share your desktop not only with the older VNC protocol, but also with the newer RDP protocol, gave me this idea.

To activate:

Settings -> sharing -> enable -> enable Remote Desktop -> and setup some authentication: username and password

For creating the Droste-effect we gonna do something silly: we gonna connect to our-self! Yes a Remote Desktop Connection with a local client.

A Remote Desktop Connection with a local client

Introspection!

Start up the default remote desktop client Remmina.

Quick setup a new connection, enter your IP-address and the authentication you just entered: username and password.

To find your IP-address, open a terminal, (CTRL ALT T) and type `ip address` return. Then you will find it in the output, or look it up under details in the network settings.

Save and connect in the Remmina dialog, and see the connection being made.

Click the `Toggle Scaled Mode` button to rescale the desktop (CTRL_R S), and there it is.

A nice Raspberry Pi Droste Effect of the Ubuntu Desktop in a local remote Desktop connection: 🙂

Remmina Droste effect

Remmina Droste effect

Gnome-connections

An alternative to `Remmina` is Gnome-connections. That program is in development, but like all Gnome apps, it does offer an very easy and intuitive approach.

Can all the settings in Remmina be overwhelming, gnome-connections is easy as it can be.

But the default resolution seems to be quite poor. And I could not find a scaling options, so you end up with a more spacey psychedelic form of computer art.

The Gnome-Connections Art

The Gnome-Connections Art

Cool as well.

Update: Actually there is a scale setting for Gnome-Connections, a bit hidden, under properties once you established a connection. Using Gnome-connections for managing my Pi400 from another Ubuntu 22.04 is working quite well, although I had to restart the Pi400 to get control working.

So maybe Gnome-connections is lacking a lot of settings, it’s working out of the box surprisingly well in Ubuntu 22.04.

Give it a try, if you own a Pi.

How does the Pi create a Droste effect?

You open up a program that shows your complete desktop scaled including the program that shows your desktop scaled, etc etc.

Actually I was expecting a crash, or out of memory error, you will probably get that when you let it run for hours, but the Raspberry Pi kept being responsive for the couple of minutes I tried. Enough time to take a screenshot.

So it seems Ubuntu and Gnome are much more optimized for running on less powerful hardware in 2022 then a couple of years ago.

This funny showcase of the Droste-effect is the prove, and that is all a big win.

Please let me know what you think in the comments.

4 Comments

Kodi on Bullseye, playing 4K on the RPI4

Friday, March 18th, 2022

Getting the most out of your (cheap) hardware is always a challenge. Selling hardware is easier then supporting hardware.

The Raspberry Pi 4 has strong multimedia capabilities, it can playing 4K media 60fps, but getting it done isn’t a piece of cake. Even playing 1080HD content on YouTube can be a problem, but that’s probably because YouTube is more about tracking and selling adds than playing media.

A bold statement? Think about it this way. Any 1080p movie will play fine outside a browser in Kodi, any movie will play fine without DRM (Digital Rights Management). It chokes on the DRM en-/decryption. By definition: DRM is tracking.

Historically LibreElec is the best distribution for a Raspberry Pi as a multimedia device. LibreElec’s goal: just enough OS to support Kodi, and it is highly optimized for that.

Yes it’s powerful. You can install add-ons like MPD for music, or RetroPie-alike  for games. Also docker containers are available for HomeAssistant, MQTT and Nginx. So a RPI with LibreElec can be pretty powerful.

Still LibreElec is limited, and the RPI4 is capable of doing more.

Kodi on Raspberry used to work pretty well, until big changes in the 5.10 kernel came. It more or less stopped working on Buster. Compiling it yourself was quite a hassle, that actually failed more than it succeeded. I wrote about that before and it failed in most cases for most users including myself, I must admit.

But now luckily RPI-engineers stepped up:  Kodi in Rapsberry Pi OS is more or less supported again.

At least it’s easy again to install Kodi in Bullseye. But you still need a bit more tweaks to get it running smoothly.

To install Kodi in Bullseye

No OS can beat this 🙂 :

sudo apt install kodi

Install addons

Two important add-ons that can’t be installed from within Kodi like in LibreElec, but you have to resort to apt again:

TVHeadend-client (DVB-T tv)

sudo apt install kodi-pvr-hts

Only the client is installed with this command, this assumes a TV-Headend server is running on another local IP-address.

Inputstream-adaptive helper to play DRM protected (Widevine) content

sudo apt-get install kodi-inputstream-adaptive

The add-on then will extract (and update) the needed libs from internet automatically.

To enable HEVC HW decoding, you have to tweak /boot/config.txt

Add this line (only for RPI4)

dtoverlay=rpivid-v4l2

For 4K HEVC playback tweak this line:

# Enable DRM VC4 V3D driver
dtoverlay=vc4-kms-v3d,cma-512

Mount NFS shares

Somehow Kodi on Bullseye stopped discovering NFS by default. Don’t worry to much, just give it a little manual bump.

  • Choose Browse for new share -> Add network location -> Protocol -> Network File System (NFS)
  • Entering the your ip-address as Server address and Remote path manually, adding up to something like nfs://192.168.0.3:/path/to/mnt/
  • Click OK, then it will list.
  • Select and click OK.

Conclusion

Changes in `/boot/config.txt` require a reboot.

After all these steps, playing 4K HEVC content with HW-acceleration should work fine on a Raspberry Pi 4.

That’s all. Let me know if it’s working for you.

 

No Comments

Powering a Pi Zero (2) from your laptop

Friday, November 12th, 2021

The new quad-core Pi Zero 2 has a lot more horsepower than the original Zero and as a consequence it does require more power than the original Zero.

But that doesn’t necessarily means that you cannot power it from an USB port from your laptop.

Can you still power a Raspberry Pi Zero from an USB port of a laptop?

Let’s try. Be reminded all Pi’s are cleverly designed to throttle down, when they experience a power shortage.

To check if your Pi has throttled down:

> vcgencmd get_throttled
throttled=0x0

If you see some other output then 0x0 yes then you’ve had power problems. Otherwise you’re OK.

For the moment, running Raspberry Pi OS Bullseye on a Raspberry Pi Zero 2 powered form an USB port doesn’t show problems by just installing programs and updating the OS.

No Comments

Stop your Raspberry Pi from leaking telemetry to Microsoft

Friday, February 19th, 2021

Visual Studio Code is a highly rewarded and much used code-editor from Microsoft.

Microsoft tells you it’s open source, but when you actually install it on your Raspberry Pi 4 or Raspberry Pi 400 as promoted, it suddenly isn’t open source anymore. The installation binaries come packed with some proprietary stuff, like telemetry and tracking.

There is no real reason for that, Microsoft could absolutely disable telemetry by default and offer it 100% open source, but Microsoft doesn’t do that. The company wants to ride on the popular waves of open source without actually practicing it.

Luckily there is a real open source version of VSCode and that is called VSCodium:
https://github.com/VSCodium/vscodium

Somehow Microsoft has managed to get the Raspberry Pi Foundation to add a Microsoft repository with the non-open source version of VSCode.

So when you even do not want to use a Microsoft product, Microsoft is still getting some info about your usage of your Raspberry Pi. In every update your Pi will check with the servers if there is a update.

If you want to stop the spying and tracking, execute this command on your Raspberry Pi:

sudo sed -i 's/^deb/#deb/g' /etc/apt/sources.list.d/vscode.list

Or when you wanna do that remotely:

ssh yourpi "sudo sed -i 's/^deb/#deb/g' /etc/apt/sources.list.d/vscode.list"

This will comment-out the Microsoft repository, and stop checking / leaking usage data to Microsoft.

To install the real VSCode open source version on your Raspberry Pi 4(00):

Install from repository for Debian/Ubuntu/Linux Mint

Recommended way of install. It will update automatically, and now the Gitlab servers will be pinged and not Microsoft’s. 😉

That’s not much of a gain, but you get a version without telemetry and tracking and without proprietary code, and that is of course a real win.

See:

https://github.com/VSCodium/vscodium#install-with-package-manager

Install as Flatpak

Not the best choice, but you can install it aside a repository version; to check and test the speed and functionality of Flatpak builds.

Chances are high, you get a slightly older build this way.

flatpak install flathub com.vscodium.codium

flatpak run com.vscodium.codium
The 100% open source VSCodium running on a Pi 400

The 100% open source VSCodium running on a Pi 400

 

The main ten million dollar question remains, why doesn’t Microsoft offer a 100% open source version of VSCode in the first place?

It’s like wrapping a nice sustainable vegetable up in non-degradable plastic. We won’t save the planet with that attitude.

3 Comments

Using A Raspberry Pi Zero as a webcam without SD card

Thursday, January 7th, 2021

The covid lock-down is sentencing a lot of people to work from home. For that we need webcams, a new pc, better monitor  and other equipment. The Raspberry Pi 400 is  a great and affordable second desktop, it’s the fastest Pi available suited for desktop use. It lacks a camera connector, so you need a Zero to connect a camera board.

So what about reusing that old gadget that was collecting dust in the drawer: a small and cheap Raspberry Pi Zero. If you also happen to own a camera board for that little computer, here is a nice project showmewebcam to turn that cheap computer into a handy webcam. It uses a small Buildroot Linux version and boots really fast.

And now that project has been forked on Github: showmewebcam-usbboot. No SD-card needed. That project will let the Raspberry Pi Zero boot over USB!

If you don’t have a camera board. You can buy a clone version of the v1 board for a few dollars in China, or get a v2 board or for the best results the really great HQ-camera board.

Interested in photography, that High Quality camera board can do some really great macro-photography.

Cheap Raspberry Pi webcam

With the Raspberry Pi Zero costing about 5 euro, and a clone camera board around 3 euro on AliExpress, you can have a very nice and decent webcam for less then 10 euro’s. And that is a bargain. Remember you don’t need an SD card. So save on the hardware where you can.

How does it work?

How does the Pi boot then? Over USB, so you do need the usbboot/rpiboot tool. That is free and opensource software made by the Raspberry Pi organization, a program that makes the Raspberry P Zero boot by pushing the operating system over USB.

Let’s try it out. I’m using an Ubuntu desktop.

Step 1: download showmewebcam-usbboot

Download the latest release .

Unzip it. You will extract a directory called showmewebcam-usbboot.

Step 2: install usbboot/rpiboot

If you have already installed a version of this tool, you can of course skip this tool and jump to step 3.

Download the usbboot/rpiboot, unzip it and build it according to the instructions.

Step 3: Connect the raspberry Pi Zero

(with installed camera board) by putting the USB plug into the middle USB connector.

Step 4: boot the webcam

You can start the webcam by executing the rpiboot tool and pointing it to the unzipped showmewebcam-usbboot directory

sudo ~/usbboot/rpiboot -d ~/showmewebcam-usbboot

After about half a minute booting the Raspberry Pi Webcam will be ready.

How to use the Webcam on the PC

For a quick start, and when no other cam is connected, you can start the webcam with (Ubuntu):

mpv /dev/video0

On a laptop with a build-in webcam the command that you have to issue will be :

mpv /dev/video2

To control your cams on the PC, you need `v4l-utils` (apt install v4l-utils)

To set the resolution

v4l2-ctl --set-fmt-video=width=1280,height=720 -d /dev/video2

To list all video devices:

v4l2-ctl --list-devices

To list the specs of your video devices:

v4l2-ctl --list-formats-ext
ffmpeg -f v4l2 -list_formats all -i /dev/video2

A serial connection will also be available, so you can connect to the Webcam to control the settings and do debugging. That works exactly the same as in showmewebcam

Control the webcam

Finer control offers the camera-ctl tool on the Zero

Connect to the Zero:

sudo screen /dev/ttyACM0 115200 Start the tool # /usr/bin/camera-ctl
Showmewebcam-usbboot - Controlling the webcam with camera-ctl

Controlling the webcam with camera-ctl

Create a stereo webcam

The tool will let you boot more then one Raspberry Pi Zero from the same directory. Just connect the two Raspberry Pi Webcams and start the tool. One will boot, just execute the tool another time and the other one will boot.

The webcams will be available as /dev/video0 (you) and /dev/video2 (your cat) on your Pi400.

Now make that video call with your boss, and ask for a raise. Switch the webcam to your cat the moment you stopped speaking.

What can showmewebcam-usbboot do what showmewebcam can’t do?

Nothing. It can do the same with less hardware, because it doesn’t need an SD card. But is does need extra software, which can limit compatibility. It also boots slower.

It hasn’t been tested that much.

Have fun, try it out,  en let me now your thoughts!

Links: