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.7.tar.gz (21.5 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.7-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for sniffer-positivedegree-0.1.7.tar.gz
Algorithm Hash digest
SHA256 e1710fcab306a3f0c243f8528aa562bc092ba42bb7ba570d50d88fd124b12150
MD5 566347071b9992e16985d65d092036f9
BLAKE2b-256 af2ea08f791aab336fc321da2fb105eb00a0bde3379fbbab3809a6e54a0fa20d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sniffer_positivedegree-0.1.7-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.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.6.13

File hashes

Hashes for sniffer_positivedegree-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 5dfacf1c6751229ef532436f32f4b3afe4dcc07bcafa6a0e8976a50e20430b1b
MD5 f8b3c40b4de3b1d5247c9986d21b4259
BLAKE2b-256 863585dadd332ec0ad7b69ec3967165bd3ecf26fb76023e5b524559b9218b688

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