Skip to content

Commit 12b51a6

Browse files
committed
Minor updates and fix in examples
1 parent 3596c8a commit 12b51a6

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

examples/serial-alarm/serial-alarm.ino

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* communication issues.
1010
*/
1111
#define I2C_FREQ_HZ 400000
12+
#define PERIODIC_MEAS_INTERVAL_IN_SECONDS 10
13+
#define ALARM_PPM_THRESHOLD 1200
1214

1315
uint8_t interrupt_pin = 9; /* For XMC2Go. Change it for your hardware setup */
1416

@@ -58,10 +60,10 @@ void setup()
5860
/*
5961
* Periodic measurement every 10 seconds.
6062
* Interrupt alarm when the CO2 value
61-
* goes over 25000 ppm. The isr function is
63+
* goes over 1200 ppm. The isr function is
6264
* passed enabling the sensor interrupt mode.
6365
*/
64-
err = cotwo.startMeasure(10, 1200, isr);
66+
err = cotwo.startMeasure(PERIODIC_MEAS_INTERVAL_IN_SECONDS, ALARM_PPM_THRESHOLD, isr);
6567
if(XENSIV_PASCO2_OK != err)
6668
{
6769
Serial.print("start measure error: ");

examples/serial-forced-compensation/serial-forced-compensation.ino

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,26 @@ void setup()
4848
Serial.println(err);
4949
}
5050

51+
err = cotwo.setPressRef(PRESSURE_REFERENCE);
52+
if (XENSIV_PASCO2_OK != err)
53+
{
54+
Serial.print("pressure reference error: ");
55+
Serial.println(err);
56+
}
57+
58+
Serial.print("forced compensation started with ");
59+
Serial.print(FORCED_COMPENSATION_CO2_REFERENCE);
60+
Serial.println(" ppm baseline reference ...");
61+
62+
err = cotwo.performForcedCompensation(FORCED_COMPENSATION_CO2_REFERENCE);
63+
if (XENSIV_PASCO2_OK != err)
64+
{
65+
Serial.print("forced compensation error: ");
66+
Serial.println(err);
67+
}
68+
69+
Serial.println("forced compensation finished");
70+
5171
/*
5272
* Configure the sensor to measureme periodically
5373
* every 10 seconds
@@ -65,8 +85,6 @@ void loop()
6585
/* Wait for the value to be ready. */
6686
delay(PERIODIC_MEAS_INTERVAL_IN_SECONDS*1000);
6787

68-
co2ppm = 0;
69-
7088
err = cotwo.getCO2(co2ppm);
7189
if(XENSIV_PASCO2_OK != err)
7290
{
@@ -98,22 +116,4 @@ void loop()
98116
Serial.print("pressure reference error: ");
99117
Serial.println(err);
100118
}
101-
102-
err = cotwo.performForcedCompensation(FORCED_COMPENSATION_CO2_REFERENCE);
103-
if(XENSIV_PASCO2_OK != err)
104-
{
105-
Serial.print("forced compensation error: ");
106-
Serial.println(err);
107-
}
108-
109-
/*
110-
* Restart, as after performForcedCompensation function
111-
* the sensor returns to IDLE mode.
112-
*/
113-
err = cotwo.startMeasure(PERIODIC_MEAS_INTERVAL_IN_SECONDS);
114-
if(XENSIV_PASCO2_OK != err)
115-
{
116-
Serial.print("start measure error: ");
117-
Serial.println(err);
118-
}
119119
}

examples/serial-single-shot/serial-single-shot.ino

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ void loop()
5555
/* Wait for the value to be ready. */
5656
delay(5000);
5757

58-
co2ppm = 0;
59-
6058
/**
6159
* getCO2() is called until the value is
6260
* available.

0 commit comments

Comments
 (0)