Skip to main content

The sniffer package is used on the Positive Degree sniffer and control boards. It gathers sensors data, can operate some board control and is used for remote updates.

Project description

Mark-II-sniffer

Small piece of software running on-board (Omega2S+) sniffers to gather sensors data and operate some board control.

MQTT publisher: live data

Running the pub_main.py starts a publisher client that will continually read the board's data via Modbus and send it to the .../system_data MQTT topic. The Modbus communication is done over Serial by default, but can be configured for TCP clients.

MQTT subscriber: update automation

Running the sub_main.py starts a subscriber client that listens on the .../update topic. When receiving a message on this topic, the update_sniffer.sh script will be called, executing a git pull and rebooting the module.

Setup on the Omega2S+

1. Configure the system timezone

We want to make sure that the onion is configured at the correct timezone for the data to be accurate.

  • List all the timezones with onion time list
  • Scroll through the available zones and copy the line that represents your
  • Set the correct timezone with onion time set <timezone> <timezone string>
  • For more details, you can follow this tutorial.

2. Install basic packages

  • Install python3 light with opkg install python3-light
  • Install git with opkg install git git-http ca-bundle
  • Install pip for python3 with opkg install python3-pip

3. Clone the repository and install requirements

The automation requires the omega to do a git pull when receiving an update. By using a personnal access token to clone the repository at first, we don't have to authenticate with git for subsequent pulls. Anyways, since 2020 using password-based authentication for Git is deprecated, and using a PAT is more secure. For more information, see Creating a personal access token.

  • Go to the root directory of the onion
  • Clone the repository with git clone https://ac7856efdf646a40d5d7b7a891e842b361b41b6d@github.com/Positive-Degree/Mark-II-sniffer.git
  • In the project folder, install the required libraries with pip3 install -r requirements.txt
  • If the app has to communicate modbus over TCP, install pymodbus with pip3 install -U pymodbus

4. Configure the app with the appropriate info

Some environment variables have to be configured into your environment for the application to work. (They can also be added in a .env file for development).

The necessary variables are listed in the .env.example file and can be sourced with bash. To make those variables persistent on a Linux system, add them in a bash (.sh) file in /etc/profile.d.

On the Onion, the python-dotenv library is used to read the environment variables for the script, so make sure you have a .env file that is populated with your configuration.

3. Start sniffer code on boot

The start_sniffer.sh contains the commands to launch the publisher and subscriber clients. Hence, we just have to call this script on boot to start them.

  • edit the /etc/rc.local file on the Omega
  • add the line sh /root/Mark-II-sniffer/scripts/start_sniffer.sh <mode> <protocol> &
  • the mode is either 'sniffer' or 'controller' and the protocol 'tcp' or 'serial'
  • If the app has to communicate modbus over TCP, we presume it won't run on the Onion. Hence, you can use the PM2 process manager or another method to start the script on boot/reboot for your system.

For further reference, see the full Onion documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sniffer-positivedegree-0.1.6.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sniffer_positivedegree-0.1.6-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file sniffer-positivedegree-0.1.6.tar.gz.

File metadata

  • Download URL: sniffer-positivedegree-0.1.6.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.13

File hashes

Hashes for sniffer-positivedegree-0.1.6.tar.gz
Algorithm Hash digest
SHA256 49ca3d5e5768a550b391ae4f272155bb1fb1afa5a095886e836992ac4d5ac63b
MD5 1891dc28f7eb6b9e397bd4c35b68fd2c
BLAKE2b-256 9710526b0a4346975e5a9c6bf290b592e97d13776dc5dca9bc697b1df28c226e

See more details on using hashes here.

File details

Details for the file sniffer_positivedegree-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: sniffer_positivedegree-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.13

File hashes

Hashes for sniffer_positivedegree-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ad2250d210ea328dadcaa5459c77f9c445d68cdd7e7146bcda4e53609e537d8a
MD5 5e07aa0a40eff677072517a195b0e0e0
BLAKE2b-256 47e29b9bbbc25068cebe35672a2df4f35360a7387f6c8b55ea31b9c611a991ff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page