#RaspberryPi – Raspberry Pi 400,

Buy Me A Coffee

Hi !

It seems that it was yesterday when I wrote about the amazing and new Raspberry Pi 4, and it was on February ! There was a lot of news since February, however the Raspberry 400 is a huge milestone.

From a hardware view, is a faster device, that’s cool. However I really like the all-in-one format:

Raspberry Pi 400, a compact keyboard with an ARM-based computer built in.

Start is super easy

  • Add your SD card with your OS image
  • Connect 1 or 2 monitors using the 2 micro HDMI ports
  • Power the device
  • Optional, connect a mouse
  • that’s all !

The specs are super cool:

  • Broadcom BCM2711 quad-core Cortex-A72 (ARM v8) 64-bit SoC @ 1.8GHz
  • 4GB LPDDR4-3200
  • Dual-band (2.4GHz and 5.0GHz) IEEE 802.11b/g/n/ac wireless LAN
  • Bluetooth 5.0, BLE
  • Gigabit Ethernet
  • 2 × USB 3.0 and 1 × USB 2.0 ports
  • Horizontal 40-pin GPIO header
  • 2 × micro HDMI ports (supports up to 4Kp60)
  • H.265 (4Kp60 decode); H.264 (1080p60 decode, 1080p30 encode); OpenGL ES 3.0 graphics
  • MicroSD card slot for operating system and data storage
  • 78- or 79-key compact keyboard (depending on regional variant)
  • 5V DC via USB connector
  • Operating temperature: 0°C to +50°C ambient
  • Maximum dimensions 286 mm × 122 mm × 23 mm

I am really looking forward to test the GPIO pins on the back of the keyboard. I have several hats, and connectors for this, so I’m sure that we will see some adapters in the near future:

And I really like this analogy from FastCompany (see references)

Of course, the computer-in-a-keyboard concept isn’t new. As The Verge notes, the Raspberry Pi 400 is a throwback of sorts to classic PCs like the BBC Micro, ZX Spectrum, or Apple IIe, and some vendors such as Asus have tried to revive the concept before. But with Raspberry Pi’s low pricing and its emphasis on education, now might be just the right time for a revival. The only question is when Raspberry Pi takes the next logical step and makes a full-blown laptop.

Happy coding!

Greetings

El Bruno

References

My posts on Raspberry Pi

Dev posts for Raspberry Pi
Tools and Apps for Raspberry Pi
Setup the device
Hardware

#RaspberryPi – Raspberry Pi Imager, super cool imaging utility. Bonus: source code included !

Buy Me A Coffee

Hi !

It’s time to setup a Raspberry Pi so my kid can learn a little Python with some local projects at home. And, it’s also time to test one super cool tool from the Raspberry Pi family: Raspberry Pi Imager, a new tool to image microSD cards with Raspbian.

Until today, I mostly used Balena Etcher, and it works amazing. However let’s give this one a try.

First step is to download the tool from the official Download page (see references). Lucky for us, we have the application with versions for Windows, macOS and Ubuntu. The install process is very fast.

raspberry pi imager setup process

Now we launch the app, and select the OS to install.

raspberry pi installer, welcome screeen

This time Raspbian is the one for me. I really like the chance to have other SOs here to select

raspberry pi imager select Raspbian OS

And, I will go even further and select the full version of Raspbian.

select raspbian full

Next step, is to select the target microSD Card, Device. F: for me.

select sd card, disk F

Now we are ready to write the image to the SD Card.

Ready to write the image.

Important: depending the selected image, writing process may take some time. The Full Raspbian version is +2.5GB and it needs to be downloaded in chunks. before starting the write process.

As usual, after writing, let’s verify !

raspberry pi imager verifing step

A couple of minutes later, the process is done !

write process complete

Bonus

And a couple of notes as a bonus. The tool is open source, and this is great! (see references). And, a video is much better than my posts !

Happy coding!

Greetings

El Bruno

References

#RaspberryPi – New Raspbian image for 2020-Feb-05

Buy Me A Coffee

Hi!

I remember last time I download and updated my Raspberry Pi with the latest Raspbian image, because it was the week before the Caribbean Developers Conference, and I deal with a couple of unexpected issues with the new version.

After the Regional Innovation Summit in Seattle, one of the draft posts that I have is related to a new Raspbian version released on 2020 Feb 05. See Release notes in the references section below. There are a couple of very interesting features here:

File Manager

The File Manager has a couple of new and interesting options. It’s still not as good as Double Commander, but I like the new features. This is the old FM

raspbian file manager before the update

And in the new one we can find that the Places, which allow us to directly access to our most frequent locations, is not collapsed by default. And with this new space, we can access more easily to other resources like USB disks and more.

Another big one, is the [New Folder] icon in the toolbar. Yes, this small one feature makes our lives much more happy! And there are new icons and more.

Code the Classics

Remember that I got my amazing [Code the Classics] book? Now all the samples for the book are included as an option to be downloaded from the Recommended Software in the Games section.

raspbian now includes code the classics in the recommended software

Display Options

I mostly use my device via VNC (which was also updated), however sometimes I got some issues when I connect my device to an external monitor. In the previous configuration, we didn’t have any option to manage this:

In the new version we can enable or disable the following options

  • Underscan
  • Pixel Doubling
  • Composite Video
  • Screen Blanking
raspbian raspberry pi configuration after the update.png

Change Log

The full change log is:

  • Version 3.2.6 of Thonny included – significant improvements in speed, particularly when debugging
  • Version 1.0.4 of Scratch 3 included – adds new “display stage” and “display sprite” blocks to SenseHAT extension, and loading of files from command line
  • Version 32.0.0.314 of Flash player included
  • Version 1.0.3 of NodeRED included
  • Version 6.6.0 of RealVNC Server and version 6.19.923 of RealVNC Viewer included – adds support for audio
  • Version 78.0.3904.108 of Chromium included
  • Mesa updated to 19.3.2 for OpenGL ES 3.1 conformance
  • Pixel doubling option added in Raspberry Pi Configuration on platforms using FKMS display driver
  • Orca screen reader added to Recommended Software
  • Code The Classics Python games added to Recommended Software
  • File manager – new “places” pane added at top of sidebar to show mounted drives in simplified view; “new folder” icon added to taskbar; expanders in directory browser now correctly show state of subfolders
  • Multiple monitor support improved – alignment of icons on second desktop corrected, Appearance Settings opens on correct tab when launched from context menu
  • Raspberry Pi Touchscreen correctly aligned with display
  • System clock synchronised before installing new packages in startup wizard and Recommended Software
  • Mixer dialogs added to taskbar volume plugin; separate Audio Preferences application removed
  • Raspberry Pi Configuration – separate tab added for display options; screen blanking control added
  • Volume taskbar plugin and raspi-config modified to support separate ALSA devices for internal audio outputs (analogue and HDMI 1 and 2)
  • Robustness improvements in volume, ejecter and battery taskbar plugins
  • Movement of mouse pointer to menu button on startup now controlled by point_at_menu parameter in Global section of lxpanel configuration file
  • Ctrl-Alt-Del and Ctrl-Alt-End shortcuts added to open shutdown options box
  • Ctrl-Shift-Esc shortcut added to open task manager
  • Enabled NEON routines in OpenSSL
  • Linux kernel 4.19.93
  • Raspberry Pi firmware 67392a7a32bddad7f571047fccafca9eeb65d29c

How to Update

If you want to update your current existing version, you must run the commands

sudo apt update
sudo apt full-upgrade

Happy coding!

Greetings

El Bruno

References

My posts on Raspberry Pi

Dev posts for Raspberry Pi
Tools and Apps for Raspberry Pi
Setup the device
Hardware

#RaspberryPi – Install Virtual Environments

Buy Me A Coffee

Hi!

Virtual Environments are a great way to isolate our dev tests, and after been using this in Windows also, work with them in the Raspberry Pi makes a lot of sense.

I’ll leave here the necessary steps to do this, however the full credit is based on some posts from Adrian Rosebrock and his amazing blog (see references).

Once we have everything updated in our Raspbian, let’s run the following command:

sudo pip install virtualenv virtualenvwrapper
sudo rm -rf ~/get-pip.py ~/.cache/pip

Now we need to update the ~/.bashrc file using nano (not a big fan of VI )

nano ~/.bashrc

And then add the following lines

# virtualenv and virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source /usr/local/bin/virtualenvwrapper.sh

Now everytime we open a new terminal session, this commands will be applied and we will have our virtual environments up and running.

Next, source the bashrc file

source ~/.bashrc

And we can create a new virtual environment. Let’s create one named devOpenCV using python 3.

mkvirtualenv devOpenCV -p python3

We can enable and access the virtual environment with the workon command, and we will see the virtual environment as a prefix in our terminal

workon devOpenCV

As we can see in the following screenshot, the virtual environment uses the latest Python 3 version, and just a few packages installed.

Happy coding!

Greetings

El Bruno

References

My posts on Raspberry Pi

Dev posts for Raspberry Pi
Tools and Apps for Raspberry Pi
Setup the device
Hardware

#RaspberryPi – Performance differences in #FaceRecognition using #OpenVino (code with @code!)

Buy Me A Coffee

Hi !

I’ve been looking to use the amazing Intel Neural Stick 2 for a while, and one of the 1st ideas that I have was to check how fast my Raspberry Pi 4 can run using this device.

The Intel team released a nice step by step process installation for Raspberry Pi. And it works great, there are a couple of minor glitches that you need to figure out, like the latest package version, everything else works great.

Note: I downloaded my openvino toolkit from here (https://download.01.org/opencv/2019/openvinotoolkit/R3/), and the downloaded file is (l_openvino_toolkit_runtime_raspbian_p_2019.3.334.tgz).

Once installed, the 1st python sample is a face recognition one. This sample analyzes a image file using OpenCV to detect faces, and creates a new output file with the detected images. As I said, is very straight forward.

So, I decided to create a new python sample to run live face detection using the camera feed and also display the FPS. This is the output code:

# perform face detection
# display detected face frame
# display FPS info in webcam video feed
# This is the official sample demo file desribed in the installer documentation
# Date: 2020 01 26
# Install OpenVINO™ toolkit for Raspbian* OS
# http://docs.openvinotoolkit.org/2019_R1/_docs_install_guides_installing_openvino_raspbian.html
import cv2
import time
import imutils
# Load the model.
net = cv2.dnn.readNet('face-detection-adas-0001.xml',
'face-detection-adas-0001.bin')
# Specify target device.
# ERROR net.setPreferableBackend(cv2.dnn.DNN_BACKEND_OPENCV)
# OK net.setPreferableBackend(cv2.dnn.DNN_BACKEND_INFERENCE_ENGINE)
# ERROR net.setPreferableBackend(cv2.dnn.DNN_BACKEND_HALIDE)
net.setPreferableBackend(cv2.dnn.DNN_BACKEND_INFERENCE_ENGINE)
net.setPreferableTarget(cv2.dnn.DNN_TARGET_MYRIAD)
# open video frame
video_capture = cv2.VideoCapture(0)
while True:
start_time = time.time()
ret, frame = video_capture.read()
# frame resize to improve performance
frame = imutils.resize(frame, width=648, height=480)
rgb_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
# Prepare input blob and perform an inference.
blob = cv2.dnn.blobFromImage(rgb_frame, size=(640, 480), ddepth=cv2.CV_8U)
net.setInput(blob)
out = net.forward()
# Draw detected faces on the frame.
for detection in out.reshape(1, 7):
confidence = float(detection[2])
xmin = int(detection[3] * frame.shape[1])
ymin = int(detection[4] * frame.shape[0])
xmax = int(detection[5] * frame.shape[1])
ymax = int(detection[6] * frame.shape[0])
if confidence > 0.5:
cv2.rectangle(frame, (xmin, ymin), (xmax, ymax), color=(0, 255, 0))
#display FPS
fpsInfo = "FPS: " + str(1.0 / (time.time() start_time)) # FPS = 1 / time to process loop
print(fpsInfo)
font = cv2.FONT_HERSHEY_DUPLEX
cv2.putText(frame, fpsInfo, (10, 20), font, 0.4, (255, 255, 255), 1)
cv2.imshow('Video', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
video_capture.release()
cv2.destroyAllWindows()

The code is very straight forward and the main matters are

  • It uses 2 models from the Intel Zoo to perform the face detection: face-detection-adas-0001.xml and face-detection-adas-0001.bin
  • Lines 22 and 23 are key to define that OpenCV will load and use the models in the Intel device
  • I use imutils to resize the image to 640×480. Feel free to use any other library for this, even OpenCV
  • Also, it works also with smaller resolutions, however 640×480 is good for this demo

And the final app running analyzing almost 8 frames per second (8 FPS).

Which is almost 10 times faster that the 0.7 FPS without Intel NCS2

And, I already wrote about running Visual Studio Code in the Raspberry Pi (see references) is an amazing experience. I did all my Python in VSCode coding remote accesing my device via VNC. Python runs like a charm!

You can download the code from https://github.com/elbruno/rpiopenvino/tree/master/facedetection

References

My posts on Raspberry Pi

Dev posts for Raspberry Pi
Tools and Apps for Raspberry Pi
Setup the device
Hardware

#RaspberryPi – How to solve the SSH warning: WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

Buy Me A Coffee

Hi !

When you test and play around with your Raspberry Pi, you may need to format again your Raspbian SD Card, and then start everything from scratch. This is a trivial process, and is usual to setup the device to connect automatically to a Wifi network and also enable SSH (I wrote about this, see references).

And then, when you try to connect via SSH you may get this warning

 C:\Users\bruno> ssh pi@192.168.1.247
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256: Not here ! 
Please contact your system administrator.
Add correct host key in C:\\Users\\bruno/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in C:\\Users\\bruno/.ssh/known_hosts:10
ECDSA host key for 192.168.1.247 has changed and you have requested strict checking.
Host key verification failed.

This is a very common scenario, and because I forgot how to fix it, I’ll write the simple command remove all keys belonging to the IP / hostname from the known_hosts file.

# ssh-keygen -R <host>
ssh-keygen -R 192.168.1.247

And that’s it, keys removed and now I can connect via SSH

Happy coding!

Greetings

El Bruno

References

My posts on Raspberry Pi

Dev posts for Raspberry Pi
Tools and Apps for Raspberry Pi
Setup the device
Hardware

#RaspberryPi – How to install #docker (Updated 2020-01-24)

Buy Me A Coffee

Hi

I wrote a couple of times about this, however this is the updated version on how to install docker in a Raspberry Pi. Updated to Jan 24 2020.

The information is available from the Official Docker Documentation

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

And then, a simple check for the docker version with the command

docker version

And that’s it ! Docker installed in the device 😀

Happy coding!

Greetings

El Bruno

References

My posts on Raspberry Pi

Dev posts for Raspberry Pi
Tools and Apps for Raspberry Pi
Setup the device
Hardware

#RaspberryPi – Install OpenCV

Buy Me A Coffee

Hi!

After some posts about how to setup a Raspberry Pi, today I’ll share the steps I follow to install OpenCV.

Disclaimer: if you are looking for a detailed step by step on how to install or even build OpenCV in a Raspberry Pi, I strongly recommend to read the post “Install OpenCV on Raspberry Pi 4” by Adrian Rosebrock.

Ok, so let’s start. I assume that you read my posts and your Raspbian image is up and running.

Install Python 3 and Update device

1st step will be to install Python 3 with the following command

sudo apt-get install python3-dev

And run and update for all the installed software

sudo -- sh -c 'apt-get update; apt-get upgrade -y; apt-get dist-upgrade -y; apt-get autoremove -y; apt-get autoclean -y'
Install and use Virtual Environments

This will give us the base image to start working. And, in case we need to install different versions or different apps, I’ll use virtual environments to work with Python.

Let’s install VirtualEnv with the command

#create virtual environment
sudo pip3 install virtualenv

Now let’s create a new virtual environment named “venv” with the command

virtualenv -p python3 .venv

And let’s activate the environment with the command

source .venv/bin/activate

At this moment, the terminal should change and add a prefix (venv) in the bash.

raspberry pi install and activate a virtual environment
Install prerequisites

Let’s update again

sudo apt-get update

And install prerequisites with the commands

sudo apt-get install gfortran 
sudo apt-get install libopenblas-dev 
sudo apt-get install liblapack-dev
sudo apt-get install libatlas-base-dev
sudo apt-get install libjasper-dev
sudo apt-get install libqtgui4
sudo apt-get install python3-pyqt5
sudo apt-get install libqt4-test

or in a single command

sudo apt-get install gfortran libopenblas-dev liblapack-dev libatlas-base-dev libjasper-dev libqtgui4 python3-pyqt5 libqt4-test -y

This process will take some minutes, so this is time 1 to get a coffee!

Install OpenCV and switch to right Raspberry Pi version!

And now the magic command to install OpenCV

sudo apt-get install libopencv-dev

And this process is the one who take most of the time, so coffee number 2. Take a look at all the dependencies for this

And after a couple of minutes the process is done. We can test the OpenCV version running 2 simple python commands. First let’s start python with the command

python

And then run the following lines

import cv2
cv2.__version__

This should display the current OpenCV version.

However, with the latest version we have an error: ModuleNotFoundError: No module named ‘cv2’

The current installed version have some issues running in the raspberry py, so we need to make a downgrade to the version 4.1.0.25 with the command. We first uninstall the installed version (4.1.0.26) and install the specific version.

pip uninstall opencv-contrib
pip install opencv-contrib-python==4.1.0.25

Now, we launch python again, run our 2 lines, and we got OpenCV up and running!

Bonus: Installed Packages

Finally, this is the current list of packages installed in the virtual environments and the version of each package

(.venv) pi@rpidev5:~ $ pip3 list
Package               Version
--------------------- --------
numpy                 1.18.1
opencv-contrib-python 4.1.0.25
pip                   20.0.1
setuptools            45.1.0
wheel                 0.33.6
(.venv) pi@rpidev5:~ $

Happy coding!

Greetings

El Bruno

References

My posts on Raspberry Pi

Dev posts for Raspberry Pi
Tools and Apps for Raspberry Pi
Setup the device
Hardware

#RaspberryPi – setup without monitor: enable VNC

Buy Me A Coffee

Hi!

In my previous post I shared a series of steps to:

  • Configure and SD Card with Raspbian
  • Automatically connect to a WiFi network
  • Enable SSH
  • Expand the file system
  • Rename the device
  • Update the default Raspbian software

In this post I’ll share the necessary steps to enable the VNC service, so you can connect to the Raspbian Desktop via VNC.

Enable VNC

In order to activate the VNC service we need to access to the device configuration with the command

sudo raspi-config

Then we select the options

  • Interfacing Options
  • VNC

Select YES

And that’s it, the VNC Server is enabled.

Now we can connect to the device with a VNC client app. Like in example, VNC Viewer

Conclusion

And that’s it, we have our device updated and running with the latest software versions and we didn’t use a monitor! I’ll update this post frequently to make it relevant with my personal best practices.

Happy coding!

Greetings

El Bruno

References

My posts on Raspberry Pi

Dev posts for Raspberry Pi
Tools and Apps for Raspberry Pi
Setup the device
Hardware

#RaspberryPi – 1st setup without monitor: auto connect to WiFi, enable SSH, rename, update and more!

Buy Me A Coffee

Hi!

Ok, let’s assume you did the tutorial and installed the latest raspbian image in an SD card. If you want to access and control remotely your device you may want to follow this steps.

Configure Wireless connection

In the SD Card, you need to create a file named [wpa_supplicant.conf] in the root of the SD card with the following information:

country=ca
update_config=1
ctrl_interface=/var/run/wpa_supplicant

network={
 scan_ssid=1
 ssid=" Your WiFi SSID"
 psk="You amazing password"
}

The file content is very straight forward to understand. Main values to complete are [ssid] and [psk].

Once you put the SD card in the device and start the device, it will automatically connect to the configured WiFi.

Enable SSH

If you also want to enable SSH, you need to create a blank file named [ssh] to the main partition.

Once you put the SD card in the device and start the device, it will automatically enable the SSH service.

Find the IP address in your network

And that’s it, your Raspberry Pi will be connected to the Wifi and with SSH enabled. At this moment we can use a tool like AngryIp (see references) to detect the new device in the network

My new device IP is: 192.168.1.246

Access via SSH

I used to like Putty to connect to my device, however during the past months I’ve been using Windows Terminal and Powershell. In order to access the device I need to execute the command

ssh user@deviceaddress

and my data is

  • user: pi
  • ip: 192.168.1.246
  • password: raspberry

You can now start working with your Raspberry Pi !

Change Password

The default password for the device is “raspberry”, and as usual, it’s recommended to change it. In order to do this, in the ssh terminal, let’s access to the device configuration

sudo raspi-config

This will open the configuration for the device.

Option number 1 will allow us to change the password.

Rename the device

In the same Raspberry configuration tool, we can rename the hostname that our device will use for network operations.

Select the options

  • Network Options
  • Hostname

And define the new name for the Raspberry Pi device.

Expand FileSystem

Another important option in the configuration is to expand the SD disk.In the same configuration screen, select

  • 7. Advanced Options
  • Expand File System

Now we need to reboot and after the reboot the file system should have been expanded to include all available space on your micro-SD card. Reboot with the command

sudo reboot

Update the device

Of course, at this moment you should change your default password and update everything with a command like this one

sudo -- sh -c 'apt-get update; apt-get upgrade -y; apt-get dist-upgrade -y; apt-get autoremove -y; apt-get autoclean -y'

Conclusion

And that’s it, we have our device updated and running with the latest software versions and we didn’t use a monitor! I’ll update this post frequently to make it relevant with my personal best practices.

Happy coding!

Greetings

El Bruno

References

My posts on Raspberry Pi

Dev posts for Raspberry Pi
Tools and Apps for Raspberry Pi
Setup the device
Hardware