The RasQberry project: Exploring Quantum Computing and Qiskit with a Raspberry Pi and a 3D Printer
For a detailed step by step and up to date installation and testing guide, please refer to the link here. The report linked provides additional information that is not necessarily covered in the Setup Guide below.
If you already have a Raspberry Pi with the latest version of Raspberry Pi OS you can start at step 2.
With the Raspberry Pi Imager write the Raspberry Pi OS Raspbian on an (empty) SD-Card. You can either choose the Image right from the Raspberry Pi Imager or you can first download Raspberry Pi OS.
(Optional) Do the default Setup of your Raspberry Pi by using
sudo raspi-config
For this you will need a Display or for a headless setup you’ll need to enable SSH.
You can enable SSH in different ways:
Headless (add file):
After you wrote the Raspbian Image on your SD-Card you need to add a file named “ssh” in your boot partition (boot register) of your SD-Card, which you can access on your personal computer.
When you added the file, you can now boot your Raspberry Pi.
Headless (with Imager):
When you write the Raspberry Pi OS on your SD-Card you can enable SSH with the writing process. You can access the extended menu when entering shift + command + X (windows: shift + control + X)
You can enable SSH and enter your password or public-key to make the authenticating process while connecting easier.
sudo raspi-config
Select 3 – Interface options
Select P2 – SSH
Next, you’ll need to get the IP address from the Raspberry Pi. You can find the address in your Router’s DHCP lease allocation table or if you use a display, you can get your IP address by typing ifconfig in your terminal.
Open a terminal on your remote device and enter
ssh pi@/{your IP address}
You need to agree that you want to connect your devices and enter your Raspberry Pi password (default: raspberry). Now you should be able to use SSH.
Open the terminal/ssh window on your Raspberry Pi.</br>
Move to the home directory of the user pi (/home/pi
). Not doing this will result in an error while installing and using the RasQberry.
You go there by typing cd
in the terminal. You can check your current working directory by typing in pwd
. </br>
Download and run the script using the following commands.
wget https://github.com/JanLahmann/RasQberry/raw/master/RasQ-init.sh
. ./RasQ-init.sh
This will download and start the RasQberry Configuration Tool (rasqberry-config) in your terminal. It is similar to the well-known raspi-config and can also be used for some basic configurations. To start the tool again you can use
. ./RasQ-init.sh
in your terminal/ssh window.
You can assemble your Hardware either with a (touch) display or with an senseHAT. It is not possible to use the senseHAT and the touch display on the same Raspberry Pi, because the senseHAT isn’t working with the installation process from the touch display.
Open the RasQberry Configuration Tool and follow the steps below.
S – RasQberry Setup
SU – System Update
IC - Initial Config
A – Advanced Config
then Q – Install Qiskit
D – Quantum Demos
then run BS – Bloch Sphere
and enable BlockSphere Autostart
After your first the executing D
then BS
your Raspberry will reboot automatically. After the reboot you should execute D
then BS
again. This time there is no automatic reboot, but one is recommended.
S - Rasberry Setup
then CD – Config & Demos
(optional)
Before the Raspberry Pi can boot with the SenseHAT attached you need to do some changes in the config.txt-file.
/boot/config.txt
Open the config.txt-file and uncomment the line
#hdmi_force_hotplug
Next, open the RasQberry Configuration Tool and follow the steps below.
S – RasQberry Setup
G0 – System Update
G1 – Initial Config
G2 – Install Qiskit
S0 – Config SenseHAT
The above installation procedure used pre-compiled wheel files for most of the python packages. These are downloaded automatically from Piwheels. For the packages retworkx and qiskit-aer, currently there are no whl files available. Total installation with local compile takes 10 minutes on RPi 4.
If you want to access IBM Quantum Experience (to use e.g. the senseHAT demos) you need an API Token.
If you want to update or store your API Token, you need to select D – Quantum Demos
first and after that D7 – Update Q Token
.
In the terminal you can now enter your new API Token.
By executing the following instructions you clone a repository with a collection of jupyter notebooks aimed at teaching people who want to use Qiskit for writing quantum computing programs, and executing them on one of several backends (online quantum processors, online simulators, and local simulators).
If you want to clone the Git Repository to access the with the Qiskit-Tutorials, you need to open the RasQberry Configuration Tool. First select H - HD Demos
and second Q1 - Qiskit Tutorials
(Jupyter Notebook starts automatically).
This will take a moment to clone and as the case may be to open the jupyter notebook.
You can disable the autostart of the BlochSphere Demo in the RasQberry Configuration Tool. First you need to select D – Quantum Demos
and then D8 – Disable Bloch Autostart
.
The autostart is now disabled.
If you got handed an SD-Card where the above described installation already is made and you want to connect the Raspberry with your network, you can do this in different ways.
In this panel you can enter your SSID and your wifi-password and select your Wi-Fi country.
When your boot your Raspberry Pi it should automatically connect to your Wi-Fi of choice.
Sudo raspi-config
Select 1 System Options
.
When you select S1 – Wireless LAN
you can enter your SSID and password.
With the wpa_supplicant.conf
-File before first boot
Before you first boot your Raspberry Pi you can change the wpa_supplicant.conf-File on your SD-Card. In this File you can set your SSID and the password.
Save the changes and exit the file.
wpa_supplicant.conf
-File after first boot sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
The file opens in your terminal/ssh window, and you can change the SSID and the password.
Save the changes and exit the file.
Accessories
.There is the option to configure a Hotspot which automatically activates when the configured WI-FI network (see wpa_supplicant.conf) is not available. This is done with the Autohotspot package. You can find more information about this package here: Raspberry Pi - Auto Wi-Fi Hotspot Switch Internet.
To activate and run the package, choose the options:
S – RasQberry Setup
AH - Install AutoHotspot
1
is recommended)8
Prerequisites:
/home/pi
. ./RasQ-init.sh
S – RasQberry Setup
option and hit <Select>
button
DV Configure Desktop and VNC
option and hit <Select>
button
Desktop and VNC are enabled
message once it’s successfully enabled the vnc server
To connect your LED light, you need three cables (GND, VCC & IN). Put your cables on the Raspberry Pins as follows:
You can check which Pin on your Raspberry is the right one, with
pinout
in your terminal/ssh window.
Open your terminal/ssh window and type
sudo python3 .local/bin/rq_LED-test.py -c
Your LED Light should now be turned on. To turn it off press ctl + c.
If this method doesn’t work, you can also open the RasQberry Configuration Tool. Select S – RasQberry Setup
, then S7 – Enable LED Light
and finally S8 – Toggle LED Light
.
Your LED Light should now be turned on. To turn it off again select S8 – Toggle LED Light
again.