예제 #1
0
 def read_temp():
     pi = pigpio.pi()
     tsic = TsicInputChannel(pigpio_pi=pi, gpio=temperature_pin, tsic_type=TSIC306)
     measurement = tsic.measure_once(timeout=1.0)
     pi.stop()
     if not (measurement == Measurement.UNDEF):
         return measurement.degree_celsius
예제 #2
0
 def read_temp():
     pi = pigpio.pi()
     tsic = TsicInputChannel(pigpio_pi=pi, gpio=pin, tsic_type=TSIC306)
     measurement = tsic.measure_once(timeout=1.0)
     pi.stop()
     if measurement == Measurement.UNDEF:
         return "-273.15"
     else:
         return f"{round(measurement.degree_celsius, 2)}"
예제 #3
0
 def __init__(self, pigpio_pi, gpio_bcm, **kwargs):
     super().__init__(**kwargs)
     try:
         self.__gpio = gpio_bcm
         self.tsic = TsicInputChannel(pigpio_pi, gpio_bcm)
     except Exception as e:
         logger.warn('Failed to initialize TSIC input channel: ' + str(e))
         # handle missing GPIO access for windows development
         self.tsic = None
예제 #4
0
 def __init__(self, gpio=4):
     self._temperature: float = 0
     self._lock = threading.Lock()
     pi = pigpio.pi()
     self.tsic = TsicInputChannel(pigpio_pi=pi,
                                  gpio=gpio,
                                  tsic_type=TSIC306)
     self.tsic.start(self._store_measurement)
     time.sleep(0.2)
예제 #5
0
"""

__author__ = 'Holger Fleischmann'
__copyright__ = 'Copyright 2019, Holger Fleischmann, Bavaria/Germany'
__license__ = 'Apache License 2.0'

import time
import pigpio

from tsic import TsicInputChannel, Measurement, TSIC306

# TsicInputChannel and ZacWireInputChannel require pigpio
# for GPIO access with precise timing:
pi = pigpio.pi()

tsic = TsicInputChannel(pigpio_pi=pi, gpio=17, tsic_type=TSIC306)

print('\nA. Single measurement:')
print(tsic.measure_once(timeout=1.0))

print('\nB. All measurements for 1 second:')
tsic.start(lambda measurement: print(measurement))
time.sleep(1)
tsic.stop()

print('\nC. One measurement per second for 3 seconds:')

# start receiving in a context:
with tsic:
    for i in range(3):
        time.sleep(1)
예제 #6
0
on a Raspberry PI.
"""

__author__ = 'Holger Fleischmann'
__copyright__ = 'Copyright 2018, Holger Fleischmann, Bavaria/Germany'
__license__ = 'Apache License 2.0'

import pigpio
from tsic import TsicInputChannel, Measurement
import time

# TsicInputChannel and ZacWireInputChannel require pigpio
# for GPIO access with precise timing:
pi = pigpio.pi()

tsic = TsicInputChannel(pigpio_pi=pi, gpio=17)

print('\nA. Single measurement:')
print(tsic.measure_once(timeout=1.0))

print('\nB. All measurements for 1 second:')
tsic.start(lambda measurement: print(measurement))
time.sleep(1)
tsic.stop()

print('\nC. One measurement per second for 3 seconds:')

# start receiving in a context:
with tsic:
    for i in range(3):
        time.sleep(1)