LogoLogo
qoitech.com
  • Welcome
  • Otii PRODUCT SUITE
    • Overview
      • What’s included
    • Otii hardware
      • Otii Arc Pro
      • Otii Ace Pro
    • Otii software
      • Otii 3 Desktop App
      • Otii Toolbox
        • Otii Battery Toolbox [BT]
        • Otii Automation Toolbox [AT]
  • Otii SETUP
    • Connecting Otii hardware
      • Otii hardware overview
        • Otii Arc Pro overview
        • Otii Ace Pro overview
      • Wiring up
        • Expansion Port
        • Measuring DUT
        • Measuring a subsystem
        • External power source
        • Capture UART logs
    • Installing Otii software
      • Windows 10/11 setup
      • macOS setup
      • Ubuntu setup
      • Raspberry Pi setup
    • Getting started
      • Account & licensing
        • Activation & Licensing
        • Managing Licenses
      • User interface overview
        • Main window layout
        • Keyboard navigation
      • Support resources
  • Otii 3
    • Settings overview
    • Working with projects
      • Project storage
      • Create a new project
      • Save & open a project
      • Import an Otii 2.0 project
      • Export recordings as CSV
    • Control
      • Otii Arc/Ace setup
      • General settings
      • Channels
      • UART
      • Firmware management
      • Calibration
    • Recordings
      • Recording management
      • Recording tools
      • Recording viewers
        • Analog
        • Digital
        • Log
    • Measurements
    • Battery life estimator
    • Otii Battery Toolbox
      • Battery emulation
      • Battery profiler
        • Getting started with battery profiling
      • Battery validation
      • Battery Model Parameters
    • Otii Automation Toolbox
      • Otii TCP Server
      • Otii 3 Desktop App
      • Otii Server
      • User management
    • Additional features
      • User management
      • Show monitor
      • Notifications
    • Online account manager
  • Advanced guides
    • Python scripting
    • C# scripting
    • Jenkins integration
  • HELP & FAQ
    • FAQ
      • Otii Arc Pro
      • Otii Ace Pro
    • Revision history
  • Legal information
    • Product safety
    • Liability disclaimer
Powered by GitBook
On this page
  • Installing the Python client
  • Running the TCP Server
  • Automate measurements

Was this helpful?

Export as PDF
  1. Advanced guides

Python scripting

PreviousOnline account managerNextC# scripting

Last updated 7 months ago

Was this helpful?

These features require an Automation Toolbox license.

Otii has a build in TCP Server that can be used to control the application from another application, e.g. from a script running in your C.I. environment.

You can write your own TCP client using the Otii , or use one of the clients available at the Qoitech .

In this guide we will show you how to control Otii from a Python application using the .

You can find out more about how to get started with the TCP server here:

Installing the Python client

You can install the python client using pip:

python3 -m pip install otii_tcp_client

Running the TCP Server

You need to have Otii TCP Server running, either using the Otii desktop client or the Otii command line interface. You can read about it here:

For this example we also expect the server to be logged in, and that an Automation Toolbox licenses is already reserved. You can read more about logging in and reserving licenses here:

Automate measurements

Let us create a python script, e.g. otii_measurement.py. The first thing we need to do is include the Otii python client:

#!/usr/bin/env python3
import time
from otii_tcp_client import otii_client

The next step is to establish a connection with Otii TCP Server. Here we are assuming the TCP Server is running on the same computer and using the default TCP port.

client = otii_client.OtiiClient()
otii = client.connect()

After we are connected, we want to make sure that there is exactly on device connected to Otii, and get the handle to this device. We also make sure the device is added to the current project.

devices = otii.get_devices()
if len(devices) != 1:
    raise Exception(f'Expected to find exactly 1 device, found {len(devices)} devices')
device = devices[0]
device.add_to_project()

For this script we want to make one 10 second recording of the main channels of the Arc connected. We want each run to add the recording to the existing project, so that we later on can compare them.

project = otii.get_active_project()

Next step is to configure the Otii Arc/Ace for our project. In this case the device is normally running on a coin-cell battery, so we set the main voltage to 3.0. We want to use the high accuracy measurement (low range), and we want to measure the main current (mc) and the main voltage (mv).

device.set_main_voltage(3.0)
device.set_max_current(0.5)
device.enable_channel("mc", True)
device.enable_channel("mv", True)

Now we can start a recording, turn on the power and sleep for 10 seconds, and then turn off the power and stop the recording.

project.start_recording()
device.set_main(True)

time.sleep(10.0)

device.set_main(False)
project.stop_recording()

And finally we disconnect from Otii TCP Server.

otii.disconnect()

And that's it, a short script to automate recordings.

You find more examples here:

TCP Server API
Github
Otii TCP Client for Python
Automation Toolbox
TCP Server API
Otii TCP Server
User management
Otii TCP Client for Python