Skip to content

Commit c16d93c

Browse files
committed
update readme.md
1 parent 5de298c commit c16d93c

File tree

4 files changed

+128
-64
lines changed

4 files changed

+128
-64
lines changed

libraries/ADS1x15/README.md

Lines changed: 73 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -59,26 +59,30 @@ and optional the Wire interface as parameter.
5959
- **ADS1115(address, TwoWire \*wire = &Wire)** Constructor with device address,
6060
and optional the Wire interface as parameter.
6161

62-
The function **setWireClock(uint32_t speed)** is used to set the clock speed of the used
63-
I2C interface.
62+
The function **void setWireClock(uint32_t speed)** is used to set the clock speed
63+
of the used I2C interface.
6464

65-
The function **getWireClock()** is a prototype. It returns the value set by setWireClock().
66-
This is not necessary the actual value. When no value is set **getWireClock()** returns 0.
67-
Need to implement a read / calculate from low level I2C code (e.g. TWBR on AVR).
65+
The function **uint32_t getWireClock()** is a prototype.
66+
It returns the value set by setWireClock().
67+
This is not necessary the actual value.
68+
When no value is set **getWireClock()** returns 0.
69+
Need to implement a read / calculate from low level I2C code (e.g. TWBR on AVR),
70+
better the Arduino Wire lib should support this call (ESP32 does).
6871

6972
After construction the **ADS.begin()** need to be called. This will return false
7073
if an invalid address is used.
71-
The function **isConnected()** can be used to verify the reading of the ADS.
72-
The function **reset()** is sets the parameters to their initial value as
74+
The function **bool isConnected()** can be used to verify the reading of the ADS.
75+
The function **void reset()** is sets the parameters to their initial value as
7376
in the constructor.
7477

7578

7679
#### Programmable Gain
7780

78-
- **setGain(gain)** set the gain value, indicating the maxVoltage that can be measured
79-
Adjusting the gain allows one to make more precise measurements.
81+
- **void setGain(uint8_t gain)** set the gain value, indicating the maxVoltage that can be measured
82+
Adjusting the gain allows one to make more precise measurements.
83+
Note: the gain is not set in the device until an explicit read/request of the ADC (any read call will do).
8084
See table below.
81-
- **getGain()** returns the gain value (index).
85+
- **uint8_t getGain()** returns the gain value (index).
8286

8387
| PGA value | Max Voltage | Notes |
8488
|:---------:|:-----------:|:-------:|
@@ -89,8 +93,8 @@ See table below.
8993
| 8 | ±0.512V | |
9094
| 16 | ±0.256V | |
9195

92-
- **getMaxVoltage()** returns the max voltage with the current gain.
93-
- **toVoltage(raw = 1)** converts a raw measurement to a voltage.
96+
- **float getMaxVoltage()** returns the max voltage with the current gain.
97+
- **float toVoltage(int16_t raw = 1)** converts a raw measurement to a voltage.
9498
Can be used for normal and differential measurements.
9599
The default value of 1 returns the conversion factor for any raw number.
96100

@@ -108,16 +112,19 @@ Check the examples.
108112

109113
The ADS sensor can operate in single shot or continuous mode.
110114
Depending on how often one needs a conversion one can tune the mode.
111-
- **setMode(mode)** 0 = CONTINUOUS, 1 = SINGLE (default)
112-
- **getMode()** returns current mode 0 or 1, or ADS1X15_INVALID_MODE = 0xFE.
115+
- **void setMode(uint8_t mode)** 0 = CONTINUOUS, 1 = SINGLE (default)
116+
Note: the mode is not set in the device until an explicit read/request of the ADC (any read call will do).
117+
- **uint8_t getMode()** returns current mode 0 or 1, or ADS1X15_INVALID_MODE = 0xFE.
118+
113119

114120

115121
#### Data rate
116122

117-
- **setDataRate(dataRate)** Data rate depends on type of device.
123+
- **void setDataRate(uint8_t dataRate)** Data rate depends on type of device.
118124
For all devices the index 0..7 can be used, see table below.
119125
Values above 7 ==> will be set to the default 4.
120-
- **getDataRate()** returns the current data rate (index).
126+
Note: the data rate is not set in the device until an explicit read/request of the ADC (any read call will do).
127+
- **uint8_t getDataRate()** returns the current data rate (index).
121128

122129
The library has no means to convert this index to the actual numbers
123130
as that would take 32 bytes.
@@ -144,10 +151,10 @@ all in one call. Under the hood it uses the asynchronous calls.
144151
If the pin number is out of range, this function will return 0.
145152

146153
To read the ADC in an asynchronous way (e.g. to minimize blocking) one has to use three calls:
147-
- **requestADC(pin)** Start the conversion. pin = 0..3.
148-
- **isBusy()** Is the conversion not ready?
149-
- **isReady()** Is the conversion ready? (= wrapper around **isBusy()** )
150-
- **getValue()** Read the result of the conversion.
154+
- **void requestADC(uint8_t pin)** Start the conversion. pin = 0..3.
155+
- **bool isBusy()** Is the conversion not ready?
156+
- **bool isReady()** Is the conversion ready? (= wrapper around **isBusy()** )
157+
- **int16_t getValue()** Read the result of the conversion.
151158

152159

153160
in terms of code
@@ -176,33 +183,35 @@ See examples
176183
## ReadADC Differential
177184
178185
For reading the ADC in a differential way there are 4 calls possible.
179-
- **readADC_Differential_0_1()** returns the difference between 2 ADC pins.
180-
- **readADC_Differential_0_3()** ADS1x15 only
181-
- **readADC_Differential_1_3()** ADS1x15 only
182-
- **readADC_Differential_2_3()** ADS1x15 only
183-
- **readADC_Differential_0_2()** ADS1x15 only - in software (no async equivalent)
184-
- **readADC_Differential_1_2()** ADS1x15 only - in software (no async equivalent)
186+
- **int16_t readADC_Differential_0_1()** returns the difference between 2 ADC pins.
187+
- **int16_t readADC_Differential_0_3()** ADS1x15 only
188+
- **int16_t readADC_Differential_1_3()** ADS1x15 only
189+
- **int16_t readADC_Differential_2_3()** ADS1x15 only
190+
- **int16_t readADC_Differential_0_2()** ADS1x15 only - in software (no async equivalent)
191+
- **int16_t readADC_Differential_1_2()** ADS1x15 only - in software (no async equivalent)
185192
186193
The differential reading of the ADC can also be done with asynchronous calls.
187-
- **requestADC_Differential_0_1()** starts conversion for differential reading
188-
- **requestADC_Differential_0_3()** ADS1x15 only
189-
- **requestADC_Differential_1_3()** ADS1x15 only
190-
- **requestADC_Differential_2_3()** ADS1x15 only
194+
- **int16_t requestADC_Differential_0_1()** starts conversion for differential reading
195+
- **int16_t requestADC_Differential_0_3()** ADS1x15 only
196+
- **int16_t requestADC_Differential_1_3()** ADS1x15 only
197+
- **int16_t requestADC_Differential_2_3()** ADS1x15 only
191198
192199
After one of these calls one need to call
193-
- **isBusy()** Is the conversion ready?
194-
- **getValue()** Read the result of the conversion.
200+
- **bool isBusy()** Is the conversion ready?
201+
- **int16_t getValue()** Read the result of the last conversion.
195202
196203
197204
#### ReadADC continuous mode
198205
199206
To use the continuous mode one need three calls
200-
- **setMode(0)** 0 = CONTINUOUS, 1 = SINGLE (default)
201-
- **readADC()** or **requestADC()** to get the continuous mode started.
202-
- **getValue()** to return the last value read by the device.
207+
- **void setMode(0)** 0 = CONTINUOUS, 1 = SINGLE (default).
208+
Note: the mode is not set in the device until an explicit read/request of the ADC (any read call will do).
209+
- **int16_t readADC(uint8_t pin)** or **void requestADC(uint8_t pin)** to get the continuous mode started.
210+
- **int16_t getValue()** to return the last value read by the device.
211+
Note this can be a different pin, so be warned.
203212
Calling this over and over again can give the same value multiple times.
204213
205-
By using **isBusy()** or **isReady()** one can wait until new data is available.
214+
By using **bool isBusy()** or **bool isReady()** one can wait until new data is available.
206215
Or one can use the **ALERT/RDY** pin to trigger via hardware the readiness of the conversion.
207216
208217
See examples.
@@ -212,17 +221,22 @@ See examples.
212221
213222
If the thresholdHigh is set to 0x0100 and the thresholdLow to 0x0000
214223
the **ALERT/RDY** pin is triggered when a conversion is ready.
215-
- **setComparatorThresholdLow(0x0000)**
216-
- **setComparatorThresholdHigh(0x0100)**
224+
- **void setComparatorThresholdLow(int16_t lo)** writes value to device directly.
225+
- **void setComparatorThresholdHigh(int16_t hi)** writes value to device directly.
226+
- **int16_t getComparatorThresholdLow()** reads value from device.
227+
- **int16_t getComparatorThresholdHigh()** reads value from device.
217228
218229
See examples.
219230
220231
221232
## Comparator
222233
223-
Please read Page 15 of the datasheet as the behavior of the
234+
Please read Page 15 of the datasheet as the behaviour of the
224235
comparator is not trivial.
225236
237+
NOTE: all comparator settings are copied to the device only after an explicit
238+
**readADC()** or **requestADC()**
239+
226240
227241
#### Comparator Mode
228242
@@ -231,6 +245,10 @@ When configured as a **TRADITIONAL** comparator, the **ALERT/RDY** pin asserts
231245
high threshold register. The comparator then de-asserts when the input
232246
signal falls below the low threshold register value.
233247
248+
- **void setComparatorMode(uint8_t mode)** value 0 = TRADITIONAL 1 = WINDOW,
249+
- **uint8_t getComparatorMode()**
250+
251+
234252
If the comparator **LATCH** is set, the **ALERT/RDY** pin asserts and it will be
235253
reset after reading the sensor (conversion register) again.
236254
*An SMB alert command (00011001) on the I2C bus will also reset the alert state.*
@@ -245,20 +263,30 @@ In this mode the alert is held if the **LATCH** is set. This is similar as above
245263
246264
Default state of the **ALERT/RDY** pin is **LOW**, can be to set **HIGH**.
247265
266+
- **void setComparatorPolarity(uint8_t pol)**
267+
Flag is only explicitly set after a **readADC()** or a **requestADC()**
268+
- **uint8_t getComparatorPolarity()** returns value set.
269+
248270
249271
#### Latch
250272
251273
Holds the **ALERT/RDY** to **HIGH** (or **LOW** depending on polarity) after triggered
252274
even if actual value has been 'restored to normal' value.
253275
276+
- **void setComparatorLatch(uint8_t latch)** 0 = NO LATCH, not 0 = LATCH
277+
- **uint8_t getComparatorLatch()** returns value set.
278+
254279
255280
#### QueConvert
256281
257282
Set the number of conversions before trigger activates.
258-
The **setComparatorQueConvert(uint8_t mode)** is used to set the number of
283+
The **void setComparatorQueConvert(uint8_t mode)** is used to set the number of
259284
conversions that exceed the threshold before the **ALERT/RDY** pin is set **HIGH**.
260285
A value of 3 (or above) effectively disables the comparator. See table below.
261286
287+
- **void setComparatorQueConvert(uint8_t mode)** See table below.
288+
- **uint8_t getComparatorQueConvert()** returns value set.
289+
262290
| value | meaning | Notes |
263291
|:-----:|:----------------------------------|:--------|
264292
| 0 | trigger alert after 1 conversion | |
@@ -271,19 +299,17 @@ A value of 3 (or above) effectively disables the comparator. See table below.
271299
272300
Depending on the comparator mode **TRADITIONAL** or **WINDOW** the thresholds registers
273301
mean something different see - Comparator Mode above or datasheet.
274-
- **setComparatorThresholdLow(lo)** set the low threshold; take care the hi >= lo
275-
- **setComparatorThresholdHigh(hi)** set the high threshold; take care the hi >= lo
276-
- **getComparatorThresholdLow()** returns set value
277-
- **getComparatorThresholdHigh()** returns set value
302+
- **void setComparatorThresholdLow(int16_t lo)** set the low threshold; take care the hi >= lo.
303+
- **void setComparatorThresholdHigh(int16_t hi)** set the high threshold; take care the hi >= lo.
304+
- **int16_t getComparatorThresholdLow()** reads value from device.
305+
- **int16_t getComparatorThresholdHigh()** reads value from device.
278306
279307
280308
## Future ideas & improvements
281309
282310
- Improve documentation
283-
- more examples?
311+
- More examples ?
284312
- SMB alert command (00011001) on I2C bus?
285-
- implement missing Differential reads in software.
286-
- testing....
287313
288314
289315
## Operation

libraries/SHT31/README.md

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
Arduino library for the SHT31 temperature and humidity sensor
1010

11+
Relates to the SHT85 library - https://github.com/RobTillaart/SHT85
12+
1113

1214
## Description
1315

@@ -18,9 +20,10 @@ not tested yet.
1820

1921
| SENSOR | Temperature accuracy | Humidity accuracy |
2022
|:----:|:----:|:----:|
21-
| SHT30 | ~0.3 | 2 |
23+
| SHT30 | ~0.3 | 2.0 |
2224
| SHT31 | ~0.3 | 1.5 |
2325
| SHT35 | ~0.2 | 1.5 |
26+
| SHT85 | ~0.2 | 1.5 |
2427

2528

2629
An elaborated library for the SHT31 sensor can be found here
@@ -36,7 +39,8 @@ https://github.com/hawesg/SHT31D_Particle_Photon_ClosedCube
3639
returns false if device address is incorrect or device cannot be reset.
3740
- **begin(address)** for single I2C bus platforms, e.g UNO.
3841
- **begin(address, TwoWire \*wire)** for platforms with multiple I2C busses.
39-
- **read(bool fast = true)** blocks 4 (fast) or 15 (slow) milliseconds + actual read + math
42+
- **read(bool fast = true)** blocks 4 (fast) or 15 (slow) milliseconds + actual read + math.
43+
Does read both the temperature and humidity.
4044
- **isConnected()** check sensor is reachable over I2C. Returns false if not connected.
4145
- **uint16_t readStatus()** details see datasheet and **Status fields** below
4246
- **uint32_t lastRead()** in milliSeconds since start of program.
@@ -97,26 +101,31 @@ See async example for usage
97101

98102
| BIT | Description | values |
99103
|:----:|:----|:----|
100-
| 15 | Alert pending status | '0': no pending alerts|
101-
| | | '1': at least one pending alert - default |
102-
| 14 | Reserved | '0' |
103-
| 13 | Heater status | '0’ : Heater OFF - default |
104-
| | | '1’ : Heater ON |
105-
| 12 | Reserved | '0' |
106-
| 11 | Humidity tracking alert | '0’ : no alert - default |
107-
| | | '1’ : alert |
104+
| 15 | Alert pending status | '0': no pending alerts|
105+
| | | '1': at least one pending alert - default |
106+
| 14 | Reserved | '0' |
107+
| 13 | Heater status | '0’ : Heater OFF - default |
108+
| | | '1’ : Heater ON |
109+
| 12 | Reserved | '0' |
110+
| 11 | Humidity tracking alert | '0’ : no alert - default |
111+
| | | '1’ : alert |
108112
| 10 | Temperature tracking alert | '0’ : no alert - default |
109113
| | | '1’ : alert |
110-
| 9-5 | Reserved | '00000' |
111-
| 4 | System reset detected | '0': no reset since last ‘clear status register’ command |
112-
| | | '1': reset detected (hard or soft reset command or supply fail) - default |
113-
| 3-2 | Reserved | '00' |
114-
| 1 | Command status | '0': last cmd executed successfully |
115-
| | | '1': last cmd not processed. Invalid or failed checksum |
114+
| 9-5 | Reserved | '00000' |
115+
| 4 | System reset detected | '0': no reset since last ‘clear status register’ command |
116+
| | | '1': reset detected (hard or soft reset command or supply fail) - default |
117+
| 3-2 | Reserved | '00' |
118+
| 1 | Command status | '0': last cmd executed successfully |
119+
| | | '1': last cmd not processed. Invalid or failed checksum |
116120
| 0 | Write data checksum status | '0': checksum of last write correct |
117121
| | | '1': checksum of last write transfer failed |
118122

119123

124+
## Future
125+
126+
- merge with other SHT sensors if possible
127+
- direct Fahrenheit formula
128+
120129
## Operation
121130

122131
See examples

libraries/SHT31/keywords.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Syntax Coloring Map For SHT31
1+
# Syntax Coloring Map For SHT31 temperature and humidity sensor
2+
23

34
# Datatypes (KEYWORD1)
45
SHT31 KEYWORD1
@@ -11,16 +12,21 @@ isConnected KEYWORD2
1112
readStatus KEYWORD2
1213
lastRead KEYWORD2
1314
reset KEYWORD2
15+
1416
setHeatTimeout KEYWORD2
1517
heatOn KEYWORD2
1618
heatOff KEYWORD2
1719
isHeaterOn KEYWORD2
20+
1821
getHumidity KEYWORD2
1922
getTemperature KEYWORD2
23+
2024
requestData KEYWORD2
2125
dataReady KEYWORD2
2226
readData KEYWORD2
2327

28+
getRawHumidity KEYWORD2
29+
getRawTemperature KEYWORD2
2430

2531
# Instances (KEYWORD2)
2632

0 commit comments

Comments
 (0)