# This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.8
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
from sys import version_info
if version_info >= (2, 6, 0):
def swig_import_helper():
from os.path import dirname
import imp
fp = None
try:
fp, pathname, description = imp.find_module('_pyupm_ecezo', [dirname(__file__)])
except ImportError:
import _pyupm_ecezo
return _pyupm_ecezo
if fp is not None:
try:
_mod = imp.load_module('_pyupm_ecezo', fp, pathname, description)
finally:
fp.close()
return _mod
_pyupm_ecezo = swig_import_helper()
del swig_import_helper
else:
import _pyupm_ecezo
del version_info
try:
_swig_property = property
except NameError:
pass # Python < 2.2 doesn't have 'property'.
def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
if (name == "thisown"):
return self.this.own(value)
if (name == "this"):
if type(value).__name__ == 'SwigPyObject':
self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name, None)
if method:
return method(self, value)
if (not static):
if _newclass:
object.__setattr__(self, name, value)
else:
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)
def _swig_setattr(self, class_type, name, value):
return _swig_setattr_nondynamic(self, class_type, name, value, 0)
def _swig_getattr_nondynamic(self, class_type, name, static=1):
if (name == "thisown"):
return self.this.own()
method = class_type.__swig_getmethods__.get(name, None)
if method:
return method(self)
if (not static):
return object.__getattr__(self, name)
else:
raise AttributeError(name)
def _swig_getattr(self, class_type, name):
return _swig_getattr_nondynamic(self, class_type, name, 0)
def _swig_repr(self):
try:
strthis = "proxy of " + self.this.__repr__()
except Exception:
strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
try:
_object = object
_newclass = 1
except AttributeError:
class _object:
pass
_newclass = 0
def getVersion():
return _pyupm_ecezo.getVersion()
getVersion = _pyupm_ecezo.getVersion
_pyupm_ecezo.ECEZO_MAX_BUFFER_LEN_swigconstant(_pyupm_ecezo)
ECEZO_MAX_BUFFER_LEN = _pyupm_ecezo.ECEZO_MAX_BUFFER_LEN
_pyupm_ecezo.ECEZO_CALIBRATE_CLEAR_swigconstant(_pyupm_ecezo)
ECEZO_CALIBRATE_CLEAR = _pyupm_ecezo.ECEZO_CALIBRATE_CLEAR
_pyupm_ecezo.ECEZO_CALIBRATE_DRY_swigconstant(_pyupm_ecezo)
ECEZO_CALIBRATE_DRY = _pyupm_ecezo.ECEZO_CALIBRATE_DRY
_pyupm_ecezo.ECEZO_CALIBRATE_ONE_swigconstant(_pyupm_ecezo)
ECEZO_CALIBRATE_ONE = _pyupm_ecezo.ECEZO_CALIBRATE_ONE
_pyupm_ecezo.ECEZO_CALIBRATE_LOW_swigconstant(_pyupm_ecezo)
ECEZO_CALIBRATE_LOW = _pyupm_ecezo.ECEZO_CALIBRATE_LOW
_pyupm_ecezo.ECEZO_CALIBRATE_HIGH_swigconstant(_pyupm_ecezo)
ECEZO_CALIBRATE_HIGH = _pyupm_ecezo.ECEZO_CALIBRATE_HIGH
[docs]class ECEZO(_object):
"""
API for the EC-EZO EC Sensor.
ID: ecezo
Name: Electrical Conductivity (EC) Circuit
Category: liquid
Manufacturer: sparkfun
Connection: uart i2c
Link:https://www.sparkfun.com/products/12908 This driver was tested
with the Atlas Scientific Electrical Conductivity kit.
This device can operate in either UART or I2C modes.
C++ includes: ecezo.hpp
"""
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, ECEZO, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, ECEZO, name)
__repr__ = _swig_repr
def __init__(self, bus=0, addrBaud=9600, isI2C=False):
"""
ECEZO(unsigned int bus=0,
unsigned int addrBaud=9600, bool isI2C=false)
ECEZO object constructor. This can use either UART (default) or I2C
communications. For UART, specify the uart number as the bus
parameter, the baudrate as the addrBaud parameter, and false for the
isI2C parameter.
For I2C, specify the bus parameter, the I2C address as the addrBaud
parameter, and true for the isI2C parameter.
Parameters:
-----------
bus: Specify which uart or I2C bus to use
addrBaud: Specify the baudrate if using UART, or the I2C address of
the device if using I2C.
isI2C: true if using I2C, false if using a UART
"""
this = _pyupm_ecezo.new_ECEZO(bus, addrBaud, isI2C)
try:
self.this.append(this)
except Exception:
self.this = this
__swig_destroy__ = _pyupm_ecezo.delete_ECEZO
__del__ = lambda self: None
[docs] def update(self):
"""
void update()
Query the device for a reading, parse the response, and store the read
values into the device context. This function must be called prior to
calling any function that returns the data, like getEC().
"""
return _pyupm_ecezo.ECEZO_update(self)
[docs] def setTemperature(self, temp):
"""
void
setTemperature(float temp)
For accurate readings, the temperature of the liquid being measured
should be known. This function allows you to specify the liquid's
temperature (in Celsius) so that proper compensation can take place.
How you measure this temperature is up to you. By default, the device
will assume a temperature of 25C.
Parameters:
-----------
temp: The temperature of the liquid being measured
UPM result
"""
return _pyupm_ecezo.ECEZO_setTemperature(self, temp)
[docs] def setKValue(self, k):
"""
void setKValue(float k)
Set the K value of the probe being used. By default, this is 1.0.
Valid values are between 0.1 and 10.0.
Parameters:
-----------
k: The K value of the probe
"""
return _pyupm_ecezo.ECEZO_setKValue(self, k)
[docs] def setSleep(self, enable):
"""
void setSleep(bool
enable)
Enable or disable Sleep mode.
Parameters:
-----------
enable: True to enable sleep mode, false to wake up
"""
return _pyupm_ecezo.ECEZO_setSleep(self, enable)
[docs] def getEC(self):
"""
float getEC()
Retrieve the last measured Electrical Conductivity (EC) value in
microsiemens. update() must have been called before calling this
function.
EC value in microsiemens
"""
return _pyupm_ecezo.ECEZO_getEC(self)
[docs] def getTDS(self):
"""
float getTDS()
Retrieve the last measured Total Dissolved solids (TDS) value.
update() must have been called before calling this function.
TDS value
"""
return _pyupm_ecezo.ECEZO_getTDS(self)
[docs] def getSalinity(self):
"""
float getSalinity()
Retrieve the last measured Salinity value. update() must have been
called before calling this function.
Salinity value
"""
return _pyupm_ecezo.ECEZO_getSalinity(self)
[docs] def getSG(self):
"""
float getSG()
Retrieve the last measured Specific Gravity (SG) value. update() must
have been called before calling this function.
SG value
"""
return _pyupm_ecezo.ECEZO_getSG(self)
[docs] def calibrate(self, cal, ec):
"""
void
calibrate(ECEZO_CALIBRATION_T cal, float ec)
Specify calibration data for calibrating the device. See the datasheet
for details on how calibration is performed. This function provides a
mechanism for clearing out, and setting calibration data.
A simple one point calibration might work as follows:
CLEAR the calibration data
with a dry probe, set the DRY point.
with the probe immersed in a standardized solution, set the ONE
parameter to the solution's known EC value in microsiemens.
A two point calibration might work as follows:
CLEAR the calibration data
with a dry probe, set the DRY point.
with the probe immersed in the lowest EC standardized solution, set
the LOW parameter to the solution's known EC value in microsiemens.
with the probe immersed in the highest EC standardized solution, set
the HIGH parameter to the solution's known EC value in microsiemens.
Parameters:
-----------
cal: One of the ECEZO_CALIBRATION_T values
ec: The EC value of the calibration fluid. This parameter is ignored
when cal is either ECEZO_CALIBRATE_CLEAR or ECEZO_CALIBRATE_DRY.
"""
return _pyupm_ecezo.ECEZO_calibrate(self, cal, ec)
ECEZO_swigregister = _pyupm_ecezo.ECEZO_swigregister
ECEZO_swigregister(ECEZO)
# This file is compatible with both classic and new-style classes.