Watlow

class watlow.Watlow(serial=None, port=None, timeout=0.5, address=1)[source]

Object representing a Watlow PID temperature controller. This class facilitates the generation and parsing of BACnet TP/MS messages to and from Watlow temperature controllers.

  • serial: serial object (see pySerial’s serial.Serial class) or None
  • port (str): string representing the serial port or None
  • timeout (float): Read timeout value in seconds
  • address (int): Watlow controller address (found in the setup menu). Acceptable values are 1 through 16.

timeout and port are not necessary if a serial object was already passed with those arguments. The baudrate for Watlow temperature controllers is 38400 and hardcoded.

read(instance='01')[source]

Reads the current temperature. This is a wrapper around readParam() and is equivalent to readParam(4001, float, instance).

Returns a dict containing the response data, parameter ID, and address. * instance: a two digit string corresponding to the channel to read (e.g. ‘01’, ‘05’)

readParam(param, data_type, instance='01')[source]

Takes a parameter and writes data to the watlow controller at object’s internal address. Using this function requires knowing the data type for the parameter (int or float). See the Watlow user manual for individual parameters and the Usage section of these docs.

  • param: a four digit integer corresponding to a Watlow parameter (e.g. 4001, 7001)
  • data_type: the Python type representing the data value type (i.e. int or float)
  • instance: a two digit string corresponding to the channel to read (e.g. ‘01’, ‘05’)

data_type is used to determine how many characters to read following the controller’s response. If int is passed when the data type should be float, it will not read the entire message and will throw an error. If float is passed when it should be int, it will timeout, possibly reading correctly. If multiple instances of Watlow() are using the same serial port for different controllers it will read too many characters. It is best to be completely sure which data type is being used by each parameter (int or float).

Returns a dict containing the response data, parameter ID, and address.

readSetpoint(instance='01')[source]

Reads the current setpoint. This is a wrapper around readParam() and is equivalent to readParam(7001, float, instance).

Returns a dict containing the response data, parameter ID, and address. * instance: a two digit string corresponding to the channel to read (e.g. ‘01’, ‘05’)

write(value, instance='01')[source]

Changes the watlow temperature setpoint. Takes a value (in degrees F by default), builds request, writes to watlow, receives and returns response object.

  • value: an int or float representing the new target setpoint in degrees F by default
  • instance: a two digit string corresponding to the channel to set (e.g. ‘01’, ‘05’)

This is a wrapper around writeParam() and is equivalent to writeParam(7001, value, float, instance).

Returns a dict containing the response data, parameter ID, and address.

writeParam(param, value, data_type, instance='01')[source]

Changes the value of the passed watlow parameter ID. Using this function requires knowing the data type for the parameter (int or float). See the Watlow user manual for individual parameters and the Usage section of these docs.

  • value: an int or float representing the new target setpoint in degrees F by default
  • data_type: the Python type representing the data value type (i.e. int or float)
  • instance: a two digit string corresponding to the channel to read (e.g. ‘01’, ‘05’)

data_type is used to determine how the BACnet TP/MS message will be constructed and how many serial characters to read following the controller’s response.

Returns a dict containing the response data, parameter ID, and address.