IMPBUS-2 Library

This library is a python implementation of the “Data transmission protocol for IMPBus2” called IMPBus2. IMPBus2 is a fieldbus system to which up to 250 single slaves may be connected by a bi-directional 2-wire line. The modules are controlled by the bus master, typically this is the host computer. Each computer with a standard RS-232 interface can be used as the bus master. The master is able to send a set of commands to the slaves, to start actions or to acquire data. The IMPBus-2 itself is interfaced by a special active adapter (SM23U or SM-USB, please contact the IMKO GmbH for more informations).

The communication is based on the transmission of address- and data blocks. The transmission itself uses asynchronous symbolic address-based and byte-based protocols. Up to 250 bytes of significant data can be transmitted bi-directional in one telegram.

This library is typically used to access TRIME Pico moisture measurements probes. It is tested for Python 2.7 - 3.6 running on Linux, Windows and MacOSX.

Requirements

Before you can start using the IMPLib2 software you have to make sure, that you have at least the following software packages installed.

For instructions on how to get and install these packages on your OS please head over to the official project pages.

Installation

Install the stable branch using pip:

pip install implib2

Of if you brave enough:

pip install git+https://github.com/mhubig/implib2.git@develop

Depending on your system you may have to prefix these commands with sudo!

Quick Start Manual

This small quick start manual is intended to give you a basic example of how to use this library. In order to start playing with it you have to connect at least one Trime Pico moisture measurement probe to your computer. An easy way to connect the probe is by using the USB-IMPBus Converter SM-USB.

After successfully installing IMPLib2 and connecting, start the Python Shell within your terminal:

$ python
Python 3.6.2 (default, Jul 17 2017, 16:44:45)
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

Import the IMPLib2 module:

>>> import implib2

Now initialize the IMPBus, sync and scan for connected Modules. Replace the USB Interface with the one your SM-USB uses:

>>> bus = implib2.Bus('/dev/ttyUSB0')
>>> bus.sync()
>>> bus.scan()
(10010, 10011)

As you can see we found two connected modules with the serial numbers 10010 and 10011. Now we can instantiate the module objects:

>>> mod10 = implib2.Module(bus, 10010)
>>> mod11 = implib2.Module(bus, 10011)

Using the handy module objects we can now perform various higher operations, like doing a measurement or requesting the serial number:

>>> mod10.get_moisture()
14.3
>>> mod11.get_moisture()
17.4
>>> mod10.get_serno()
10010

10011

If you came so far you should be able to easily build a little script which performs an measurement on all connected probes ones an hour:

#!/usr/bin/env python

import time
import implib2

# Initialize the IMPBus2
bus = implib2.Bus('/dev/ttyUSB0')
bus.sync()

# Search the bus for connected modules
modules = [implib2.Module(bus, serno) for serno in bus.scan()]

# Start a measurement and show the results once an hour
while True:
    for module in modules:
        serno = module.get_serno()
        moist = module.get_moisture()
        temp = module.get_measure(quantity='MeasTemp')
        print('Module {}: Moist {}, Temp {}'.format(serno, moist, mtemp))

    time.sleep(3600)  # for one hour

For more and in depth information please head over to the API-Documentation on Read the Docs.

Indices and tables

LICENSE

MIT License

Copyright (c) 2011-2017 Markus Hubig <mh@imko.de>

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.