@@ -17,7 +17,7 @@ The library is based upon (stripped and adapted version of) the https://github.c
1717
1818Currently the library is experimental, so use with care.
1919
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.
2121The library works and it reads temperatures well, both with HW SPI and SW SPI.
2222
2323
@@ -34,7 +34,7 @@ Different TC's have a different Seebeck Coefficient (SC) expressed in µV/°C.
3434See http://www.analog.com/library/analogDialogue/archives/44-10/thermocouple.html
3535
3636
37- #### Breakout
37+ ### Breakout
3838
3939The library is tested with a breakout board with following pins:
4040
@@ -49,14 +49,14 @@ The library is tested with a breakout board with following pins:
4949```
5050
5151
52- #### 0.3.0 Breaking change
52+ ### 0.3.0 Breaking change
5353
5454Version 0.3.0 introduced a breaking change to improve handling the SPI dependency.
5555The user has to call ** SPI.begin()** or equivalent before calling ** AD.begin()** .
5656Optionally the user can provide parameters to the ** SPI.begin(...)**
5757
5858
59- #### 0.2.0 Breaking change
59+ ### 0.2.0 Breaking change
6060
6161The version 0.2.0 has breaking changes in the interface.
6262The essence is removal of ESP32 specific code from the library.
@@ -66,17 +66,18 @@ Also it makes the library a bit simpler to maintain.
6666Note the order of the parameters of the software SPI constructor has changed in 0.2.0.
6767
6868
69- #### Related
69+ ### Related
7070
71- - https://github.com/RobTillaart/MAX6675
71+ - https://github.com/RobTillaart/MAX6675
7272- https://github.com/RobTillaart/MAX31850
7373- https://github.com/RobTillaart/MAX31855_RT
74+ - https://github.com/RobTillaart/Temperature conversion to (exotic) temperature scales.
7475
7576
7677## Hardware SPI vs software SPI
7778
7879
79- #### Pins
80+ ### Pins
8081
8182Default pin connections.
8283
@@ -88,7 +89,7 @@ Default pin connections.
8889 | SELECT | eg. 4 | 5 | 15 | * can be others too.*
8990
9091
91- #### Performance
92+ ### Performance
9293
9394Performance read() function, timing in us.
9495- UNO @ 16 MHz
@@ -117,15 +118,15 @@ Tested with **MAX6675_test_HWSPI.ino**
117118#include " MAX6675.h"
118119```
119120
120- #### Constructor
121+ ### Constructor
121122
122123- ** MAX6675(uint8_t select, SPIClassRP2040 \* mySPI)** hardware SPI R2040
123124- ** MAX6675(uint8_t select, SPIClass \* mySPI)** hardware SPI other
124125- ** MAX6675(uint8_t select, uint8_t miso, uint8_t clock)** software SPI
125126- ** void begin()** initialize internals
126127
127128
128- #### Hardware SPI
129+ ### Hardware SPI
129130
130131To be used only if one needs a specific speed.
131132
@@ -136,63 +137,73 @@ Del is the time in micros added per bit. Even numbers keep the duty cycle of the
136137- ** uint16_t getSWSPIdelay()** get set value in micros.
137138
138139
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.
140151
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.
144152
145153Table: values returned from ** uint8_t read()** and ** uint8_t getStatus()**
146154
147155Note: this list is a subset of MAX31855 errors.
148156
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+
155164
165+ After ** uint8_t read()** returns ** STATUS_OK** you can get the temperature with
166+ ** getCelsius()** or ** getFahrenheit()** .
156167
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()** .
158170
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()** .
163173
164174
165- #### Offset
175+ ### Offset
166176
167177The library supports a fixed offset to calibrate the thermocouple.
168178For 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.
170180
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)
173183- 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.
176187
177188
178- #### Delta analysis
189+ ### Delta analysis
179190
180191As the ** tc** object holds its last known temperature it is easy to determine the delta
181192with the last known temperature, e.g. for trend analysis.
182193
183194``` cpp
184- float last = tc.getTemperature ();
195+ float last = tc.getCelsius ();
185196 int state = tc.read();
186197 if (state == STATUS_OK)
187198 {
188- float new = tc.getTemperature ();
199+ float new = tc.getCelsius ();
189200 float delta = new - last;
190201 // process data
191202 }
192203```
193204
194205
195- #### Last time read
206+ ### Last time read
196207
197208The **tc** object keeps track of the last time **read()** is called in the function **uint32_t lastRead()**.
198209The 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)
203214 int state = tc.read();
204215 if (state == STATUS_OK)
205216 {
206- float new = tc.getTemperature ();
217+ float new = tc.getCelsius ();
207218 // process read value.
208219 }
209220 else
@@ -214,7 +225,7 @@ if (millis() - tc.lastRead() >= interval)
214225```
215226
216227
217- #### GetRawData
228+ ### GetRawData
218229
219230The function ** uint32_t getRawData()** allows you to get all the 32 bits raw data from the board,
220231after the standard ** uint8_t tc.read()** call.
0 commit comments