-
Notifications
You must be signed in to change notification settings - Fork 0
/
sen66_i2c.h
999 lines (948 loc) · 38.4 KB
/
sen66_i2c.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
/*
* THIS FILE IS AUTOMATICALLY GENERATED
*
* Generator: sensirion-driver-generator 1.0.1
* Product: sen66
* Model-Version: 1.3.1
*/
/*
* Copyright (c) 2024, Sensirion AG
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of Sensirion AG nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SEN66_I2C_H
#define SEN66_I2C_H
#ifdef __cplusplus
extern "C" {
#endif
#include "sensirion_config.h"
#define SEN66_I2C_ADDR_6B 0x6b
typedef enum {
SEN66_START_CONTINUOUS_MEASUREMENT_CMD_ID = 0x21,
SEN66_STOP_MEASUREMENT_CMD_ID = 0x104,
SEN66_GET_DATA_READY_CMD_ID = 0x202,
SEN66_READ_MEASURED_VALUES_AS_INTEGERS_CMD_ID = 0x300,
SEN66_READ_NUMBER_CONCENTRATION_VALUES_AS_INTEGERS_CMD_ID = 0x316,
SEN66_READ_MEASURED_RAW_VALUES_CMD_ID = 0x405,
SEN66_START_FAN_CLEANING_CMD_ID = 0x5607,
SEN66_SET_TEMPERATURE_OFFSET_PARAMETERS_CMD_ID = 0x60b2,
SEN66_SET_VOC_ALGORITHM_TUNING_PARAMETERS_CMD_ID = 0x60d0,
SEN66_GET_VOC_ALGORITHM_TUNING_PARAMETERS_CMD_ID = 0x60d0,
SEN66_SET_NOX_ALGORITHM_TUNING_PARAMETERS_CMD_ID = 0x60e1,
SEN66_GET_NOX_ALGORITHM_TUNING_PARAMETERS_CMD_ID = 0x60e1,
SEN66_SET_TEMPERATURE_ACCELERATION_PARAMETERS_CMD_ID = 0x6100,
SEN66_SET_VOC_ALGORITHM_STATE_CMD_ID = 0x6181,
SEN66_GET_VOC_ALGORITHM_STATE_CMD_ID = 0x6181,
SEN66_PERFORM_FORCED_CO2_RECALIBRATION_CMD_ID = 0x6707,
SEN66_SET_CO2_SENSOR_AUTOMATIC_SELF_CALIBRATION_CMD_ID = 0x6711,
SEN66_GET_CO2_SENSOR_AUTOMATIC_SELF_CALIBRATION_CMD_ID = 0x6711,
SEN66_SET_AMBIENT_PRESSURE_CMD_ID = 0x6720,
SEN66_GET_AMBIENT_PRESSURE_CMD_ID = 0x6720,
SEN66_SET_SENSOR_ALTITUDE_CMD_ID = 0x6736,
SEN66_GET_SENSOR_ALTITUDE_CMD_ID = 0x6736,
SEN66_ACTIVATE_SHT_HEATER_CMD_ID = 0x6765,
SEN66_GET_PRODUCT_NAME_CMD_ID = 0xd014,
SEN66_GET_SERIAL_NUMBER_CMD_ID = 0xd033,
SEN66_READ_DEVICE_STATUS_CMD_ID = 0xd206,
SEN66_READ_AND_CLEAR_DEVICE_STATUS_CMD_ID = 0xd210,
SEN66_DEVICE_RESET_CMD_ID = 0xd304,
} SEN66_CMD_ID;
typedef union {
struct {
uint32_t reserved1 : 4;
uint32_t fan_error : 1;
uint32_t reserved2 : 1;
uint32_t rht_error : 1;
uint32_t gas_error : 1;
uint32_t reserved3 : 1;
uint32_t co2_2_error : 1;
uint32_t reserved4 : 1;
uint32_t pm_error : 1;
uint32_t reserved5 : 1;
uint32_t reserved6 : 8;
uint32_t fan_speed_warning : 1;
};
uint32_t value;
} sen66_device_status;
/**
* @brief Initialize i2c address of driver
*
* @param[in] i2c_address Used i2c address
*
*/
void sen66_init(uint8_t i2c_address);
/**
* @brief sen66_signal_mass_concentration_pm1p0
*
* @param[in] mass_concentration_pm1p0_raw
*
* @return Mass concentration in μg/m³ for particles smaller than 1.0 μm
*/
float sen66_signal_mass_concentration_pm1p0(
uint16_t mass_concentration_pm1p0_raw);
/**
* @brief sen66_signal_mass_concentration_pm2p5
*
* @param[in] mass_concentration_pm2p5_raw
*
* @return Mass concentration in μg/m³ for particles smaller than 2.5 μm
*/
float sen66_signal_mass_concentration_pm2p5(
uint16_t mass_concentration_pm2p5_raw);
/**
* @brief sen66_signal_mass_concentration_pm4p0
*
* @param[in] mass_concentration_pm4p0_raw
*
* @return Mass concentration in μg/m³ for particles smaller than 4.0 μm
*/
float sen66_signal_mass_concentration_pm4p0(
uint16_t mass_concentration_pm4p0_raw);
/**
* @brief sen66_signal_mass_concentration_pm10p0
*
* @param[in] mass_concentration_pm10p0_raw
*
* @return Mass concentration in μg/m³ for particles smaller than 10.0 μm
*/
float sen66_signal_mass_concentration_pm10p0(
uint16_t mass_concentration_pm10p0_raw);
/**
* @brief sen66_signal_number_concentration_pm0p5
*
* @param[in] number_concentration_pm0p5_raw
*
* @return Number concentration in particles/cm³ for particles smaller than 0.5
* μm
*/
float sen66_signal_number_concentration_pm0p5(
uint16_t number_concentration_pm0p5_raw);
/**
* @brief sen66_signal_number_concentration_pm1p0
*
* @param[in] number_concentration_pm1p0_raw
*
* @return Number concentration in particles/cm³ for particles smaller than 1.0
* μm
*/
float sen66_signal_number_concentration_pm1p0(
uint16_t number_concentration_pm1p0_raw);
/**
* @brief sen66_signal_number_concentration_pm2p5
*
* @param[in] number_concentration_pm2p5_raw
*
* @return Number concentration in particles/cm³ for particles smaller than 2.5
* μm
*/
float sen66_signal_number_concentration_pm2p5(
uint16_t number_concentration_pm2p5_raw);
/**
* @brief sen66_signal_number_concentration_pm4p0
*
* @param[in] number_concentration_pm4p0_raw
*
* @return Number concentration in particles/cm³ for particles smaller than 4.0
* μm
*/
float sen66_signal_number_concentration_pm4p0(
uint16_t number_concentration_pm4p0_raw);
/**
* @brief sen66_signal_number_concentration_pm10p0
*
* @param[in] number_concentration_pm10p0_raw
*
* @return Number concentration in particles/cm³ for particles smaller than 10.0
* μm
*/
float sen66_signal_number_concentration_pm10p0(
uint16_t number_concentration_pm10p0_raw);
/**
* @brief sen66_signal_temperature
*
* @param[in] temperature_raw
*
* @return Measured temperature in degrees celsius. The raw value is scaled
* appropriately.
*/
float sen66_signal_temperature(int16_t temperature_raw);
/**
* @brief sen66_signal_humidity
*
* @param[in] humidity_raw
*
* @return Measured humidity in %RH. The raw value is scaled appropriately.
*/
float sen66_signal_humidity(int16_t humidity_raw);
/**
* @brief sen66_signal_voc_index
*
* @param[in] voc_index_raw
*
* @return Measured VOC Index ticks.
*/
float sen66_signal_voc_index(int16_t voc_index_raw);
/**
* @brief sen66_signal_nox_index
*
* @param[in] nox_index_raw
*
* @return Measured NOx Index ticks.
*/
float sen66_signal_nox_index(int16_t nox_index_raw);
/**
* @brief sen66_signal_co2
*
* @param[in] co2_raw
*
* @return Measured CO2 in ppm.
*/
uint16_t sen66_signal_co2(uint16_t co2_raw);
/**
* @brief Read measured values and apply scaling as defined in datasheet.
*
* @param[out] mass_concentration_pm1p0 Mass concentration in μg/m³ for
* particles smaller than 1.0 μm.
* @param[out] mass_concentration_pm2p5 Mass concentration in μg/m³ for
* particles smaller than 2.5 μm.
* @param[out] mass_concentration_pm4p0 Mass concentration in μg/m³ for
* particles smaller than 4.0 μm.
* @param[out] mass_concentration_pm10p0 Mass concentration in μg/m³ for
* particles smaller than 10.0 μm.
* @param[out] humidity Measured humidity in %RH.
* @param[out] temperature Measured temperature in degrees celsius.
* @param[out] voc_index Measured VOC Index between 0 and 500.
* @param[out] nox_index Measured NOx Index between 0 and 500.
* @param[out] co2 Measured CO2 concentration in ppm.
*
* @return error_code 0 on success, an error code otherwise.
*/
int16_t sen66_read_measured_values(float* mass_concentration_pm1p0,
float* mass_concentration_pm2p5,
float* mass_concentration_pm4p0,
float* mass_concentration_pm10p0,
float* humidity, float* temperature,
float* voc_index, float* nox_index,
uint16_t* co2);
/**
* @brief Read measured number concentration values and apply scaling as defined
* in datasheet.
*
* @param[out] number_concentration_pm0p5 Number concentration in particles/cm³
* for particles smaller than 0.5 μm.
* @param[out] number_concentration_pm1p0 Number concentration in particles/cm³
* for particles smaller than 1.0 μm.
* @param[out] number_concentration_pm2p5 Number concentration in particles/cm³
* for particles smaller than 2.5 μm.
* @param[out] number_concentration_pm4p0 Number concentration in particles/cm³
* for particles smaller than 4.0 μm.
* @param[out] number_concentration_pm10p0 Number concentration in particles/cm³
* for particles smaller than 10.0 μm.
*
* @return error_code 0 on success, an error code otherwise.
*/
int16_t sen66_read_number_concentration_values(
float* number_concentration_pm0p5, float* number_concentration_pm1p0,
float* number_concentration_pm2p5, float* number_concentration_pm4p0,
float* number_concentration_pm10p0);
/**
* @brief Start a continuous measurement (interval 1s)
*
* Starts a continuous measurement. After starting the measurement, it takes
* some time (~1.1s) until the first measurement results are available. You
* could poll with the command "Get Data Ready" to check when the results are
* ready to read. This command is only available in idle mode. If the device is
* already in any measure mode, this command has no effect.
*
* @return error_code 0 on success, an error code otherwise.
*/
int16_t sen66_start_continuous_measurement();
/**
* @brief Stop the continuous measurement
*
* Stops the measurement and returns to idle mode. After sending this command,
* wait at least 1000 ms before starting a new measurement. If the device is
* already in idle mode, this command has no effect.
*
* @return error_code 0 on success, an error code otherwise.
*/
int16_t sen66_stop_measurement();
/**
* @brief Check if data is ready to be read out from the sensor
*
* This command can be used to check if new measurement results are ready to
* read. The data ready flag is automatically reset after reading the
* measurement values.
*
* @param[out] padding Padding byte, always 0x00.
* @param[out] data_ready True (0x01) if data is ready, False (0x00) if not.
* When no measurement is running, False will be returned.
*
* @return error_code 0 on success, an error code otherwise.
*/
int16_t sen66_get_data_ready(uint8_t* padding, bool* data_ready);
/**
* @brief read measured values as integers.
*
* Returns the measured values. The command "Get Data Ready" can be used to
* check if new data is available since the last read operation. If no new data
* is available, the previous values will be returned again. If no data is
* available at all (e.g. measurement not running for at least one second), all
* values will be at their upper limit (0xFFFF for uint16, 0x7FFF for int16).
*
* @param[out] mass_concentration_pm1p0 Value is scaled with factor 10: PM1.0
* [µg/m³] = value / 10 *Note: If this value is unknown, 0xFFFF is returned.*
* @param[out] mass_concentration_pm2p5 Value is scaled with factor 10: PM2.5
* [µg/m³] = value / 10 *Note: If this value is unknown, 0xFFFF is returned.*
* @param[out] mass_concentration_pm4p0 Value is scaled with factor 10: PM4.0
* [µg/m³] = value / 10 *Note: If this value is unknown, 0xFFFF is returned.*
* @param[out] mass_concentration_pm10p0 Value is scaled with factor 10: PM10.0
* [µg/m³] = value / 10 *Note: If this value is unknown, 0xFFFF is returned.*
* @param[out] ambient_humidity Value is scaled with factor 100: RH [%] = value
* / 100 *Note: If this value is unknown, 0x7FFF is returned.*
* @param[out] ambient_temperature Value is scaled with factor 200: T [°C] =
* value / 200 *Note: If this value is unknown, 0x7FFF is returned.*
* @param[out] voc_index Value is scaled with factor 10: VOC Index = value / 10
* *Note: If this value is unknown, 0x7FFF is returned.*
* @param[out] nox_index Value is scaled with factor 10: NOx Index = value / 10
* *Note: If this value is unknown, 0x7FFF is returned. During the first 10..11
* seconds after power-on or device reset, this value will be 0x7FFF as well.*
* @param[out] co2 CO₂ concentration [ppm] *Note: If this value is unknown,
* 0xFFFF is returned. During the first 5..6 seconds after power-on or device
* reset, this value will be 0xFFFF as well.*
*
* @return error_code 0 on success, an error code otherwise.
*/
int16_t sen66_read_measured_values_as_integers(
uint16_t* mass_concentration_pm1p0, uint16_t* mass_concentration_pm2p5,
uint16_t* mass_concentration_pm4p0, uint16_t* mass_concentration_pm10p0,
int16_t* ambient_humidity, int16_t* ambient_temperature, int16_t* voc_index,
int16_t* nox_index, uint16_t* co2);
/**
* @brief sen66_read_number_concentration_values_as_integers
*
* Returns the measured number concentration values. The command "Get Data
* Ready" can be used to check if new data is available since the last read
* operation. If no new data is available, the previous values will be returned
* again. If no data is available at all (e.g. measurement not running for at
* least one second), all values will be at their upper limit (0xFFFF for
* uint16).
*
* @param[out] number_concentration_pm0p5 Value is scaled with factor 10: PM0.5
* [particles/cm³] = value / 10 *Note: If this value is unknown, 0xFFFF is
* returned.*
* @param[out] number_concentration_pm1p0 Value is scaled with factor 10: PM1.0
* [particles/cm³] = value / 10 *Note: If this value is unknown, 0xFFFF is
* returned.*
* @param[out] number_concentration_pm2p5 Value is scaled with factor 10: PM2.5
* [particles/cm³] = value / 10 *Note: If this value is unknown, 0xFFFF is
* returned.*
* @param[out] number_concentration_pm4p0 Value is scaled with factor 10: PM4.0
* [particles/cm³] = value / 10 *Note: If this value is unknown, 0xFFFF is
* returned.*
* @param[out] number_concentration_pm10p0 Value is scaled with factor 10:
* PM10.0 [particles/cm³] = value / 10 *Note: If this value is unknown, 0xFFFF
* is returned.*
*
* @return error_code 0 on success, an error code otherwise.
*/
int16_t sen66_read_number_concentration_values_as_integers(
uint16_t* number_concentration_pm0p5, uint16_t* number_concentration_pm1p0,
uint16_t* number_concentration_pm2p5, uint16_t* number_concentration_pm4p0,
uint16_t* number_concentration_pm10p0);
/**
* @brief sen66_read_measured_raw_values
*
* Returns the measured raw values. The command "Get Data Ready" can be used to
* check if new data is available since the last read operation. If no new data
* is available, the previous values will be returned again. If no data is
* available at all (e.g. measurement not running for at least one second), all
* values will be at their upper limit (0xFFFF for uint16, 0x7FFF for int16).
*
* @param[out] raw_humidity Value is scaled with factor 100: RH [%] = value /
* 100 *Note: If this value is unknown, 0x7FFF is returned.*
* @param[out] raw_temperature Value is scaled with factor 200: T [°C] = value /
* 200 *Note: If this value is unknown, 0x7FFF is returned.*
* @param[out] raw_voc Raw measured VOC ticks without scale factor. *Note: If
* this value is unknown, 0xFFFF is returned.*
* @param[out] raw_nox Raw measured NOx ticks without scale factor. *Note: If
* this value is unknown, 0xFFFF is returned. During the first 10..11 seconds
* after power-on or device reset, this value will be 0xFFFF as well.*
* @param[out] raw_co2 Not interpolated CO₂ concentration [ppm] updated every
* five seconds. *Note: If this value is unknown, 0xFFFF is returned. During the
* first 5..6 seconds after power-on or device reset, this value will be 0xFFFF
* as well.*
*
* @return error_code 0 on success, an error code otherwise.
*/
int16_t sen66_read_measured_raw_values(int16_t* raw_humidity,
int16_t* raw_temperature,
uint16_t* raw_voc, uint16_t* raw_nox,
uint16_t* raw_co2);
/**
* @brief sen66_start_fan_cleaning
*
* This command triggers fan cleaning. The fan is set to the maximum speed for
* 10 seconds and then automatically stopped. Wait at least 10s after this
* command before starting a measurement.
*
* @note This command is only available in idle mode.
*
* @return error_code 0 on success, an error code otherwise.
*/
int16_t sen66_start_fan_cleaning();
/**
* @brief sen66_set_temperature_offset_parameters
*
* This command allows to compensate temperature effects of the design-in at
* customer side by applying custom temperature offsets to the ambient
* temperature. The compensated ambient temperature is calculated as follows:
* T_Ambient_Compensated = T_Ambient + (slope * T_Ambient) + offset Where slope
* and offset are the values set with this command, smoothed with the specified
* time constant. All temperatures (T_Ambient_Compensated, T_Ambient and offset)
* are represented in °C. There are 5 temperature offset slots available that
* all contribute additively to T_Ambient_Compensated. The default values for
* the temperature offset parameters are all zero, meaning that
* T_Ambient_Compensated is equal to T_Ambient by default. The parameters can be
* changed in any state of the device, i.e. both in idle mode and in measure
* mode.
*
* @param[in] offset Constant temperature offset scaled with factor 200 (T [°C]
* = value / 200).
* @param[in] slope Normalized temperature offset slope scaled with factor 10000
* (applied factor = value / 10000).
* @param[in] time_constant The time constant determines how fast the new slope
* and offset will be applied. After the specified value in seconds, 63% of the
* new slope and offset are applied. A time constant of zero means the new
* values will be applied immediately (within the next measure interval of 1
* second).
* @param[in] slot The temperature offset slot to be modified. Valid values are
* 0 .. 4. If the value is outside this range, the parameters will not be
* applied.
*
* @note This configuration is volatile, i.e. the parameters will be reverted to
* their default value of zero after a device reset.
*
* @return error_code 0 on success, an error code otherwise.
*
* Example:
* --------
*
* @code{.c}
*
* int16_t local_error = 0;
* local_error = sen66_set_temperature_offset_parameters(1, 10, 1, 0);
* if (local_error != NO_ERROR) {
* return local_error;
* }
*
* @endcode
*
*/
int16_t sen66_set_temperature_offset_parameters(int16_t offset, int16_t slope,
uint16_t time_constant,
uint16_t slot);
/**
* @brief sen66_set_voc_algorithm_tuning_parameters
*
* Sets the parameters to customize the VOC algorithm. This configuration is
* volatile, i.e. the parameters will be reverted to their default values after
* a device reset.
*
* @param[in] index_offset VOC index representing typical (average) conditions.
* Allowed values are in range 1..250. The default value is 100.
* @param[in] learning_time_offset_hours Time constant to estimate the VOC
* algorithm offset from the history in hours. Past events will be forgotten
* after about twice the learning time. Allowed values are in range 1..1000. The
* default value is 12 hours.
* @param[in] learning_time_gain_hours Time constant to estimate the VOC
* algorithm gain from the history in hours. Past events will be forgotten after
* about twice the learning time. Allowed values are in range 1..1000. The
* default value is 12 hours.
* @param[in] gating_max_duration_minutes Maximum duration of gating in minutes
* (freeze of estimator during high VOC index signal). Set to zero to disable
* the gating. Allowed values are in range 0..3000. The default value is 180
* minutes
* @param[in] std_initial Initial estimate for standard deviation. Lower value
* boosts events during initial learning period, but may result in larger
* device-to-device variations. Allowed values are in range 10..5000. The
* default value is 50.
* @param[in] gain_factor Gain factor to amplify or to attenuate the VOC index
* output. Allowed values are in range 1..1000. The default value is 230.
*
* @note This command is available only in idle mode. In measure mode, this
* command has no effect. In addition, it has no effect if at least one
* parameter is outside the specified range.
*
* @return error_code 0 on success, an error code otherwise.
*
* Example:
* --------
*
* @code{.c}
*
* int16_t local_error = 0;
* local_error = sen66_set_voc_algorithm_tuning_parameters(100, 12, 12, 180,
* 50, 230); if (local_error != NO_ERROR) { return local_error;
* }
*
* @endcode
*
*/
int16_t sen66_set_voc_algorithm_tuning_parameters(
int16_t index_offset, int16_t learning_time_offset_hours,
int16_t learning_time_gain_hours, int16_t gating_max_duration_minutes,
int16_t std_initial, int16_t gain_factor);
/**
* @brief sen66_get_voc_algorithm_tuning_parameters
*
* Gets the parameters to customize the VOC algorithm.
*
* @param[out] index_offset VOC index representing typical (average) conditions.
* @param[out] learning_time_offset_hours Time constant to estimate the VOC
* algorithm offset from the history in hours. Past events will be forgotten
* after about twice the learning time.
* @param[out] learning_time_gain_hours Time constant to estimate the VOC
* algorithm gain from the history in hours. Past events will be forgotten after
* about twice the learning time.
* @param[out] gating_max_duration_minutes Maximum duration of gating in minutes
* (freeze of estimator during high VOC index signal). Zero disables the gating.
* @param[out] std_initial Initial estimate for standard deviation. Lower value
* boosts events during initial learning period, but may result in larger
* device-to-device variations.
* @param[out] gain_factor Gain factor to amplify or to attenuate the VOC index
* output.
*
* @note This command is only available in idle mode.
*
* @return error_code 0 on success, an error code otherwise.
*/
int16_t sen66_get_voc_algorithm_tuning_parameters(
int16_t* index_offset, int16_t* learning_time_offset_hours,
int16_t* learning_time_gain_hours, int16_t* gating_max_duration_minutes,
int16_t* std_initial, int16_t* gain_factor);
/**
* @brief sen66_set_nox_algorithm_tuning_parameters
*
* Sets the parameters to customize the NOx algorithm. This configuration is
* volatile, i.e. the parameters will be reverted to their default values after
* a device reset.
*
* @param[in] index_offset NOx index representing typical (average) conditions.
* Allowed values are in range 1..250. The default value is 1.
* @param[in] learning_time_offset_hours Time constant to estimate the NOx
* algorithm offset from the history in hours. Past events will be forgotten
* after about twice the learning time. Allowed values are in range 1..1000. The
* default value is 12 hours.
* @param[in] learning_time_gain_hours The time constant to estimate the NOx
* algorithm gain from the history has no impact for NOx. This parameter is
* still in place for consistency reasons with the VOC tuning parameters
* command. This parameter must always be set to 12 hours.
* @param[in] gating_max_duration_minutes Maximum duration of gating in minutes
* (freeze of estimator during high NOx index signal). Set to zero to disable
* the gating. Allowed values are in range 0..3000. The default value is 720
* minutes.
* @param[in] std_initial The initial estimate for standard deviation parameter
* has no impact for NOx. This parameter is still in place for consistency
* reasons with the VOC tuning parameters command. This parameter must always be
* set to 50.
* @param[in] gain_factor Gain factor to amplify or to attenuate the NOx index
* output. Allowed values are in range 1..1000. The default value is 230.
*
* @note This command is available only in idle mode. In measure mode, this
* command has no effect. In addition, it has no effect if at least one
* parameter is outside the specified range.
*
* @return error_code 0 on success, an error code otherwise.
*
* Example:
* --------
*
* @code{.c}
*
* int16_t local_error = 0;
* local_error = sen66_set_nox_algorithm_tuning_parameters(1, 12, 12, 720,
* 50, 230); if (local_error != NO_ERROR) { return local_error;
* }
*
* @endcode
*
*/
int16_t sen66_set_nox_algorithm_tuning_parameters(
int16_t index_offset, int16_t learning_time_offset_hours,
int16_t learning_time_gain_hours, int16_t gating_max_duration_minutes,
int16_t std_initial, int16_t gain_factor);
/**
* @brief sen66_get_nox_algorithm_tuning_parameters
*
* Gets the parameters to customize the NOx algorithm.
*
* @param[out] index_offset NOx index representing typical (average) conditions.
* @param[out] learning_time_offset_hours Time constant to estimate the NOx
* algorithm offset from the history in hours. Past events will be forgotten
* after about twice the learning time.
* @param[out] learning_time_gain_hours The time constant to estimate the NOx
* algorithm gain from the history has no impact for NOx. This parameter is
* still in place for consistency reasons with the VOC tuning parameters
* command.
* @param[out] gating_max_duration_minutes Maximum duration of gating in minutes
* (freeze of estimator during high NOx index signal). Zero disables the gating.
* @param[out] std_initial The initial estimate for standard deviation has no
* impact for NOx. This parameter is still in place for consistency reasons with
* the VOC tuning parameters command.
* @param[out] gain_factor Gain factor to amplify or to attenuate the NOx index
* output.
*
* @note This command is available only in idle mode.
*
* @return error_code 0 on success, an error code otherwise.
*/
int16_t sen66_get_nox_algorithm_tuning_parameters(
int16_t* index_offset, int16_t* learning_time_offset_hours,
int16_t* learning_time_gain_hours, int16_t* gating_max_duration_minutes,
int16_t* std_initial, int16_t* gain_factor);
/**
* @brief sen66_set_temperature_acceleration_parameters
*
* This command allows to set custom temperature acceleration parameters of the
* RH/T engine. It overwrites the default temperature acceleration parameters of
* the RH/T engine with custom values. This configuration is volatile, i.e. the
* parameters will be reverted to their default values after a device reset.
*
* @param[in] k Filter constant K scaled with factor 10 (K = value / 10).
* @param[in] p Filter constant P scaled with factor 10 (P = value / 10).
* @param[in] t1 Time constant T1 scaled with factor 10 (T1 [s] = value / 10).
* @param[in] t2 Time constant T2 scaled with factor 10 (T2 [s] = value / 10).
*
* @note The command is only available in idle mode.
*
* @return error_code 0 on success, an error code otherwise.
*
* Example:
* --------
*
* @code{.c}
*
* int16_t local_error = 0;
* local_error = sen66_set_temperature_acceleration_parameters(1, 1, 1, 1);
* if (local_error != NO_ERROR) {
* return local_error;
* }
*
* @endcode
*
*/
int16_t sen66_set_temperature_acceleration_parameters(uint16_t k, uint16_t p,
uint16_t t1, uint16_t t2);
/**
* @brief sen66_set_voc_algorithm_state
*
* Sets the VOC algorithm state previously received with "Get VOC Algorithm
* State" command. Allows restoration of the VOC algorithm state to resume
* operation after a power cycle or device reset, skipping initial learning
* phase. By default, the VOC Engine is reset, and the algorithm state is
* retained if a measurement is stopped and started again. If the VOC algorithm
* state shall be reset, a device reset, or a power cycle can be executed.
*
* @param[in] state VOC algorithm state to restore.
*
* @note This command is only available in idle mode and the state will be
* applied only once when starting the next measurement. In measure mode, this
* command has no effect.
*
* @return error_code 0 on success, an error code otherwise.
*/
int16_t sen66_set_voc_algorithm_state(const uint8_t* state,
uint16_t state_size);
/**
* @brief sen66_get_voc_algorithm_state
*
* Gets the current VOC algorithm state. Allows to backup and restore the VOC
* algorithm state to resume operation after a power cycle or device reset,
* skipping initial learning phase. By default, the VOC Engine is reset and the
* algorithm state is retained if a measurement is stopped and started again.
* If the VOC algorithm state shall be reset, a device reset or a power cycle
* can be executed.
*
* @param[out] state Current VOC algorithm state.
*
* @note This command can be used either in measure mode or in idle mode (which
* will then return the state at the time when the measurement was stopped). In
* measure mode, the state can be read each measure interval to always have the
* latest state available, even in case of a sudden power loss.
*
* @return error_code 0 on success, an error code otherwise.
*/
int16_t sen66_get_voc_algorithm_state(uint8_t* state, uint16_t state_size);
/**
* @brief Perform Forced CO₂ Recalibration
*
* Execute the forced recalibration (FRC) of the CO₂. See the datasheet of the
* SCD4x sensor for details how the forced recalibration shall be used.
*
* @param[in] target_co2_concentration Target CO₂ concentration [ppm] of the
* test setup.
* @param[out] correction Correction value as received from the SCD [ppm CO₂].
* FRC correction [ppm CO₂] is calculated as follows: FRC = return_value -
* 0x8000 If the recalibration has failed this returned value is 0xFFFF.
*
* @note After power-on wait at least 1000 ms and after stopping a measurement
* 600 ms before sending this command. This command is not available in measure
* mode. The recalibration procedure will take about 500 ms to complete, during
* which time no other functions can be executed.
*
* @return error_code 0 on success, an error code otherwise.
*/
int16_t
sen66_perform_forced_co2_recalibration(uint16_t target_co2_concentration,
uint16_t* correction);
/**
* @brief sen66_set_co2_sensor_automatic_self_calibration
*
* Sets the status of the CO₂ sensor automatic self-calibration (ASC). The CO₂
* sensor supports automatic self calibration (ASC) for long-term stability of
* the CO₂ output. This feature can be enabled or disabled. By default it is
* enabled. This configuration is volatile, i.e. the parameter will be reverted
* to its default value after a device restart.
*
* @param[in] status Set to true (0x0001) to enable or false (0x0000) to disable
* the automatic CO₂ measurement self calibration feature. High byte of uint16
* is padding and always 0x00.
*
* @note This command is only available in idle mode.
*
* @return error_code 0 on success, an error code otherwise.
*
* Example:
* --------
*
* @code{.c}
*
* int16_t local_error = 0;
* local_error = sen66_set_co2_sensor_automatic_self_calibration(0);
* if (local_error != NO_ERROR) {
* return local_error;
* }
*
* @endcode
*
*/
int16_t sen66_set_co2_sensor_automatic_self_calibration(uint16_t status);
/**
* @brief sen66_get_co2_sensor_automatic_self_calibration
*
* The CO₂ sensor supports automatic self calibration (ASC) for long-term
* stability of the CO₂ output. This feature can be enabled or disabled. By
* default it is enabled. This configuration is volatile, i.e. the parameter
* will be reverted to its default value after a device restart.
*
* @param[out] padding Padding byte, always 0x00.
* @param[out] status Is set true (0x01) if the automatic self calibration is
* enabled or false (0x00) if the automatic self calibration is disabled.
*
* @note This command is only available in idle mode.
*
* @return error_code 0 on success, an error code otherwise.
*/
int16_t sen66_get_co2_sensor_automatic_self_calibration(uint8_t* padding,
bool* status);
/**
* @brief sen66_set_ambient_pressure
*
* The ambient pressure can be used for pressure compensation in the CO₂ sensor.
* Setting an ambient pressure overrides any pressure compensation based on a
* previously set sensor altitude. Use of this command is recommended for
* applications experiencing significant ambient pressure changes to ensure CO₂
* sensor accuracy. Valid input values are between 700 to 1'200 hPa. The default
* value is 1013 hPa. This configuration is volatile, i.e. the parameter will be
* reverted to its default value after a device restart.
*
* @param[in] ambient_pressure Ambient pressure [hPa] to be used for pressure
* compensation.
*
* @note This command can be used in any state of the device, i.e. both in idle
* mode and in measure mode.
*
* @return error_code 0 on success, an error code otherwise.
*
* Example:
* --------
*
* @code{.c}
*
* int16_t local_error = 0;
* local_error = sen66_set_ambient_pressure(1013);
* if (local_error != NO_ERROR) {
* return local_error;
* }
*
* @endcode
*
*/
int16_t sen66_set_ambient_pressure(uint16_t ambient_pressure);
/**
* @brief sen66_get_ambient_pressure
*
* Gets the ambient pressure value. The ambient pressure can be used for
* pressure compensation in the CO₂ sensor.
*
* @param[out] ambient_pressure Currently used ambient pressure [hPa] for
* pressure compensation.
*
* @note This command can be used in any state of the device, i.e. both in idle
* mode and in measure mode.
*
* @return error_code 0 on success, an error code otherwise.
*/
int16_t sen66_get_ambient_pressure(uint16_t* ambient_pressure);
/**
* @brief sen66_set_sensor_altitude
*
* The sensor altitude can be used for pressure compensation in the CO₂ sensor.
* The default sensor altitude value is set to 0 meters above sea level. Valid
* input values are between 0 and 3000m. This configuration is volatile, i.e.
* the parameter will be reverted to its default value after a device reset.
*
* @param[in] altitude Sensor altitude [m], valid input between 0 and 3000m.
*
* @return error_code 0 on success, an error code otherwise.
*
* Example:
* --------
*
* @code{.c}
*
* int16_t local_error = 0;
* local_error = sen66_set_sensor_altitude(0);
* if (local_error != NO_ERROR) {
* return local_error;
* }
*
* @endcode
*
*/
int16_t sen66_set_sensor_altitude(uint16_t altitude);
/**
* @brief sen66_get_sensor_altitude
*
* Gets the current sensor altitude. The sensor altitude can be used for
* pressure compensation in the CO₂ sensor.
*
* @param[out] altitude Current sensor altitude [m].
*
* @note This command is only available in idle mode.
*
* @return error_code 0 on success, an error code otherwise.
*/
int16_t sen66_get_sensor_altitude(uint16_t* altitude);
/**
* @brief Activate SHT Heater
*
* This command allows to use the inbuilt heater in SHT sensor to reverse creep
* at high humidity. This command activates the SHT sensor heater with 200mW for
* 1s. The heater is then automatically deactivated again. Wait at least 20s
* after this command before starting a measurement to get coherent temperature
* values (heating consequence to disappear).
*
* @note This command is only available in idle mode.
*
* @return error_code 0 on success, an error code otherwise.
*/
int16_t sen66_activate_sht_heater();
/**
* @brief sen66_get_product_name
*
* Gets the product name from the device.
*
* @param[out] product_name Null-terminated ASCII string containing the product
* name. Up to 32 characters can be read from the device.
*
* @return error_code 0 on success, an error code otherwise.
*/
int16_t sen66_get_product_name(uint8_t* product_name,
uint16_t product_name_size);
/**
* @brief sen66_get_serial_number
*
* Gets the serial number from the device.
*
* @param[out] serial_number Null-terminated ASCII string containing the serial
* number. Up to 32 characters can be read from the device.
*
* @return error_code 0 on success, an error code otherwise.
*/
int16_t sen66_get_serial_number(uint8_t* serial_number,
uint16_t serial_number_size);
/**
* @brief sen66_read_device_status
*
* Reads the current device status. Use this command to get detailed information
* about the device status. The device status is encoded in flags. Each device
* status flag represents a single bit in a 32-bit integer value. If more than
* one error is present, the device status register value is the sum of the
* corresponding flag values. For details about the available flags, refer to
* the device status flags documentation in the data sheet.
*
* @param[out] device_status Device status (32 flags as an integer value). For
* details, please refer to the device status flags documentation in the
* datasheet.
*
* @note The status flags of type "Error" are sticky, i.e. they are not cleared
* automatically even if the error condition no longer exists. So they can only
* be cleared manually with the command "Read And Clear Device Status" or with a
* device reset. All other flags are not sticky, i.e. they are cleared
* automatically if the trigger condition disappears.
*
* @return error_code 0 on success, an error code otherwise.
*/
int16_t sen66_read_device_status(sen66_device_status* device_status);
/**
* @brief sen66_read_and_clear_device_status
*
* Reads the current device status (like command 0xD206 "Read Device Status")
* and afterwards clears all flags.
*
* @param[out] device_status Device status (32 flags as an integer value)
* **before** clearing it. For details, please refer to the device status flags
* documentation.
*
* @return error_code 0 on success, an error code otherwise.
*/
int16_t sen66_read_and_clear_device_status(sen66_device_status* device_status);
/**
* @brief sen66_device_reset
*
* Executes a reset on the device. This has the same effect as a power cycle.
*
* @return error_code 0 on success, an error code otherwise.
*/
int16_t sen66_device_reset();
#ifdef __cplusplus
}
#endif
#endif // SEN66_I2C_H