Execution on Android

Prerequisites
  • Install Termux from F-Droid - Android terminal emulator and Linux environment.
  • Install Termux API from F-Droid - This addon exposes device functionality as API to command line programs in Termux
  1. Open Termux and update:

    pkg update && pkg upgrade

  2. Install required packages with

    pkg install python git termux-api

  3. Clone the Collectu repository:

    git clone https://github.com/core4x/collectu-core.git

  4. Create an api access token. Save the created token in the root directory (/collectu-core).

    You can switch directories with

    cd collectu-core

    You can create a file with

    touch api_access_token.txt

    You can change the content of the file with

    nano api_access_token.txt

  5. Switch to the src directory with

    cd src

    Run the app:

    python main.py

  6. Continue with our First Steps.
Info

To stop Collectu click CTRL + C

To stop Termux CTRL + D


Access Android Sensors

You can access built-in smartphone sensors using Termux API.

To list all available sensors execute:

termux-sensor -l

To gather sensor values in Collectu, implement the user_logic module using the following code:

import subprocess
import json

sensor_data = subprocess.check_output(["termux-sensor", "-s", "Gravity Sensor", "-n", "1"])
data.fields = json.loads(sensor_data)[0]['values']