sts1-sensors¶
Streamline the process of handling sensors for the STS1 project.
The following sensors are available both on the satellite and on the EDU module:
ADXL345
- Digital accelerometer.BME688
- Pressure, humidity, temperature and gas sensor.BMM150
- Geomagnetic sensor.L3GD20H
- Three-axis gyroscope.TMP112
- High-accuracy temperature sensor.
The following sensors are available on the satellite only:
GUVA_C32
- Ultraviolet light sensor.
Quickstart¶
from sts1_sensors import ADXL345, BME688, BMM150, L3GD20H, TMP112
# Accelerometer
accel = ADXL345()
x, y, z = accel.get_g()
print(f"{x=:.2f} g, {y=:.2f} g, {z=:.2f} g")
# Temperature, pressure, humidity and gas sensor
multi = BME688(enable_gas_measurements=True)
t = multi.get_temperature()
p = multi.get_pressure()
h = multi.get_humidity()
heat = multi.get_heat_stable()
res = multi.get_gas_resistance()
print(f"{t:.2f} °C, {p:.2f} hPa, {h:.2f} %RH, {heat=}, {res:.2f} Ohms")
# Geomagnetic sensor
mag = BMM150()
x, y, z = mag.get_magnetic_data()
print(f"{x=:.2f} µT, {y=:.2f} µT, {z=:.2f} µT")
print(f"Heading: {mag.get_heading():.2f}°")
# Gyroscope
gyro = L3GD20H()
x, y, z = gyro.get_dps()
print(f"{x=:.2f} dps, {y=:.2f} dps, {z=:.2f} dps")
# Temperature sensor
temp = TMP112()
print(f"{temp.get_temp():.2f} °C")
More examples, see examples folder.
Installation¶
Initial Setup on the Raspberry Pi¶
Open a terminal on the Raspberry Pi (e.g. via SSH).
Activate the I2C interface:
sudo raspi-config
Reboot
sudo reboot now
then reconnect.Run
sudo apt-get install i2c-tools
Run
ls /dev/i2c*
. Note the last number that apprears. E.g. for/dev/i2c-1
this would be1
.Run
i2cdetect -y 1
. You may change that last number according to what you saw in the previous step.If you see a grid of dashes
--
with some numbers, this means some sensors were recognized and you are good to go. For example:
flo@raspberrypi:~ $ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: 10 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- --
50: -- -- -- 53 -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- 6a -- -- -- -- --
70: -- -- -- -- -- -- 76 --
Installing the Python Package on the Raspberry Pi¶
If you want the latest stable version, install it like so:
pip install sts1-sensors
For Developers¶
Install just:
curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to ~/bin
Add it to
~/.bashrc
:export PATH="$PATH:$HOME/bin"
Install the package manager uv:
curl -LsSf https://astral.sh/uv/install.sh | sh
Add its path to your
~/.bashrc
such that the commanduv
is available:export PATH=$HOME/.local/bin:$PATH
Clone this repo:
git clone https://github.com/SpaceTeam/STS1_sensor_libraries
Switch into the directory.
Run
uv sync --all-extras --dev
. This creates a.venv
folder and installs all necessary dependencies.(Only on Raspberry Pi) Run
pytest