This receiver for SID monitoring consists of a Raspberry Pi board running linux and my receiver software in python. The hardware section lists the minimal items needed for the system itself. In this setup, the Pi Zero W computer is not connected to a keyboard, mouse, or monitor. Another computer (the logging computer) is instead used to log into the Pi Zero through X11 windows and your home wireless network. One talks to the Pi Zero through terminal screens. Graphical output from the programs running on the Pi Zero can be displayed on the logging computer via X11. The logging computer does not need to be linux. It only needs to have an X11 server and an ssh client running on it. On windows these can be xming and putty, respectively.
The hardware section describes the hardware I am using, and the setup section gives the steps to set up linux and other software on the Pi Zero. It has taken a lot of fiddling to get the Pi Zero up and running, and I am hoping that being specific about hardware and software these instructions might shorten the path for those of you who like myself are not linux savvy.
Later sections explain how to run sidmon in the background, and to run it as a service. The latter ensures that sidmon restarts when the Pi Zero boots, which prevents missing blocks of time after power dropouts. Finally there is info on power consumption, noise from switching power supplies, running on a battery with or without a solar panel, and remote siting.
Minimal hardware for getting a Pi Zero W up and running over a wireless network. This configuration does not use a mouse or keyboard, but is instead controlled via ssh on a linux or windows computer (use ssh on linux, or, e.g., putty on a windows computer).
sudo cp wpa-supplicant.conf /media/<username>/boot sudo cp ssh /media/<username>/boot
ssh -Y pi@<ipaddress>The password is raspberry. From a windows computer with putty installed, use:
putty -X pi@<ipaddress>The switches enable X11 port forwarding.
sudo apt-get update && sudo apt-get upgrade -y sudo apt-get install software-properties-common sudo apt-add-repository universe sudo apt-get install python-pip python -m pip install -U pip # python 3 sudo apt install python3.7 python3.7-dev python3.7-venv sudo apt-get install python3-pip sudo apt-get install python3-numpy sudo apt-get install python3-matplotlib sudo apt-get install libasound2-dev sudo apt-get install python3-alsaaudio
$ python >>> import alsaaudio >>> alsaaudio.pcms()A list of sound devices should be printed. If not, then go to this link.
sudo shutdown nowUnplug the Pi Zero, plug in the sound card, and then reapply power. Log in as before. Note that with DHCP, the IP address may have changed.
arecord -LWith an Xonar U5, among many device entries it should show
... plughw:CARD=U5,DEV=0 ASUS XONAR U5, USB Audio Hardware device with all software conversions ...
alsamixer
/home/<user>/.local/lib/python2.7/site-packages/matplotlib/mpl-data/matplotlibrcwhere <user> is your user name. Look for the line
backend = aggIf present, replace it with
backend = TkAgg
config.py iputil.py noaa_flares.py sidfile.py sidsplit.py supersid_plot.py ftp_to_Standford.py Moments.py OrthPoly.py sidmon.py sound.pyNote that some of these files are associated with supersid_plot from the SuperSID distribution. Some of these files are modified significantly and are not interchangable with the originals.
Other packages and useful commands:
sudo apt-get install xbase-clients
which can be useful for testing X-windows (X11).
xeyes
sudo shutdown now
lsb_release -a # or uname -a
curl -O <url>
sudo apt-get install lynx
sudo pip3 install pandas
sudo apt-get install python3-scipy
sudo apt-get install ipython3
sudo apt-get install jupyter
sudo apt-get install python3-sympy
sudo apt-get install geanyFast and works over X11.
When running from a terminal, logging off or other disruption of the terminal session will kill sidmon. To avoid this problem, it is convenient to run sidmon in the backgound without connection to a terminal. Running without a terminal session is simple with nohup.
nohup /usr/bin/python sidmon.py <options> &When run this way the user can log off without stopping the program. The sidmon -lp switch should not be specified so that no live plot is generated. Make a note of the process ID so that the process can be stopped with the kill command later. Alternatively, the process ID can be learned later using the ps command. The process by the name python is likely the correct one.
ps -U pi PID TTY TIME CMD 428 ? 00:00:00 systemd 431 ? 00:00:00 (sd-pam) 1363 ? 1-10:36:32 python 4059 ? 00:00:00 sshd 4062 pts/0 00:00:01 bash 4169 pts/0 00:00:00 ps
Note in the earlier command that the path to the python interpreter might be different on other machines than shown.
vi /etc/init.d/sidmonand after Provides: in the file enter that name.
... Provides: sidmon ...
... dir="/home/pi" cmd="./sidmon.py -t 4.4" user="pi" ...Again make sure to enter the correct path to the sidmon directory and that the python path at the top of sidmon.py is correct on your Pi Zero (check with whereis python). If you are already running sidmon from the command line, you should enter that in the cmd variable. There are also places to change the locations for stdout, stderr, and a file for the process ID. You might wish to enter locations for those files more convenient than the defaults in the template.
sudo chmod +x /etc/init.d/sidmon sudo chown root:root /etc/init.d/sidmon
sudo update-rc.d sidmon defaults sudo update-rc.d sidmon enable
sudo /etc/init.d/sidmon startcheck the status using
sudo /etc/init.d/sidmon statusrestart the service (stop then restart) with
sudo /etc/init.d/sidmon restartand stop the service with
sudo /etc/init.d/sidmon stop
Measured current consumption while running sidmon oscillates between 0.41 and 0.47 mA at 5 V, including the Asus Xonar U5 sound card on the USB port.
To conserve power, switch off the LED, and see this link. There are other useful links in the latter.
To set the LED to undervoltage detect, enter
echo input | sudo tee /sys/class/leds/led0/triggerNote 'led0' instead of the 'led1' from the first link. The savings look to be only a few mA.
Powering off the HDMI port using the command
/usr/bin/tvservice -osaves about 15 mA.
With these reductions the average current consumption is about 0.42 A (2.1 W). This figure includes the wireless interface and the Xonar U5. Stopping sidmon dropped the current to 0.37 A, and halting dropped the current to 0.165 A.
To save power it might be possible to disable the wireless adapter except at a predetermined time.
sudo ifconfig wlan0 downand bring it back up for a time
sudo ifconfig wlan0 up
The CPU temperature is available in the file/sys/devices/virtual/thermal/thermal_zone0/temp. It can be useful to routinely log this temperature to a file as a means to monitor the receiver's environment. To do this:
*/5 * * * * <path>/temperaturewhere the digit '5' is the number of minutes between recorded readings.
cd <path> echo $(date -Iseconds) $(cat /sys/devices/virtual/thermal/thermal_zone0/temp) >> temperature.log exit 0where <path> is the path to the sidmon directory.
crontab temperatureschedule
CPU temperature reflects power consumption, and wireless and bluetooth power consumption can be measured by switching them on and off and monitoring the cpu temperature. If the power consumption turns out to be lower, then one can write a script that switches off wireless and bluetooth most of the day, and then switches them back on at a predetermined time to enable download of data and other activity on the Pi Zero. Not an ideal scheme, but it might be useful in a remotely sited Pi Zero.
Further information on sensors in linux systems. To install, enter
sudo apt install lm-sensorsTo look for sensors, run
sudo sensors-detectand note what sensors are found.
When run on a local area network (LAN) behind a modem, devices are ordinarily dynamically assigned IP addresses by the modem in the private domain, usually 192.168.x.x. A static (fixed) IP address on the LAN is a convenience in that it obviates the need to determine the Pi Zero's IP address. Your modem can be configured to provide one through its configuration menus. To do this first determine your Pi Zero's (or other sidmon host's) MAC address by entering on the sidmon host the command
ifconfig -wlan0 # for wireless interface, or ifconfig -a # for all interfacesOne of the interfaces will be the wireless or wired interface you are using. Note the MAC address of the form hh:hh:hh:hh:hh:hh associated with that interface, where 'h' refers to a hexadecimal character. Log into your modem and navigate to the page used to assign static DHCP addresses. On my ZyXEL DSL modem it is under Network Settings -> Static DHCP. Add a new entry and enter the MAC address you noted. Then choose a new static address in the DHCP address range configured for the modem and enter that address in its place on that configuration page. Make sure that that IP address does not conflict with a device currently on your network.