This library allows you to use the Ocean Optics ST-VIS range of spectrometers using a Raspberry Pi Zerro 2W and a LCD display to view spectra using the Seabreeze API. This allows for a very small low power package that can easily be integrated into a small handheld device for field work.
Lots of love to the the people working on keeping the PySeabreeze API alive. This let me get the Ocena Optic Spectrometer working on an ARM device.
sudo apt-get update
sudo apt-get upgrade
sudo apt install vim
sudo apt-get install git cmake
sudo apt install python3-RPi.GPIO
sudo apt-get install python3-numpy
sudo apt-get install python3-pil
sudo apt-get install git-all build-essential libusb-dev
sudo apt-get install p7zip-full -y
sudo apt-get install python3-matplotlib
sudo apt install libatlas-base-dev
sudo apt-get install python3-pip
sudo apt-get install python3-opencv
sudo apt install feh
sudo usermod -aG video pi
sudo usermod -aG i2c,gpio pi
Install Pyseabreeze.
cd
mkdir pysb
cd pysb
python3 -m venv --system-site-packages venv
source venv/bin/activate
pip install seabreeze[pyseabreeze]
seabreeze_os_setup
This script manages a spectrometer and camera system with an LCD display and button inputs.
It cycles through three states:
- IDLE (STATE_1) - Allows you to view WiFi info, date/time, or capture spectra.
- SPECTRA (STATE_2) - Captures a spectrum, plots it, and optionally saves data.
- CAMERA (STATE_3) - Allows capturing and saving a photo.
Install the LCD display drivers. May be missing stuff here as I didn't document it as I got it working. My bad.
wget https://files.waveshare.com/upload/b/bd/1.3inch_LCD_HAT_code.7z
7z x 1.3inch_LCD_HAT_code.7z -r -o./1.3inch_LCD_HAT_code
sudo chmod 777 -R 1.3inch_LCD_HAT_code
mv ~/pysb/1.3inch_LCD_HAT_code/1.3inch_LCD_HAT_code/python ~/pysb/lcd
cd /home/pi/pysb
source venv/bin/activate
cd 1_3_INCH_WAVESHARE_LCD_PI_GLOBAL_SHUTTER_CAM
python3 disp_spec_plot.py
ssh -X
sudo apt install feh
feh spectrum_20241212102529.png --auto-zoom --scale-down -g 600x600 -
cd pysb
vim run_spectrometer.sh
#!/bin/bash
# Navigate to the correct directory
cd /home/pi/pysb
# Activate the virtual environment
source venv/bin/activate
# Run the Python script
python3 disp_spec_plot.py
chmod +x /home/pi/pysb/run_spectrometer.sh
chmod +x /home/pi/pysb/disp_spec_plot.py
sudo nano /etc/systemd/system/spectrometer.service
[Unit]
Description=Spectrometer System Service
After=network.target
[Service]
Type=simple
User=pi
Group=pi
WorkingDirectory=/home/pi/pysb
ExecStart=/home/pi/pysb/run_spectrometer.sh
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
# Reload systemd to recognize the new service
sudo systemctl daemon-reload
# Enable the service to start at boot
sudo systemctl enable spectrometer.service
# Start the service now
sudo systemctl start spectrometer.service
# Check the status
sudo systemctl status spectrometer.service
To stop it at boot
sudo systemctl disable spectrometer.service
If it is currently running you can stop it
sudo systemctl stop spectrometer.service
To make changes to the service file:
sudo systemctl daemon-reload
sudo systemctl restart spectrometer.service
Add a voltage output to the display to monitor the lipo batteries.