Metadata-Version: 2.1
Name: apogee-connect-rpi
Version: 0.2.1
Summary: Automates data collection with Bluetooth sensors from Apogee Instruments, Inc. using a Raspberry Pi
Author-email: "Apogee Instruments, Inc." <developer@apogeeinstruments.com>
License: MIT License
        
        Copyright (c) 2024 Apogee Instruments, Inc.
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX :: Linux
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: python-crontab
Requires-Dist: bleak
Requires-Dist: asyncio
Requires-Dist: filelock
Requires-Dist: packaging
Requires-Dist: requests

# Apogee Connect for Raspberry Pi 

Apogee Connect for Raspberry Pi is a lightweight script intended for automating the data collection process with Apogee's Bluetooth sensors. This command line application will automatically collect data from an Apogee Bluetooth sensor and store the data in a .csv file with various configurable options.

## Table of Contents
- [Introduction](#introduction)
- [Installation](#installation)
   - [Prerequisite](#prerequisite)
   - [Installation](#installation-1)
   - [Update](#update)
   - [Uninstall](#uninstall)
- [Basic Example](#basic_example)
- [Commands](#commands)
   - [collect](#collect)
   - [config](#config)
   - [list](#list)
   - [scan](#scan)
   - [stop](#stop)
   - [version](#version)
   - [help](#help)
- [Contact](#contact)

## Installation

### *Prerequisite*

In order to install Apogee Connect for Raspberry Pi, you will need pip (the package installer for Python). Pip is likely already included by default on a Raspberry PI or if you installed Python from source or with an installer from python.org. You can confirm pip is installed by running the command:

`pip --version`

If pip isn't already installed, visit the following site for instructions on a simple pip installation:

[https://pip.pypa.io/en/stable/installation/](https://pip.pypa.io/en/stable/installation/)

### *Installation*

1) We recommend installing the app onto a Raspberry Pi using pipx, a tool that uses pip in order to install stand-alone command line applications in an isolated environment that won't affect or be affected by other installations. In terminal, run the following command (It may be necessary to close and restart the terminal after installing pipx for it to be recognized):

`sudo apt install pipx`

2) Install Apogee Connect for Raspberry Pi from the Python Package Index by running the following command in terminal:

`pipx install apogee-connect-rpi`

3) Add the install location to your PATH environment variables so that it can be run from anywhere in the terminal.

`pipx ensurepath`

4) Verify installation by running the following command (It may be necessary to close and restart the terminal first for the changes to take effect):

`apogee --version`

#### *Update*

Whenever updates are available, the app can be updated simply by running the following command in terminal:

`pipx upgrade apogee-connect-rpi`

#### *Uninstall*

To uninstall, run the following command in terminal:

`pipx uninstall apogee-connect-rpi`


## Basic Example

Note: `apogee` is the command that can be run from the terminal at any location to use the app.
 
1. Scan for nearby Apogee sensors to obtain sensor's MAC address required for connection.

`apogee scan`

2. Start collecting data from the sensor with the MAC address of AA:BB:CC:DD:EE:FF and set a logging interval of 10 minutes.

`apogee collect AA:BB:CC:DD:EE:FF --interval 10`
 
3. See a list of all currently collecting sensors along with the number of logs currently collected, data file location, start/end time, etc.

`apogee list`
 
4. Stop data collection from the sensor with the MAC address of AA:BB:CC:DD:EE:FF, but not until the epoch timestamp of 1726247820 (Unix timestamp in seconds).

`apogee stop AA:BB:CC:DD:EE:FF --end 1726247820`


## Commands

*Key:*

`apogee command <required_argument> [--optional_arguments (default: value)]`


### collect

*Usage*

Automatically collect data from an Apogee sensor and write the data to a csv file (All data is also logged in the sensor's internal memory and is automatically recovered in the event of an interruption in connection at the time of collection).

*Example*

`apogee collect E8:63:32:06:6D:7D  --interval 10 --start 1720647720 --end 1721250915 --file /usr/documents/greenhouse-data.csv --append`

*Documentation*

`apogee collect <MAC address> [--interval (default: 5)] [--start (default: Now)] [--end (default: Never)] [--file (default: ./data/MAC_address.csv)] [--append]`

| Argument | Default Value | Usage |
| -------- | ------------- | ----- |
| Mac Address| N/A (required) | MAC address of sensor in the format of AA:BB:CC:DD:EE:FF |
| -i, --interval | 5 minutes | Collect data every set number of minutes (must be a positive integer) |
| -s, --start | Now | Start time for data collection using epoch time (Unix timestamp in seconds) |
| -e, --end | Never | End time for data collection using epoch time (Unix timestamp in seconds) |
| -f, --file | ./data/MAC_address.csv | File path to write data to csv file. Will create folders and files is they don’t exist. |
| -a, --append | N/A | Add this flag to automatically append data to the file if it exists instead of overwriting. |  


### config

*Usage*

Change or view the application settings.

*Example*

`apogee config --filepath /usr/documents/live-data --precision 4 --temp F --par-filtering True`

`apogee config --reset`

*Documentation*

`apogee config [--filepath (default: ./data/)] [--precision (default: 2)] [--temp (default: C)] [--par-filtering (default: False)] [--collection-frequency (default: 5)]`

| Argument | Default Value | Usage |
| -------- | ------------- | ----- |
| (N/A)| (N/A) | If no optional arguments are provided, the current configuration will be displayed. |
| -f, --filepath | ~/Apogee/apogee-connect-rpi/data/ | The default folder to save collected data. Adjust to avoid needing to specify full filepath every time data collection is initiated. |
| --p, --precision | 2 | Maximum number of decimal places for live data. |
| -t, --temp | C | Change preferred temperature units. Enter “C” for Celsius and “F” for Fahrenheit (without quotations). |
| -pf, --par-filtering | False | Filter negative PAR (PPFD) values to compensate for sensor "noise" in low-light conditions. Enter "True" or "False" (without quotations). |
| -cf, --collection-frequency | 5 | Frequency in minutes to check for new data logs and add to .csv data file (This is different than the data logging interval for the sensor). Must be between 5 - 60 minutes. |
| -r, --reset | N/A | Add this flag to reset configuration back to default values. |

### list

*Usage*

List all the sensors currently collecting data.

*Example*

`apogee list`

*Documentation*

`apogee list`


### scan

*Usage*

Scan for nearby Apogee sensors

*Example*

`apogee scan --time 10`

*Documentation*

`apogee scan [--time (default: 5-20)]`

| Argument | Default Value | Usage |
| -------- | ------------- | ----- |
|-t, --time | 5-20 | Number of seconds to scan for Apogee Bluetooth sensors. If not set, scanning will continue until no new sensors are being discovered or a maximum of 20 seconds. |


### stop

*Usage*

Stop data collection from an Apogee sensor. Can optionally use the `--all` flag to stop data collection from all Apogee sensors instead.

*Example*

`apogee stop E8:63:32:06:6D:7D  --end 1724428813`

`apogee stop --all`

*Documentation*

`apogee stop <MAC address> [--end (default: now)]`

| Argument | Default Value | Usage |
| -------- | ------------- | ----- |
| MAC address | N/A (required) | MAC address of sensor in the format of AA:BB:CC:DD:EE:FF (Required unless the '--all' flag is used). |
| -e, --end | Now | End time for data collection using epoch time (Unix timestamp in seconds). Cannot be used when using the '--all' flag. |
| -a, --all | N/A | Stop data collection for all sensors (Can be used instead of the MAC address requirement).|


### version

*Usage*

Show current application version

*Example*

`apogee --version`

*Documentation*

`apogee --version`


### help

*Usage*

Show help menu for entire application or for specific command, depending on usage

*Example*

`apogee --help`

`apogee collect --help`

*Documentation*

Entering just `--help` (or `-h`) will show a high-level overview of available commands.
Entering a command followed by `--help` will show a menu with required and optional arguments.
Any unrecognized command will also print the high-level overview help menu.

## Contact

For more information or additional help, contact Apogee Instruments at: [techsupport@apogeeinstruments.com](mailto:techsupport@apogeeinstruments.com) or [+1(435)245-8012](tel:+14352458012)
