Skip to content

overthesun/simoc-sam

Repository files navigation

SIMOC Live

This repository contains the code for the live backend used in SAM to collect live sensors data.

The configurations and scripts are generally installed and executed on Raspberry Pi 4/5 and 0s using the simoc-sam.py script.

Using the simoc-sam.py script

The repo contains a simoc-sam.py script used to simplify several operations. The script will automatically create a venv (virtual environment), install the dependencies, and run the commands inside the venv.

You can see the full list of commands with python simoc-sam.py -h, and you can run them with python simoc-sam.py COMMAND:

  • initial-setup will initialize an RPi 0 image
  • test will execute the tests using pytest
  • info will print host info about the network, sensors, and services
  • hosts will print information about the other hosts in the network

Using the venv manually

If you want to manually run some of the scripts inside the venv, you first have to activate the venv with source venv/bin/activate. You can execute commands after activating the venv is activated, and then leave the venv with deactivate.

Since the package is already installed within the venv, you can run the scripts by doing python -m simoc_sam.scriptname (see the TL;DR section for an example).

Installation and dependencies

If you are using the simoc-sam.py script, depending on the command, you might need some additional dependencies that can be installed with:

python3 -m pip install -r requirements.txt

Additionally, for the tmux/ scripts you will need to install tmux with sudo apt install tmux.

Docker container usage

Note: Docker deployment is no longer supported for the time being.

Connecting to the MQTT broker

The repository includes a SocketIO bridge and a SocketIO client (siobridge.py and sioclient.py) that can be used to test the MQTT->SocketIO conversion. They can both be launched (together with a Mock Sensor) by running python3 simoc-sam.py run-tmux mqtt.

TL;DR

This is a summary of the commands you need to run everything.

venv

Start everything with:

sudo apt install tmux
python3 simoc-sam.py run-tmux

Start the sensor(s)/client(s):

user@host:path$ source venv/bin/activate
(venv) user@host:path$ python -m simoc_sam.sensors.mocksensor -v
...
(venv) user@host:path$ deactivate
user@host:path$

You can run multiple sensors/clients on multiple terminal tabs (you have to activate the venv in each of them).

Testing

Run the tests in the venv with:

python simoc-sam.py test

About

Back-end system to support SIMOC Live air quality monitor sensor array as used at the SAM Mars habitat analog.

Resources

Stars

Watchers

Forks

Contributors

Languages