Skip to content

fossasia/pslab-app

Repository files navigation

PSLab Android App

Repository for the PSLab Android App for performing experiments with the Pocket Science Lab open-hardware platform.

Build Mailing List GitHub repo size Gitter Twitter Follow

This repository holds the Android App for performing experiments with PSLab. PSLab is a tiny pocket science lab that provides an array of equipment for doing science and engineering experiments. It can function like an oscilloscope, waveform generator, frequency counter, programmable voltage and current source and also as a data logger. Our website is at https://pslab.io.

Sign up for the latest updates and test new features early by joining our beta program here.

Get it on Google Play Get it on F-Droid

Buy

Communication

Roadmap

  • First we need to get communication between Android App and PSLab working.
  • Implement Applications and expose PSLab Hardware functionality to the user.
  • Implement wireless connectivity

Screenshots

Image Image Image Image
Image Image
Image Image Image Image
Image Image
Image Image Image Image
Image Image Image Image
Image Image Image Image
Image Image Image
Image Image

Video Demo

Features

Feature Description Status
Home Screen Show status and version of PSLab device ✔️
Instruments Exposes PSLab instruments like Oscilloscope, etc ✔️
Oscilloscope Shows variation of analog signals ✔️
Multimeter Measures voltage, current, resistance and capacitance ✔️
Logical Analyzer Captures and displays signals from digital system ✔️
Wave Generator Generates arbitrary analog and digital waveforms ✔️
Power Source Generates programmable voltage and currents ✔️
Luxmeter Measures the ambient light intensity ✔️
Barometer Measures the Pressure ✔️
Accelerometer Measures the acceleration of the device ✔️
Gyrometer Measures the rate of rotation ✔️
Compass Measures the absolute rotation relative to earth magnetic poles ✔️
Thermometer Measures the ambient temperature ✔️
Gas Sensor Detects gases, including NH3, NOx, alcohol, benzene, smoke and CO2 ✔️
Robotic Arm Controller Allows to control 4 servo motors of the robotic arm independently ✔️

Development Environment Setup

Project Overview

This is a Flutter cross-platform application that supports:

  • Android (primary platform)
  • iOS
  • Linux (with USB device support)
  • macOS
  • Windows
  • Web

The app interfaces with PSLab hardware devices via USB and provides scientific instrument functionality.

Required Software

Flutter & Dart

  • Flutter (stable channel)
  • Dart (bundled with Flutter)

Java

  • Java (LTS version required for Android builds)

Flutter SDK Setup

Install Flutter

macOS (via Homebrew)
brew install --cask flutter
Linux

Follow the official Flutter install guide for Linux: https://docs.flutter.dev/get-started/install/linux

Windows

Follow the official Flutter install guide for Windows: https://docs.flutter.dev/install/windows

Flutter development setup (VS Code)

The instructions below explain how to install the Flutter SDK, set up Visual Studio Code with the Flutter and Dart extensions, and run the project using flutter run. These steps avoid Android Studio-specific instructions and focus on a minimal, cross-platform Flutter workflow.

Prerequisites

  • A supported operating system (Windows, macOS, or Linux).
  • A working internet connection to download the Flutter SDK and extensions.
  1. Install the Flutter SDK
  • Download the Flutter SDK from https://flutter.dev and follow the platform-specific instructions. On Windows, extract the SDK (for example to C:\src\flutter) and add the bin folder to your PATH environment variable. On macOS/Linux, follow the steps on the Flutter website for adding flutter to your PATH.
  • After installation, open a terminal (PowerShell on Windows) and run:
flutter --version
flutter doctor

Resolve any missing components suggested by flutter doctor. If you plan to build desktop apps, follow the platform-specific toolchain steps suggested by flutter doctor (e.g., install Visual Studio on Windows for Windows desktop builds).

  1. Set up Visual Studio Code
  • Install VS Code (if you don't have it) and open the project folder in VS Code.
  • Install the following extensions from the Extensions view:
    • Flutter (includes the Dart extension)
    • Dart (if the Flutter extension did not install it automatically)
  • (Optional) If VS Code cannot find the Flutter SDK, set the dart.flutterSdkPath setting to the SDK location in your VS Code settings.
  1. Prepare the project and run
  • In the project root, fetch packages and generate any code:
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs  # if the project uses code generation
  • Run the app on the default device (emulator, connected device, or desktop target):
flutter run

If you want to run on a specific device, list available devices and pass -d:

flutter devices
flutter run -d windows   # example: run on Windows desktop

Notes and troubleshooting

  • If you see issues related to missing SDKs or tools, run flutter doctor and follow the recommended fixes.
  • Building Android APKs or running on Android devices may require Android SDK tools. If you need Android targets later, install the Android SDK separately; Android Studio is not required for Flutter development but can simplify SDK installation.
  • For fast iteration in VS Code, use the Debug panel (press F5) or the Flutter toolbar (Run and Debug).

Application Flavors

Verify Flutter Installation

flutter doctor
flutter --version

Android Development Setup

Android Studio is optional - you can use command-line tools instead.

Option 1: Android Studio (Recommended)

  1. Install Android Studio
  2. Install Android SDK and accept licenses:
flutter doctor --android-licenses

Option 2: Command Line Tools Only

# Install Android SDK command-line tools
# Set environment variables
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

Android Requirements:

  • Android SDK (stable)
  • Java (LTS version)
  • See Android configuration in the project Gradle files.

iOS Development Setup (macOS only)

Requirements:

  • Xcode
  • CocoaPods
  • iOS deployment target is defined in the project configuration.
# Install CocoaPods
sudo gem install cocoapods

# Install iOS dependencies
cd ios && pod install && cd ..

Linux-Specific Setup

USB Device Access for PSLab Hardware:

# Install udev rules for PSLab devices
sudo cp linux/99-pslab.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules
sudo udevadm trigger

# Add user to dialout group for serial access
sudo usermod -a -G dialout $USER
# Log out and back in for group changes to take effect

Supported PSLab Devices:

  • PSLab v5: VendorID 04d8, ProductID 00df
  • PSLab v6: VendorID 10c4, ProductID ea60

Project Setup

  1. Clone repository:
git clone https://github.com/fossasia/pslab-app.git
cd pslab-app
  1. Install dependencies:
flutter pub get
  1. Platform-specific setup:
# iOS (macOS only)
cd ios && pod install && cd ..

# Android - no additional steps needed

Android permissions used

The app requires these permissions (configured in AndroidManifest.xml):

Android:

  • ACCESS_FINE_LOCATION / ACCESS_COARSE_LOCATION - GPS logging
  • RECORD_AUDIO - Audio oscilloscope functionality
  • INTERNET - Connectivity features
  • READ_EXTERNAL_STORAGE / WRITE_EXTERNAL_STORAGE - Data logging
  • android.hardware.usb.host - PSLab device communication
  • android.hardware.sensor.ambient_temperature - Temperature sensors

Key Dependencies

Hardware Communication:

  • usb_serial
  • flusbserial

Sensors & Hardware:

  • sensors_plus
  • light
  • geolocator
  • permission_handler

Audio Processing:

  • flutter_audio_capture (Git dependency) - Audio capture for oscilloscope

Running the Application

Development

# List available devices
flutter devices

# Run on connected device
flutter run

# Run with hot reload
flutter run --debug

Building for Release

# Android APK
flutter build apk --release

# Android App Bundle (for Play Store)
flutter build appbundle --release

# iOS (macOS only)
flutter build ios --release

# Linux
flutter build linux --release

Testing

# Unit tests
flutter test

# Integration tests
flutter test integration_test/

Troubleshooting

Common Issues:

  1. USB permissions on Linux:

    • Ensure udev rules are installed: ls -la /etc/udev/rules.d/99-pslab.rules
    • Check user is in dialout group: groups $USER
  2. Flutter version mismatch:

    flutter channel stable
    flutter upgrade
    flutter pub get
  3. iOS build issues:

    cd ios
    pod deintegrate
    pod install
    cd ..
    flutter clean
    flutter pub get
  4. Android build issues:

    • Ensure an LTS Java version is installed: java -version
    • Clean build: flutter clean && flutter pub get
  5. Git dependency issues:

    flutter pub deps
    flutter pub get

Verify Setup

Follow the steps below to confirm that your local development environment is correctly configured.

1. Check Flutter installation

flutter doctor

Resolve any critical issues reported by the command.

2. Install dependencies and run tests

flutter pub get
flutter test

3. Run the application

flutter run

Run the app on a connected physical device, emulator, or desktop target.

4. (Optional) Using Android Studio

If you prefer Android Studio:

  • Open the project directory in Android Studio.
  • Wait for the Gradle sync to complete.
  • Check the Build and Run windows for errors.

Note: If you encounter a Gradle sync error such as “failed to find …”, use the suggested action (for example, Install missing platform(s) and sync project) to allow Android Studio to download the required components.

Once the app builds successfully and launches on your target device or emulator, the setup is complete.

The currently supported Flutter, Dart, and platform versions are defined in the project configuration files (for example pubspec.yaml, Android Gradle files, and iOS project settings).

Permission manifests

Permissions are declared in the platform manifests:

  • Android: android/app/src/main/AndroidManifest.xml
  • iOS: ios/Runner/Info.plist

The app may request permissions at runtime depending on the instrument/features being used (e.g., location, microphone, storage, USB).

Setup to use PSLab with Android App

To use PSLab device with Android, you simply need an OTG cable, an Android Device with USB Host feature enabled ( most modern phones have OTG support ) and PSLab Android App. Connect PSLab device to Android Phone via OTG cable. Rest is handled by App itself.

Contributions Best Practices

Code practices

Please help us follow the best practice to make it easy for the reviewer as well as the contributor. We want to focus on the code quality more than on managing pull request ethics.

  • Single commit per pull request.
  • Reference the issue numbers in the commit message. Follow the pattern Fixes #<issue number> <commit message>
  • Follow uniform design practices. The design language must be consistent throughout the app.
  • The pull request will not get merged until and unless the commits are squashed. In case there are multiple commits on the PR, the commit author needs to squash them and not the maintainers cherrypicking and merging squashes.
  • If the PR is related to any front end change, please attach relevant screenshots in the pull request description.

How to git squash?

As a tip for new developers those who struggle with squashing commits into one, multiple commits may appear in your pull request mostly due to following reasons.

  • Intentionally adding multiple commit messages after each change without just git adding.
  • Updating the current branch with the remote so a merge commit takes place.

Despite any reason, follow the steps given below to squash all commits into one adhering to our best practices.

  • Setup remote to upstream branch if not set before

$ git remote add upstream https://github.com/fossasia/pslab-app.git

  • Check into the branch related to the pull request

$ git checkout <branch-name>

  • Perform a soft reset to retain the changes while removing all the commit details

$ git reset --soft upstream/development

  • Add files to the staging area

$ git add <file paths or "." to add everything>

  • Create a new commit with a proper message following commit message guidelines

$ git commit -m "tag: commit message"

  • If you have already made a pull request

$ git push -f origin <branch-name>

Branch Policy

We have the following branches

  • development All development goes on in this branch. If you're making a contribution, you are supposed to make a pull request to development. Make sure it passes a build check on Travis.
  • master This contains the stable code. After significant features/bugfixes are accumulated on development, we move it to master.
  • apk This branch contains automatically generated apk file for testing.

Code style

Please try to follow the mentioned guidelines while writing and submitting your code as it makes easier for the reviewer and other developers to understand.

  • While naming the layout files, ensure that the convention followed is (activity/fragment) _ (name).xml like activity_oscilloscope.xml , fragment_control_main.xml .
  • Name the views and widgets defined in the layout files as (viewtype/widget) _ (fragment/activity name) _ (no. in the file) like spinner_channel_select_la1 , button_activity_oscilloscope1 .
  • The activity/fragment file name corresponding to the layout files should be named as (activity/fragment name)(activity/fragment).java like ChannelsParameterFragment.java corresponding to the layout file fragment_channels_parameter.xml .
  • The corresponding widgets for buttons, textboxes, checkboxes etc. in activity files should be named as (viewtype/widget)(fragment/activity name)(no. in the file) like spinnerChannelSelect1 corresponding to spinner_channel_select1 .

Developers

Maintainers

The project is maintained by

Alumni

License

This project is currently licensed under the Apache License 2.0. A copy of LICENSE is to be present along with the source code. To obtain the software under a different license, please contact FOSSASIA.