Datasheet

www.sensirion.com
Version 1.0 July 2020 D1
12/19
4.6 Checksum Calculation
The 8-bit CRC checksum transmitted after each data word is generated by the CRC algorithm according to the properties as
stated in Table 7. The CRC covers the contents of the two previously transmitted data bytes.
Property
Value
Example code
Name
CRC-8
uint8_t CalcCrc(uint8_t data[2]) {
uint8_t crc = 0xFF;
for(int i = 0; i < 2; i++) {
crc ^= data[i];
for(uint8_t bit = 8; bit > 0; --bit) {
if(crc & 0x80) {
crc = (crc << 1) ^ 0x31u;
} else {
crc = (crc << 1);
}
}
}
return crc;
}
Width
8 bit
Protected Data
read and/or write data
Polynomial
0x31 (x8 + x5 + x4 + 1)
Initialization
0xFF
Reflect input
False
Reflect output
False
Final XOR
0x00
Examples
CRC (0xBE EF) = 0x92
Table 7 Checksums are used for the 2-byte data packets only. The command codes themselves already contain a 3-bit CRC and therefore,
a checksum must not be appended.
4.7 I
2
C Commands
The available measurement commands of the SGP40 are listed in Table 8.
Command
Command hex.
code
Parameter length
including CRC
[bytes]
Response length
including CRC
[bytes]
Measurement duration
[ms]
Typ.
Max.
sgp40_measure_raw
0x26 0F
6
3
25
30
sgp40_measure_test
0x28 0E
3
240
250
sgp40_heater_off
0x36 15
0.1
1
Table 8 I
2
C commands available for SGP40.