Skip to content

Commit de47cd7

Browse files
Updated examples
Now using begin() and increased update rate to once every 20ms
1 parent a332ed2 commit de47cd7

File tree

6 files changed

+13
-9
lines changed

6 files changed

+13
-9
lines changed

examples/Example1_BasicReadings/Example1_BasicReadings.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ void loop(){ //print the thermocouple, ambient and delta temperatures every 200m
5151
Serial.print(tempSensor.getTempDelta());
5252
Serial.print(" °C");
5353
Serial.println();
54-
//delay(200);
54+
delay(20); //don't hammer too hard on the I2C bus
5555
}
5656
}

examples/Example2_SetThermocoupleType/Example2_SetThermocoupleType.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@ void loop(){ //print the thermocouple, ambient and delta temperatures every 200m
6969
Serial.print(tempSensor.getTempDelta());
7070
Serial.print(" °C");
7171
Serial.println();
72-
delay(200);
72+
delay(20);
7373
}
7474
}

examples/Example3_SetFilterCoefficient/Example3_SetFilterCoefficient.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ void setup(){
3232
Serial.begin(115200);
3333
Wire.begin();
3434
Wire.setClock(100000);
35+
tempSensor.begin();
3536

3637
//check if the sensor is connected
3738
if(tempSensor.isConnected()){
@@ -45,8 +46,6 @@ void setup(){
4546
//check if the Device ID is correct
4647
if(tempSensor.checkDeviceID()){
4748
Serial.println("Device ID is correct!");
48-
Serial.print("Device ID reported as: 0x");
49-
Serial.println(tempSensor.readDoubleRegister(DEVICE_ID), HEX);
5049
}
5150
else {
5251
Serial.println("Device ID is not correct! Freezing.");
@@ -80,8 +79,9 @@ void loop(){ //print the thermocouple, ambient and delta temperatures every 200m
8079
Serial.print(tempSensor.getAmbientTemp());
8180
Serial.print(" °C Temperature Delta: ");
8281
Serial.print(tempSensor.getTempDelta());
83-
Serial.print(" °C");
82+
Serial.print(" °C Filter Coefficient: ");
83+
Serial.print(tempSensor.getFilterCoefficient(), DEC);
8484
Serial.println();
85-
delay(200);
85+
delay(20); //don't pound on the I2C bus too hard
8686
}
8787
}

examples/Example4_SetResolution/Example4_SetResolution.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ void setup(){
5050
Serial.begin(115200);
5151
Wire.begin();
5252
Wire.setClock(100000);
53+
tempSensor.begin();
54+
5355
//check if the sensor is connected
5456
if(tempSensor.isConnected()){
5557
Serial.println("Device will acknowledge!");
@@ -83,6 +85,6 @@ void loop(){ //print the thermocouple, ambient and delta temperatures every 200m
8385
Serial.print(tempSensor.getTempDelta());
8486
Serial.print(" °C");
8587
Serial.println();
86-
delay(200);
88+
delay(20); //don't pound on the I2C bus too hard
8789
}
8890
}

examples/Example5_BurstMode/Example5_BurstMode.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ void setup(){
2626
Serial.begin(115200);
2727
Wire.begin();
2828
Wire.setClock(100000);
29+
tempSensor.begin();
2930

3031
//check if the sensor is connected
3132
if(tempSensor.isConnected()){

examples/Example6_ConfigureTemperatureAlert/Example6_ConfigureTemperatureAlert.ino

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ void setup(){
3535
Serial.begin(115200);
3636
Wire.begin();
3737
Wire.setClock(100000);
38+
tempSensor.begin();
3839

3940
//check if the sensor is connected
4041
if(tempSensor.isConnected()){
@@ -86,9 +87,9 @@ void setup(){
8687
}
8788

8889
unsigned long clock = millis();
89-
uint16_t updateTime = 200;
90+
uint16_t updateTime = 20;
9091
void loop(){
91-
if((clock + updateTime) < millis()){
92+
if((clock + updateTime) < millis()){ //update every 20ms without blocking!
9293
Serial.print("Thermocouple: ");
9394
Serial.print(tempSensor.getThermocoupleTemp());
9495
Serial.print(" °C Ambient: ");

0 commit comments

Comments
 (0)