sdi12 Module provides SDI-12 examples

sdi12.py

The basis for SDI-12 communication is the command line command SDI, which may be used to issue any data on any SDI-12 bus on Satlink

exception sdi12.Sdi12Error
sdi12.sdi_bus_valid(sdi_bus)

Routine checks whether the provided parameter is a SDI-12 bus

Parameters:sdi_bus – string indicating bus: “Port1”, “Port2”, or “RS485”
Returns:True if provided parameter is a valid bus
Return type:Boolean
sdi12.sdi_collect(address, command='M', sdi_bus='Port1')
Collects data from an SDI-12 sensor using the provided cmd_to_sensor
It is expected that the sensor will use the same reply format as to aM! cmd_to_sensor
Parameters:
  • address – int address of SDI-12 sensor to collect data from
  • command – command to issue to sensor, e.g. “M”
  • sdi_bus – string indicating bus: “Port1”, “Port2”, or “RS485”
Returns:

a list of floats containing all the returned parameters

sdi12.sdi_collect_improved(address, desired_parameter, command='M', sdi_bus='Port1')
Collects data from SDI address 0 using the provided command and returns the
specified parameter. This version is optimized to not re-issue the command each time a different parameter is retrieved, if the data had already been retrieved in the past 10 seconds.
Parameters:
  • address – int address of SDI-12 sensor
  • desired_parameter – which SDI-12 parameter to return, 0 based (i.e. first param is 0)
  • command – command to issue, e.g. “M”
  • sdi_bus – string indicating bus: “Port1”, “Port2”, or “RS485”
Returns:

the value of the desired SDI-12 parameter

sdi12.sdi_send_command_get_reply(cmd_to_send, sdi_bus='Port1')

Sends provided command out on the specified SDI-12 bus, gets reply from the sensor.

Parameters:
  • cmd_to_send – the command to send on the SDI-12 bus, e.g. “0M!”
  • sdi_bus – string indicating bus: “Port1”, “Port2”, or “RS485”
Returns:

sensor reply, or “No reply”

Return type:

str