def __init__(self, uid, connection, logging_daemon, queue, value=0.0, trigger_difference=0.1): self._bricklet = PTC(uid, connection) self._value = value self._value_old = value self.trigger_difference = trigger_difference self.uid = uid self._rising = False self._falling = False self._logging_daemon = logging_daemon self._queue = queue self._logging_daemon.info( 'Tinkerforge ... PTC-Bricklet UID "%s" initialisiert' % uid)
#!/usr/bin/env python # -*- coding: utf-8 -*- HOST = "localhost" PORT = 4223 UID = "XYZ" # Change to your UID from tinkerforge.ip_connection import IPConnection from tinkerforge.bricklet_ptc import PTC if __name__ == "__main__": ipcon = IPConnection() # Create IP connection ptc = PTC(UID, ipcon) # Create device object ipcon.connect(HOST, PORT) # Connect to brickd # Don't use device before ipcon is connected # Get current temperature (unit is °C/100) temperature = ptc.get_temperature() / 100.0 print('Temperature: ' + str(temperature) + ' °C') raw_input('Press key to exit\n') # Use input() in Python 3 ipcon.disconnect()