16
16
17
17
**Hardware:**
18
18
19
- * Adafruit PCT2075 Breakout: https://www.adafruit.com/products/4369
19
+ * Adafruit PCT2075 Temperature Sensor Breakout: https://www.adafruit.com/products/4369
20
20
21
21
**Software and Dependencies:**
22
22
23
23
* Adafruit CircuitPython firmware for the supported boards:
24
- https://github.com/adafruit/circuitpython/releases
24
+ https://circuitpython.org/downloads
25
25
26
26
27
27
@@ -67,20 +67,47 @@ class FaultCount:
67
67
68
68
class PCT2075 :
69
69
"""Driver for the PCT2075 Digital Temperature Sensor and Thermal Watchdog.
70
+
70
71
:param ~busio.I2C i2c_bus: The I2C bus the PCT2075 is connected to.
71
- :param address: The I2C device address for the sensor. Default is ``0x37``.
72
+ :param address: The I2C device address for the sensor. Default is :const:`0x37`
73
+
74
+ **Quickstart: Importing and using the PCT2075 temperature sensor**
75
+
76
+ Here is one way of importing the `PCT2075` class so you can use it with the name ``pct``.
77
+ First you will need to import the libraries to use the sensor
78
+
79
+ .. code-block:: python
80
+
81
+ import busio
82
+ import board
83
+ import adafruit_pct2075
84
+
85
+ Once this is done you can define your `busio.I2C` object and define your sensor object
86
+
87
+ .. code-block:: python
88
+
89
+ i2c = busio.I2C(board.SCL, board.SDA)
90
+ pct = adafruit_pct2075.PCT2075(i2c)
91
+
92
+ Now you have access to the temperature using the attribute :attr:`temperature`.
93
+
94
+ .. code-block:: python
95
+
96
+ temperature = pct.temperature
97
+
72
98
"""
73
99
74
100
def __init__ (self , i2c_bus , address = PCT2075_DEFAULT_ADDRESS ):
75
101
self .i2c_device = i2cdevice .I2CDevice (i2c_bus , address )
76
102
77
103
_temperature = ROUnaryStruct (PCT2075_REGISTER_TEMP , ">h" )
78
104
mode = RWBit (PCT2075_REGISTER_CONFIG , 1 , register_width = 1 )
79
- """Sets the alert mode. In comparitor mode, the sensor acts like a thermostat and will activate
105
+ """Sets the alert mode. In comparator mode, the sensor acts like a thermostat and will activate
80
106
the INT pin according to `high_temp_active_high` when an alert is triggered. The INT pin will be
81
- deactiveated when the temperature falls below `temperature_hysteresis`. In interrupt mode the
82
- INT pin is activated once when a temperature fault is detected, and once more when the
83
- temperature falls below `temperature_hysteresis`. In interrupt mode, the alert is cleared by
107
+ deactivated when the temperature falls below :attr:`temperature_hysteresis`.
108
+ In interrupt mode the INT pin is activated once when a temperature fault
109
+ is detected, and once more when the temperature falls below
110
+ :attr:`temperature_hysteresis`. In interrupt mode, the alert is cleared by
84
111
reading a property"""
85
112
86
113
shutdown = RWBit (PCT2075_REGISTER_CONFIG , 0 , 1 )
@@ -97,13 +124,14 @@ def __init__(self, i2c_bus, address=PCT2075_DEFAULT_ADDRESS):
97
124
98
125
@property
99
126
def temperature (self ):
100
- """Returns the current temperature in degress celsius. Resolution is 0.125 degrees C"""
127
+ """Returns the current temperature in degrees Celsius.
128
+ Resolution is 0.125 degrees Celsius"""
101
129
return (self ._temperature >> 5 ) * 0.125
102
130
103
131
@property
104
132
def high_temperature_threshold (self ):
105
133
"""The temperature in degrees celsius that will trigger an alert on the INT pin if it is
106
- exceeded. Resolution is 0.5 degrees C. """
134
+ exceeded. Resolution is 0.5 degrees Celsius """
107
135
return (self ._high_temperature_threshold >> 7 ) * 0.5
108
136
109
137
@high_temperature_threshold .setter
@@ -112,9 +140,12 @@ def high_temperature_threshold(self, value):
112
140
113
141
@property
114
142
def temperature_hysteresis (self ):
115
- """The temperature hysteresis value defines the bottom of the temperature range in degrees
116
- C in which the temperature is still considered high". `temperature_hysteresis` must be
117
- lower than `high_temperature_threshold`. Resolution is 0.5 degrees C.
143
+ """The temperature hysteresis value defines the bottom
144
+ of the temperature range in degrees Celsius in which
145
+ the temperature is still considered high.
146
+ :attr:`temperature_hysteresis` must be lower than
147
+ :attr:`high_temperature_threshold`.
148
+ Resolution is 0.5 degrees Celsius
118
149
"""
119
150
return (self ._temp_hysteresis >> 7 ) * 0.5
120
151
@@ -130,8 +161,8 @@ def temperature_hysteresis(self, value):
130
161
def faults_to_alert (self ):
131
162
"""The number of consecutive high temperature faults required to raise an alert. An fault
132
163
is tripped each time the sensor measures the temperature to be greater than
133
- `high_temperature_threshold`. The rate at which the sensor measures the temperature
134
- is defined by `delay_between_measurements`.
164
+ :attr: `high_temperature_threshold`. The rate at which the sensor measures the temperature
165
+ is defined by :attr: `delay_between_measurements`.
135
166
"""
136
167
137
168
return self ._fault_queue_length
0 commit comments