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,46 @@ 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
107
+ deactivated when the temperature falls below :attr: `temperature_hysteresis`. In interrupt mode the
82
108
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
109
+ temperature falls below :attr: `temperature_hysteresis`. In interrupt mode, the alert is cleared by
84
110
reading a property"""
85
111
86
112
shutdown = RWBit (PCT2075_REGISTER_CONFIG , 0 , 1 )
@@ -97,13 +123,13 @@ def __init__(self, i2c_bus, address=PCT2075_DEFAULT_ADDRESS):
97
123
98
124
@property
99
125
def temperature (self ):
100
- """Returns the current temperature in degress celsius . Resolution is 0.125 degrees C """
126
+ """Returns the current temperature in degrees Celsius . Resolution is 0.125 degrees Celsius """
101
127
return (self ._temperature >> 5 ) * 0.125
102
128
103
129
@property
104
130
def high_temperature_threshold (self ):
105
131
"""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. """
132
+ exceeded. Resolution is 0.5 degrees Celsius """
107
133
return (self ._high_temperature_threshold >> 7 ) * 0.5
108
134
109
135
@high_temperature_threshold .setter
@@ -113,8 +139,8 @@ def high_temperature_threshold(self, value):
113
139
@property
114
140
def temperature_hysteresis (self ):
115
141
"""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.
142
+ Celsius in which the temperature is still considered high. :attr: `temperature_hysteresis` must be
143
+ lower than :attr: `high_temperature_threshold`. Resolution is 0.5 degrees Celsius
118
144
"""
119
145
return (self ._temp_hysteresis >> 7 ) * 0.5
120
146
@@ -130,8 +156,8 @@ def temperature_hysteresis(self, value):
130
156
def faults_to_alert (self ):
131
157
"""The number of consecutive high temperature faults required to raise an alert. An fault
132
158
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`.
159
+ :attr: `high_temperature_threshold`. The rate at which the sensor measures the temperature
160
+ is defined by :attr: `delay_between_measurements`.
135
161
"""
136
162
137
163
return self ._fault_queue_length
0 commit comments