@@ -17,7 +17,7 @@ The library is based upon (stripped and adapted version of) the https://github.c
17
17
18
18
Currently the library is experimental, so use with care.
19
19
20
- Hardware has finally arrived (April 2022) and I had time to do my first round of tests with an UNO @ 16 MHz.
20
+ Hardware has finally arrived (April 2022) and I had time to do my first round of tests with an UNO at 16 MHz.
21
21
The library works and it reads temperatures well, both with HW SPI and SW SPI.
22
22
23
23
@@ -34,7 +34,7 @@ Different TC's have a different Seebeck Coefficient (SC) expressed in µV/°C.
34
34
See http://www.analog.com/library/analogDialogue/archives/44-10/thermocouple.html
35
35
36
36
37
- #### Breakout
37
+ ### Breakout
38
38
39
39
The library is tested with a breakout board with following pins:
40
40
@@ -49,14 +49,14 @@ The library is tested with a breakout board with following pins:
49
49
```
50
50
51
51
52
- #### 0.3.0 Breaking change
52
+ ### 0.3.0 Breaking change
53
53
54
54
Version 0.3.0 introduced a breaking change to improve handling the SPI dependency.
55
55
The user has to call ** SPI.begin()** or equivalent before calling ** AD.begin()** .
56
56
Optionally the user can provide parameters to the ** SPI.begin(...)**
57
57
58
58
59
- #### 0.2.0 Breaking change
59
+ ### 0.2.0 Breaking change
60
60
61
61
The version 0.2.0 has breaking changes in the interface.
62
62
The essence is removal of ESP32 specific code from the library.
@@ -66,17 +66,18 @@ Also it makes the library a bit simpler to maintain.
66
66
Note the order of the parameters of the software SPI constructor has changed in 0.2.0.
67
67
68
68
69
- #### Related
69
+ ### Related
70
70
71
- - https://github.com/RobTillaart/MAX6675
71
+ - https://github.com/RobTillaart/MAX6675
72
72
- https://github.com/RobTillaart/MAX31850
73
73
- https://github.com/RobTillaart/MAX31855_RT
74
+ - https://github.com/RobTillaart/Temperature conversion to (exotic) temperature scales.
74
75
75
76
76
77
## Hardware SPI vs software SPI
77
78
78
79
79
- #### Pins
80
+ ### Pins
80
81
81
82
Default pin connections.
82
83
@@ -88,7 +89,7 @@ Default pin connections.
88
89
| SELECT | eg. 4 | 5 | 15 | * can be others too.*
89
90
90
91
91
- #### Performance
92
+ ### Performance
92
93
93
94
Performance read() function, timing in us.
94
95
- UNO @ 16 MHz
@@ -117,15 +118,15 @@ Tested with **MAX6675_test_HWSPI.ino**
117
118
#include " MAX6675.h"
118
119
```
119
120
120
- #### Constructor
121
+ ### Constructor
121
122
122
123
- ** MAX6675(uint8_t select, SPIClassRP2040 \* mySPI)** hardware SPI R2040
123
124
- ** MAX6675(uint8_t select, SPIClass \* mySPI)** hardware SPI other
124
125
- ** MAX6675(uint8_t select, uint8_t miso, uint8_t clock)** software SPI
125
126
- ** void begin()** initialize internals
126
127
127
128
128
- #### Hardware SPI
129
+ ### Hardware SPI
129
130
130
131
To be used only if one needs a specific speed.
131
132
@@ -136,63 +137,73 @@ Del is the time in micros added per bit. Even numbers keep the duty cycle of the
136
137
- ** uint16_t getSWSPIdelay()** get set value in micros.
137
138
138
139
139
- #### Reading
140
+ ### Measurements
141
+
142
+ - ** uint8_t read()** makes a temperature measurement.
143
+ It returns the status of the read (0, 4 or 129)
144
+ - ** uint8_t getStatus()** returns the last status value of read().
145
+ Will stay the same until a new ** read()** call.
146
+ - ** float getTemperature()** returns last temperature in Celsius. (will be obsolete in future).
147
+ - ** float getCelsius()** returns last temperature in Celsius. (more explicit scale).
148
+ Will stay the same until a new ** read()** call.
149
+ - ** float getFahrenheit()** wrapper around getCelsius(). Returns last temperature in Fahrenheit.
150
+ Will stay the same until a new ** read()** call.
140
151
141
- To make a temperature reading call ** read()** .
142
- It returns the status of the read which is a value between 0..7
143
- The function ** getStatus()** returns the same status value.
144
152
145
153
Table: values returned from ** uint8_t read()** and ** uint8_t getStatus()**
146
154
147
155
Note: this list is a subset of MAX31855 errors.
148
156
149
- | value | Description | Action |
150
- | :-----:| :--------------------------| :-------------|
151
- | 0 | OK | |
152
- | 4 | Thermocouple short to VCC | check wiring |
153
- | 128 | No read done yet | check wiring |
154
- | 129 | No communication | check wiring |
157
+ | Define | value | Description | Action | Notes |
158
+ | :--------------------------| :-------:| :----------------------------| :---------------| :--------|
159
+ | STATUS_OK | 0 | OK | |
160
+ | STATUS_ERROR | 4 | Thermocouple short to VCC | check wiring |
161
+ | STATUS_NOREAD | 128 | No read done yet | check wiring | only before first read()
162
+ | STATUS_NO_COMMUNICATION | 129 | No communication | check wiring |
163
+
155
164
165
+ After ** uint8_t read()** returns ** STATUS_OK** you can get the temperature with
166
+ ** getCelsius()** or ** getFahrenheit()** .
156
167
157
- After a ** uint8_t read()** you can get the temperature with ** float getTemperature()** .
168
+ Repeated calls to ** getCelsius()** or ** getFahrenheit()** will give the same value until a new
169
+ measurement is made by calling ** read()** .
158
170
159
- Repeated calls to ** getTemperature()** will give the same value until a new ** read()** .
160
- The latter fetches a new value from the sensor. Note that if the ** read()** fails
161
- the value of ** getTemperature()** can become incorrect. So it is important to check
162
- the return value of ** read()** .
171
+ Note: if the ** read()** fails the value of ** getCelsius()** can become incorrect.
172
+ So it is important to check the return value of ** read()** .
163
173
164
174
165
- #### Offset
175
+ ### Offset
166
176
167
177
The library supports a fixed offset to calibrate the thermocouple.
168
178
For this the functions ** float getOffset()** and ** void setOffset(float offset)** are available.
169
- This offset is "added" in the ** getTemperature ()** function.
179
+ This offset is "added" in the ** getCelsius ()** function.
170
180
171
- Notes
172
- - the offset can be positive or negative.
181
+ Note:
182
+ - the offset is a constant in degrees Celsius (for Fahrenheit offset multiply by 1.8)
173
183
- the offset used is a float, so decimals can be used.
174
- A typical usage is to call ** setOffset(273.15)** to get ° Kelvin.
175
- - the offset can cause negative temperatures.
184
+ A typical usage is to call ** setOffset(273.15)** to get degrees ° Kelvin.
185
+ - the offset can be positive or negative.
186
+ - the offset can cause negative temperatures to pop up at the lower end.
176
187
177
188
178
- #### Delta analysis
189
+ ### Delta analysis
179
190
180
191
As the ** tc** object holds its last known temperature it is easy to determine the delta
181
192
with the last known temperature, e.g. for trend analysis.
182
193
183
194
``` cpp
184
- float last = tc.getTemperature ();
195
+ float last = tc.getCelsius ();
185
196
int state = tc.read();
186
197
if (state == STATUS_OK)
187
198
{
188
- float new = tc.getTemperature ();
199
+ float new = tc.getCelsius ();
189
200
float delta = new - last;
190
201
// process data
191
202
}
192
203
```
193
204
194
205
195
- #### Last time read
206
+ ### Last time read
196
207
197
208
The **tc** object keeps track of the last time **read()** is called in the function **uint32_t lastRead()**.
198
209
The time is tracked in **millis()**. This makes it easy to read the sensor at certain intervals.
@@ -203,7 +214,7 @@ if (millis() - tc.lastRead() >= interval)
203
214
int state = tc.read();
204
215
if (state == STATUS_OK)
205
216
{
206
- float new = tc.getTemperature ();
217
+ float new = tc.getCelsius ();
207
218
// process read value.
208
219
}
209
220
else
@@ -214,7 +225,7 @@ if (millis() - tc.lastRead() >= interval)
214
225
```
215
226
216
227
217
- #### GetRawData
228
+ ### GetRawData
218
229
219
230
The function ** uint32_t getRawData()** allows you to get all the 32 bits raw data from the board,
220
231
after the standard ** uint8_t tc.read()** call.
0 commit comments