I'm kind of writing this blog as I'm going along, so this is going to be the ugly blog post where I put all of my notes when I set up the software.
- Connect to the WiFi
- Set up localization settings (time zone will be important, since my research requires me to cancel out some rotation induced by the earth's orbit around the sun and the exact time is important in determining how Stanford's normal vector is aligned relative to the solar plane. Also, keyboard layouts differ slightly between USA and Britian, and the makers of Raspberry Pi live in Britain)
- Do a system software update, because having up-to-date software makes it easier to use other people's code.
If you use Python at all, you've heard of pip. If you've done scientific python, you've heard of conda. Conda is a Package manager that's designed to do even more than pip, and so you should try to make this your default package and environment manager.
To install conda on your Pi, open up a terminal, and type in
wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-armv7l.sh bash Miniconda3-latest-Linux-armv7l.sh
Next, you'll need to update your environment by either restarting the terminal (close and open a new one), or by running
If everything is working correctly, when you type in
python --version, you should get something like
Python 3.4.3 :: Continuum Analytics Inc. If you didn't get that (or something like Python 2.7), then minconda didn't run correctly.
Python 3.4 is so 2014. It's 2019. We want f-strings. We want async. We want numpy >= 1.16.0. We just can't get this with the vanilla install of the Conda distribution for ARM7 architectures. Thanks to jjhelmus, we have access to something called berryconda, and a conda channel for raspberry pi. To get access to these enhacenments with your default conda install, you can type
conda config --add channels rpi
This will allow you to then install new versions of python. For example
conda create -n py36 python=3.6 source activate py36
I like working at my office setup (with three large screens) more than in my lab (my office chair is more comfy than my chair in the lab). I also frequently find myself having to make trips between my office (which is on the third floor) and my lab (which is in the sub-basment), and I don't like walking up and down the stairs. So we're going to set up some sort of remote desktop to monitor the Raspberry Pi remote, and perhaps even control instruments remotely.
To do this, we're going to open up some of the tools by typing
- Make sure that your password has been changed from the default password of "raspberry". If you don't, you're asking to be hacked, since every Raspberry Pi on the face of the earth ships with this default password.
- Next, open up SSH by going to the interfacing options, and clicking on SSH to enable SSH. Note, that you may have to talk to whoever runs your network and make sure that your firewall allows you to talk to the Raspberry Pi remotely over port 22. If your network administrator is reluctant to do this, there are workarounds like port tunneling, and ngrok.
- You might find it useful to change the name of your Pi through the raspi-config menu to something memorable. Perhaps the name of your lab followed by 'pi'.
- Make sure that you can connect to your pi remotely. You'll need to use something like Putty on Windows, or your terminal on your linux/Mac, and type "ssh firstname.lastname@example.org" or whatever your IP address is (you can get an IT person to help you here). You can also get the IP address of your pi by running
ifconfigand looking for your IP address near where it says "inet" for the interface you're using. It may be helpful to try to get a static IP address for your Pi, so that you don't have to get a new IP address each time you reboot your Pi. Also, note that once you have SSH enabled, you should be able to access remote hard drives using SFTP (via something like Transmit or FileZilla) over port 22, without having to enable some insecure FTP protocol like FTP. External hard drives are stored under /media in a Raspberry Pi.
- You can also set up VNC, which allows you to remotely control your desktop from another computer like your office computer. To do this, using
sudo raspi-configenable the VNC under the interface options. Then, use some remote desktop software to log into your raspberry pi remotely. I believe that windows has a remote VNC viewer built in, and for mac, you can download VNC Viewer for free.
Controlling your instruments
I'm a Student at Stanford, and I collaborate with the Mabuchi Group in Ginzton Lab on their Instrumental repo. There are other options as well, like Lantz and QCoDeS, but I'm going to document the instrumental setup, since it's the one I'm not most familiar with, and the one that I have the most control over (and it's also the most Stanford-ish thing to do).
Per the installation instructions:
pip install instrumental-lib
or, if you want the most recent unstable build,
pip install git+https://github.com/mabuchilab/Instrumental
Note that if you want to install all of this inside of a conda environment, you'll need to activate the conda environment each time you open up the shell using something akin to
source activate py36
If you want to use the NI DAQ module, you'll have to run these commands (the first installs the cffi dependency, and nicelib contains pythonic wrappers for C libraries used by instrumental):
sudo apt-get install libffi-dev pip install nicelib
install pyvisa # Not sure if the first one is necessary install pyvisa-py
python -m visa info
In my case, I needed to run
pip install PyUSB pip install pyserial
Somewhere mention tmux
Working through this tutorial