Skip to content

Commit d65e32c

Browse files
Final changes from code review before PR into main branch
For more finite details, see code review document for changes made. Mostly final small tweaks to the code; updated README file
1 parent c86c9f6 commit d65e32c

File tree

6 files changed

+73
-59
lines changed

6 files changed

+73
-59
lines changed

README.md

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,34 @@
1-
SparkFun <PRODUCT NAME>
1+
SparkFun STHS34PF80 Arduino Library
22
========================================
33

4-
[![SparkFun Part Name](URL for picture of part)](URL for product on Sparkfun.com)
54

6-
[*SparkFun Part Name (SKU)*](URL for product on Sparkfun.com)
7-
8-
<Basic description of the part.>
5+
This is the SparkFun library for the STMicroelectronics STHS34PF80 IR sensor with an operating wavelength between 5 µm and 20 µm with I<sup>2</sup>C and SPI interface. (https://www.sparkfun.com/products/22494).
96

107
Repository Contents
118
-------------------
129

13-
* **/Documentation** - Data sheets, additional product information
14-
* **/Enclosure** - Enclosure files
15-
* **/Firmware** - Example code
16-
* **/Hardware** - Eagle design files (.brd, .sch)
17-
* **/Libraries** - Libraries for use with the <PRODUCT NAME>
18-
* **/Production** - Production panel files (.brd)
19-
* **/Software** - Related software for the <PRODUCT NAME>
10+
* **/examples** - Example sketches for the library (.ino). Run these from the Arduino IDE.
11+
* **/src** - Source files for the library (.cpp, .h).
12+
* **/Documentation** - Datasheet and application note for the STHS34PF80.
13+
* **keywords.txt** - Keywords from this library that will be highlighted in the Arduino IDE.
14+
* **library.properties** - General library properties for the Arduino package manager.
15+
* **[CONTRIBUTING.md](./CONTRIBUTING.md)** - guidance on how to contribute to this library.
16+
2017

2118
Documentation
2219
--------------
23-
* **[Library](GitHub library URL)** - <LANGUAGE> library for the <PRODUCT NAME>.
24-
* **[Hookup Guide](Learn.SparkFun URL)** - Basic hookup guide for the <PRODUCT NAME>.
25-
* **[SparkFun Fritzing repo](https://github.com/sparkfun/Fritzing_Parts)** - Fritzing diagrams for SparkFun products.
26-
* **[SparkFun 3D Model repo](https://github.com/sparkfun/3D_Models)** - 3D models of SparkFun products.
27-
* **[SparkFun Graphical Datasheets](https://github.com/sparkfun/Graphical_Datasheets)** -Graphical Datasheets for various SparkFun products.
28-
29-
Product Versions
30-
----------------
31-
* [Part SKU](part URL) - Basic part and short description here
32-
* [Retail part SKU](retail URL) - Retail packaging of standard description here
33-
* [Any other parts this repo covers](any other URLs) - Description of said parts
34-
35-
Version History
36-
---------------
37-
* [vExxFxxZxxHxxLxxSxx](URL for tag specific to this version) - Description
38-
* [vEyyFyyZyyHyyLyySyy](URL for tag specific to this version) - Description
20+
21+
* **[Installing an Arduino Library Guide](https://learn.sparkfun.com/tutorials/installing-an-arduino-library)** - Basic information on how to install an Arduino library.
22+
* **[Hookup Guide](https://docs.sparkfun.com/SparkFun_IoT_Brushless_Motor_Driver)** - Basic hookup guide for the SparkFun IoT Motor Driver Breakout (ESP32, TMC6300).
23+
* **[Product Repository](https://github.com/sparkfun/SparkFun_IoT_Brushless_Motor_Driver)** - Main repository for the IoT Motor Driver (including hardware files)
24+
25+
26+
Products that use this Library
27+
---------------------------------
28+
29+
* [*SEN-22494*](https://www.sparkfun.com/products/22494)
30+
* [*SEN-23253*](https://www.sparkfun.com/products/23253)
31+
3932

4033
License Information
4134
-------------------

examples/Example1_BasicReadings/Example1_BasicReadings.ino

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ STHS34PF80_I2C mySensor;
66
// Values to fill with presence and motion data
77
int16_t presenceVal = 0;
88
int16_t motionVal = 0;
9+
float temperatureVal = 0;
910

1011

1112
void setup()
@@ -47,13 +48,22 @@ void loop()
4748
// Presence Units: cm^-1
4849
mySensor.getPresenceValue(&presenceVal);
4950
Serial.print("Presence: ");
50-
Serial.println(presenceVal);
51+
Serial.print(presenceVal);
52+
Serial.println(" cm^-1");
5153
}
5254

5355
if(status.mot_flag == 1)
5456
{
5557
Serial.println("Motion Detected!");
5658
}
59+
60+
if(status.tamb_shock_flag == 1)
61+
{
62+
mySensor.getTemperatureData(&temperatureVal);
63+
Serial.print("Temperature: ");
64+
Serial.print(temperatureVal);
65+
Serial.println(" °C");
66+
}
5767
}
5868

5969
}

examples/Example2_Interrupts/Example2_Interrupts.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ void setup()
3131
}
3232

3333
// Establish communication with device
34-
if(mySensor.begin() != 0)
34+
if(mySensor.begin() == false)
3535
{
36-
Serial.println("Sensor failed to begin - Check wiring.");
36+
Serial.println("Error setting up device - please check wiring.");
3737
while(1);
3838
}
3939

examples/Example3_EmbeddedFunctions/Example3_EmbeddedFunctions.ino

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ uint8_t hysteresis = 100;
1313
void setup()
1414
{
1515
Serial.begin(115200);
16-
Serial.println("STHS34PF80 Example 3: Using Embedded Functions");
16+
Serial.println("STHS34PF80 Example 1: Basic Readings");
1717

1818
// Begin I2C
1919
if(Wire.begin() == false)
@@ -23,9 +23,9 @@ void setup()
2323
}
2424

2525
// Establish communication with device
26-
if(mySensor.begin() != 0)
26+
if(mySensor.begin() == false)
2727
{
28-
Serial.println("Sensor failed to begin - Check wiring.");
28+
Serial.println("Error setting up device - please check wiring.");
2929
while(1);
3030
}
3131

@@ -57,10 +57,12 @@ void setup()
5757

5858
void loop()
5959
{
60-
// General presence and motion read (from example 1)
61-
bool dataReady = mySensor.getDataReady();
62-
63-
if(dataReady == 1)
60+
// General presence and motion read (from example 1)
61+
sths34pf80_tmos_drdy_status_t dataReady;
62+
mySensor.getDataReady(&dataReady);
63+
64+
// Check whether sensor has new data - run through loop if data is ready
65+
if(dataReady.drdy == 1)
6466
{
6567
sths34pf80_tmos_func_status_t status;
6668
mySensor.getStatus(&status);

examples/Example4_SPIFunctionality/Example4_SPIFunctionality.ino

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,18 @@ void setup()
1919
digitalWrite(chipSelect, HIGH);
2020

2121
// Begin SPI
22-
if( !mySensor.begin(chipSelect) )
22+
if(SPI.begin() == false)
2323
{
24-
Serial.println("Sensor failed to begin - Check wiring.");
25-
while(1);
26-
}
24+
Serial.println("SPI Error - check SPI Wiring");
25+
while(1);
26+
}
27+
28+
// Establish communication with device
29+
if(mySensor.begin(chipSelect) == false)
30+
{
31+
Serial.println("Error setting up device - please check wiring.");
32+
while(1);
33+
}
2734

2835
// Set the ODR to a faster rate for quicker outputs
2936
// Default ODR: 1Hz
@@ -34,35 +41,36 @@ void setup()
3441

3542
void loop()
3643
{
37-
bool dataReady = mySensor.getDataReady();
38-
39-
// Check if the presence (data ready) flag is high. If so, print the presence value
40-
if(dataReady == 1)
44+
sths34pf80_tmos_drdy_status_t dataReady;
45+
mySensor.getDataReady(&dataReady);
46+
47+
// Check whether sensor has new data - run through loop if data is ready
48+
if(dataReady.drdy == 1)
4149
{
4250
sths34pf80_tmos_func_status_t status;
4351
mySensor.getStatus(&status);
4452

45-
Serial.println("Data ready!");
46-
47-
// If the flag is high, then read out the information
53+
// If presence flag is high, then print data
4854
if(status.pres_flag == 1)
4955
{
5056
// Presence Units: cm^-1
5157
mySensor.getPresenceValue(&presenceVal);
5258
Serial.print("Presence: ");
5359
Serial.print(presenceVal);
54-
Serial.println("cm^-1");
60+
Serial.println(" cm^-1");
5561
}
5662

57-
// Motion detected or not
5863
if(status.mot_flag == 1)
5964
{
60-
Serial.println("Motion detected! ");
65+
Serial.println("Motion Detected!");
6166
}
6267

6368
if(status.tamb_shock_flag == 1)
6469
{
65-
Serial.println("Ambient temperature shock detected! ");
70+
mySensor.getTemperatureData(&temperatureVal);
71+
Serial.print("Temperature: ");
72+
Serial.print(temperatureVal);
73+
Serial.println(" °C");
6674
}
6775
}
6876
}

examples/Example5_ArduinoPlotterOutput/Example5_ArduinoPlotterOutput.ino

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ int16_t presenceVal = 0;
99
void setup()
1010
{
1111
Serial.begin(115200);
12-
Serial.println("STHS34PF80 Example 5: Arduino Serial Plotter Presence Output");
12+
Serial.println("STHS34PF80 Example 1: Basic Readings");
1313

1414
// Begin I2C
1515
if(Wire.begin() == false)
@@ -19,9 +19,9 @@ void setup()
1919
}
2020

2121
// Establish communication with device
22-
if(mySensor.begin() != 0)
22+
if(mySensor.begin() == false)
2323
{
24-
Serial.println("Sensor failed to begin - Check wiring.");
24+
Serial.println("Error setting up device - please check wiring.");
2525
while(1);
2626
}
2727

@@ -32,10 +32,11 @@ void setup()
3232

3333
void loop()
3434
{
35+
sths34pf80_tmos_drdy_status_t dataReady;
36+
mySensor.getDataReady(&dataReady);
3537

36-
bool dataReady = mySensor.getDataReady();
37-
38-
if(dataReady == 1)
38+
// Check whether sensor has new data - run through loop if data is ready
39+
if(dataReady.drdy == 1)
3940
{
4041
sths34pf80_tmos_func_status_t status;
4142
mySensor.getStatus(&status);

0 commit comments

Comments
 (0)