Skip to main content

Omega Smartsensor Python SDK

Project description

Omega Smartsensor Python SDK

This Python SDK allows you to communicate with Omega Smart Sensor devices via I2C interface or Modbus interface and easily integrate them to embedded platform such as Raspberry Pi, etc...

Requirements

Python 3.5+

Installation & Usage

PC Install

pip install

When installing python, ensure the option to add python to PATH is checked. If python is not part of the PATH, in command prompt change directory to the location of python.exe. Execute the pip install command.

python -m pip install omegasensor

Setuptools

Another method to install omegasensor. Clone from repository. And Install via Setuptools from source directory:

python setup.py install --user

Raspberry Pi Install

Setuptools

Clone from repository. And Install via Setuptools from source directory:

python3 setup.py install --user

Getting started

import time
from omegasensor import *  

def main():    
    bus = BusModbus('/dev/ttyUSB0', SMARTSENSOR_MODBUS_ADDR)   # for Modbus interface 
    # bus = BusI2C(1, SMARTSENSOR_I2C_ADDR) # for I2C interface
    ss = Smartsensor(bus)    

    ss.soft_reset()    
    ss.preset_config()    
    print("Firmware 0x%08x" % ss.read(R.FIRMARE_VERSION))    
    print("Device Id 0x%08x" % ss.read(R.DEVICE_ID))    
    print("Device %s" % ss.read(R.DEVICE_NAME))    
    sensor_cnt = ss.read(R.NUMBER_OF_SENSORS)    
    print("Onboard %d sensors" % sensor_cnt)    
    print("Onboard %d outputs" % ss.read(R.NUMBER_OF_OUTPUTS))    

    sensor_units = [ss.sensor_unit(i) for i in range(sensor_cnt)]    

    while True:    
        print("Time: ", ss.current_time_str())    
        for i in range(sensor_cnt):    
            print("%0.2f" % ss.sensor_reading(i),    
                  " %s" % sensor_units[i],    
                  "\t", end='')    
        print('\n')    
        time.sleep(1)    


if __name__ == "__main__":    
    main()  

Enable Software I2C interface:

(supports clock stretching for SmartSensor's I2C Interface)

Open config.txt

sudo nano /boot/config.txt

Add the following entry to the file

dtoverlay=i2c-gpio,bus=3

Save the file by hitting Ctrl+O. Enter. Reboot the Pi.

A new I2C interface can be found at /dev/i2c-3

SDA is BCM23 (header pin 16)

CLK is BCM24 (header pin 18)

Software I2C requires manual pull-up resistors of about 2.2k on SDA and CLK to Vcc. It may be possible to enable GPIO internal pull-up by the following commands:

# enable internal pull-up on pin BCM23
gpio -g mode 23 up
# enable internal pull-up on pin BCM24
gpio -g mode 24 up

Examples

Examples can be found in SDK Example directory

Hardware Setup

Omega BTH-SMP smart probes can be used with the I2C interface. On Raspberry Pi, here are the connections:

Raspberry Pi BTH-SMP
Pin 3 /BCM 2 SDA
Pin 5 /BCM 3 CLK
Pin 1 3.3V
Pin 6 GND

Alternatively, Omega Smart sensor dongle can be used which converts I2C interface to Modbus interface. On Linux system, the dongle will show up as /dev/ttyUSB0 or /dev/ttyACM0 for example.

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

omegasensor-0.5.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

omegasensor-0.5-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

Details for the file omegasensor-0.5.tar.gz.

File metadata

  • Download URL: omegasensor-0.5.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.2

File hashes

Hashes for omegasensor-0.5.tar.gz
Algorithm Hash digest
SHA256 1998894bc4ae363c96a4ba6003f861fca1ea6f5ced41765816f538518f8b695d
MD5 2f424695fd4ea7daef53dc3fbdcc970e
BLAKE2b-256 8742269e9966bca500c85e814f5d6d7dd00f6e0bdd5a779f7c19eb88ed5d3385

See more details on using hashes here.

File details

Details for the file omegasensor-0.5-py3-none-any.whl.

File metadata

  • Download URL: omegasensor-0.5-py3-none-any.whl
  • Upload date:
  • Size: 18.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.2

File hashes

Hashes for omegasensor-0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7d08ec0a7cb7941f57e29dd00c81bed69d7be095d62585665943435f23fdd845
MD5 adee98c00902722ddae501fa6afbdabd
BLAKE2b-256 039db6dc6054ea885120be227c9c02f007b72303862e043ef359e438f8cf5391

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page