# co2_t6613_i2c

co2_t6613_i2c, read values from GE/Telaire T6613 CO2 sensor.

Author | Eur van Andel, eur@fiwihex.nl Copyright © 2013
Adapted-by |
Compiler | =2.4o

Description

    This library communicates with the T6613 GE/Telaire CO2 sensor,
    via I2C. The protocol doc isn't on the web: email eur@fiwihex.nl to get it.
    available functions are:
    get_status() return byte
    get_co2_ppm() return word           -- CO2 concentration in ppm
    get_serial_numer() return string[15]
    get_elevation_m() return word       -- in meters above sea level

    -------
    declare in your main program, before including this library:
    const word _i2c_bus_speed = 1 -- * 100kHz
    const bit _i2c_level = true
    include i2c_hardware                         -- there is software i2c too
    i2c_initialize()
    var bit tx_ok                                        -- check if all transmissions went OK

    ---------

Notes

    sensor pinout, top view: (gold box visible)
    A B C 2 4 6 8 10 12
          1 3 5 7  9 11
    where:
    A    TX (UART)
    B    RX (UART)
    C    V+ (5V DC)
    1 +5V
    2    GND
    3    GND
    4    AV OUT (0..4V DC)
    5    SCL (I2C)
    6    NC
    7    SDA (I2C)
    8    NC
    9    NC
    10   TX (UART)
    11   RX (UART)
    12   GND
    for this library, you need only connect pins 1, 3, 5 & 7

    --------------
    Memory map:
    T66xx memory map
         addr    Description     lt      wgt  RW/RO      write            read description        write description
         0x00    Elevation       2       msb     RW      W: 0 xx xx                              xx xx elevation in hex
         0x01                            lsb
         0x02    Span PPM        2       msb     RW      W: 2 xx xx                              xx xx span in hex T6615 only
         0x03                            lb
         0x04    sngl p trgt     2       msb     RW      W: 4 xx xx                               xx xx single point in hex
         0x05                            lsb
         0x06    zero cal cmd    1               RW      W: 6 0F         00: flags set
         0x07    span cal cmd    1               RW      W: 7 0F         00: flags set           T6615 only
         0x08    sngl pnt cal cmd 1              RW      W: 8 0F         00: flags set
         0x09    ABC logic enable 1              RW      W: 9 0x         01:ABC on, 02:ABC off 01:on, 02:off, 03:reset and on
         0x0A    Sensor idle cmd 1               RW      W: A 0x         00 after cmd            01:idle on, 02:idle off
         0x0B    Reset cmd       1               RW      W: B 0F         00 after cmd
         0x0C    span2 cal cmd   1               RW      W: C 0F         00: flags set           T6615 only
         0x0D    span2 ppm       2               RW      W: D xx xx

Dependencies

No dependency found

## Summary

### Global variables/contants

- `const CMD_CO2 = 0x20`
- `const CMD_RESET = 0x0B`
- `const CMD_ELEVATION = 0x00`
- `const CMD_SERIAL = 0x27`
- `const byte t6613_addr = 0b0001_0000`
- `const CMD_STATUS = 0x22`

### Procedures

- `set_co2_elevation_m(word in meters)`
- `get_co2_serial_number(byte out str[16])`
- `reset_t6613()`

### Functions

- `get_co2_elevation_m() return word`
- `get_co2_ppm() return word`
- `get_co2_status() return byte`

## API details

### Global variables/contants

- `const CMD_CO2 = 0x20`

  No documentation found

- `const CMD_RESET = 0x0B`

  No documentation found

- `const CMD_ELEVATION = 0x00`

  No documentation found

- `const CMD_SERIAL = 0x27`

  No documentation found

- `const byte t6613_addr = 0b0001_0000`

      0x08 in 7-bit notation

- `const CMD_STATUS = 0x22`

  No documentation found

### Procedures

- `set_co2_elevation_m(word in meters)`

      should set elevation in meters above sea level, not implemented yet

- `get_co2_serial_number(byte out str[16])`

      returns 16 byte ASCII string, which should be the same
      as the number on the sticker

- `reset_t6613()`

  No documentation found

### Functions

- `get_co2_elevation_m() return word`

      returns programmed elevation above sea level in meters
      this elevation is used to calculate CO2 concentration correctly

- `get_co2_ppm() return word`

      returns a word with CO2 concentration in ppm

- `get_co2_status() return byte`

      returns status byte. bit_0 = error, bit_1 = warmup,
      bit_2 = calibration, bit_3 = idle

## Related samples

Here are the list of samples which use this library:

18f67k22 | 18f67k22_co2_i2c.jal