Skip to main content

General sensor handler, read sensor & do somethings (send, save, trigger, ...) with the value.

Project description


General purpose sensor handler, read sensor & do somethings (send, save, trigger, ...) with the value.

What is pondslider

The pondslider is a python module to read sensor values by Sensor handler, and do somethins with the value by Value handler.

What is pondslider for?

The pondslider is for making IoT device side project quickly by reusing existing codes.

  • Reusing existing Sensor reading code through unified interface provided by Sensor handler mention later.
  • Reusing existing Value handling code through unified interface provided by Value handler mention later.

How the pondslider work?

First, the pondslider read a configration file to specify:

  • Which sensors shoul be read.
  • Which values are returned by specific sensor.
  • What shoud it do for each value.

Then, pondslider get sensor values through specific sensor handlers, and call value handlers which is related.

What is Sensor handler?

The Sensor handler is a python module which wrap existing sensor value reading code to provide unified interface as follows:

  • unified read() function Sensor handler unifies various function call of sensor value reading on the existing codes as read()

  • well-formed return value: The read() function return a python dictionally of name and value pairs as follow:

{'humiditydeficit': 15.9, 'temp': 26.8, 'humidity': 37.6}

Typically, a sensor handler is created as a wrapper module of exising python module of sensor reading as:

import SomethingExistingSensorModule

def read():
  a_sensor =
  values   =
  return adjust_the_format(values)

def adjust_the_format(value)
  ''' adjst the format of value as a dictionaly of name & value pair. '''

In other case, with external executable file,

import subprocess

def read():
  p = subprocess.Popen("./SomethingExistingExecutable2GetSensorValue",
  std_out, std_err = p.communicate(None, timeout=20)
  value = std_out.strip()

def adjust_the_format(value)
  ''' adjst the format of value as a dictionaly of name & value pair. '''

Of cource, It's OK to make Sensor handler as reading sensor value directory.

import serial

def read():
  # mh-z19 CO2 sensor
    ser = serial.Serial(serial_dev,
    while 1:
      if len(s) >= 4 and s[0] == "\xff" and s[1] == "\x86":
        return {'co2': ord(s[2])*256 + ord(s[3])}

What is Value handler?

The Value handler is a python module which recieve sensor value, and do something with it, for example, send to server, write to strage, and so on. The purpose of valule handler is to provide a unified interface to handle acquired sensor value with following interface:

def handle(sensor_hander, data_name, value):

example handlers

example of handlers are available at


pip install pondslider


config.toml. The contents are expected as follows:

  handler   = "dht22"
    name = "temp"
    handlers = [
    name = "humidity"
    handlers = [
    name = "humiditydeficit"
    handlers = [

  handler   = "mh-z19"
    name = "co2"
    handlers = [

Each element of the array of table sources correspond to one actual data source like a Sensor Device and so on. Tha table is consist of ***handler *** and value.

  • handler: Python module of Sensor handler. The pondslider import this module dynamically and call function read() to get value. The returned value is expecte as a dictionally as key of value name and correcponding value like:

{'humiditydeficit': 15.9, 'temp': 26.8, 'humidity': 37.6}

  • values: The array of table corresponding to the python dictionally of values which is the returned value of read() mentioned above. The table is consist of name and handlers.
    • name: The key of dictionally of values like "humiditydeficit", "temp", "humidity" on the above example.

    • handlers: The array of Python module of Value handler's. The pondslider import these modules dynamically and call function handle(source_modlue, name, value) for each acquired value.

How to use

as python program.

usage: python -m pondslider [-h] [--config CONFIG] [--imppaths IMPPATHS [IMPPATHS ...]] [--interval INTERVAL]

optional arguments:
  -h, --help            show this help message and exit
  --config CONFIG       config file for handler specification.
  --imppaths IMPPATHS [IMPPATHS ...]
                        list of full path for python modules import path like
                        as "/home/pi/mh-z19" "/tmp/handler"
  --interval INTERVAL   minute of interval to repeat. no repeat in case not
                        set." .

The path specified by --imppaths is used ad additional Python import library path. With --interval option, pondslider repeat it in specified interval minutes. Without --interval, just run one time and quit.

as python library.

import pondslider

print (


Any questions, suggestions, reports are welcome! Please make issue without hesitation!


  • 0.1.1 2018.11.03 first version self-forked from sensorhandler.
  • 0.2.1 2018.11.06 add --interval option.
  • 0.2.2 2018.11.06 minor fix: remove redundant print

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pondslider, version 0.2.2
Filename, size File type Python version Upload date Hashes
Filename, size pondslider-0.2.2.tar.gz (4.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page