co2minimon

Get temperature and CO2 concentration data from a CO2Mini sensor.
git clone git://git.amin.space/co2minimon.git
Log | Files | Refs | README | LICENSE

README.md (3599B)


      1 # CO2MiniMon
      2 
      3 This Linux program reads temperature and relative CO2 concentration data from a
      4 [CO2Mini][1] sensor and writes the values to temporary files. I use it to
      5 display the data in [i3status][2].
      6 
      7 
      8 ### Setup
      9 
     10 Put the udev rules file in `/etc/udev/rules.d/`, then reload the rules with:
     11 
     12 ```
     13 # udevadm control --reload-rules && udevadm trigger
     14 ```
     15 
     16 Then, when you plug in the device, `/dev/co2minix` will be created as a symlink
     17 to the appropriate `/dev/hidrawx`.
     18 
     19 Build and run:
     20 
     21 ```
     22 $ ./build.sh
     23 $ ./out/release/co2minimon
     24 ```
     25 
     26 The 2 output files specified in the source code should be created and
     27 continually updated with the latest values.
     28 
     29 
     30 ### Device Support
     31 
     32 There are different versions of this device, frequently called the CO2Mini or
     33 the RAD-0301. 
     34 
     35 Some versions use a crappy encryption scheme as a detterent to getting the data
     36 out. For some wonderful and informative reading on this subject, see
     37 [Reverse-Engineering a low-cost USB CO₂ monitor][3].
     38 
     39 For whatever reason, my device doesn't seem to engage in these encryption
     40 shenanigans, so I can just get the data by decoding the very simple
     41 [protocol][4].
     42 
     43 My device has model number `ZGm053UKA`, and Linux reports the following data
     44 for it:
     45 
     46 ```
     47 # lsusb --verbose -d 04d9:a052
     48 
     49 Bus 001 Device 020: ID 04d9:a052 Holtek Semiconductor, Inc. USB-zyTemp
     50 Device Descriptor:
     51   bLength                18
     52   bDescriptorType         1
     53   bcdUSB               1.10
     54   bDeviceClass            0 
     55   bDeviceSubClass         0 
     56   bDeviceProtocol         0 
     57   bMaxPacketSize0         8
     58   idVendor           0x04d9 Holtek Semiconductor, Inc.
     59   idProduct          0xa052 USB-zyTemp
     60   bcdDevice            2.00
     61   iManufacturer           1 Holtek
     62   iProduct                2 USB-zyTemp
     63   iSerial                 3 2.00
     64   bNumConfigurations      1
     65   Configuration Descriptor:
     66     bLength                 9
     67     bDescriptorType         2
     68     wTotalLength       0x0022
     69     bNumInterfaces          1
     70     bConfigurationValue     1
     71     iConfiguration          0 
     72     bmAttributes         0x80
     73       (Bus Powered)
     74     MaxPower              100mA
     75     Interface Descriptor:
     76       bLength                 9
     77       bDescriptorType         4
     78       bInterfaceNumber        0
     79       bAlternateSetting       0
     80       bNumEndpoints           1
     81       bInterfaceClass         3 Human Interface Device
     82       bInterfaceSubClass      0 
     83       bInterfaceProtocol      0 
     84       iInterface              0 
     85         HID Device Descriptor:
     86           bLength                 9
     87           bDescriptorType        33
     88           bcdHID               1.10
     89           bCountryCode            0 Not supported
     90           bNumDescriptors         1
     91           bDescriptorType        34 Report
     92           wDescriptorLength      53
     93          Report Descriptors: 
     94            ** UNAVAILABLE **
     95       Endpoint Descriptor:
     96         bLength                 7
     97         bDescriptorType         5
     98         bEndpointAddress     0x81  EP 1 IN
     99         bmAttributes            3
    100           Transfer Type            Interrupt
    101           Synch Type               None
    102           Usage Type               Data
    103         wMaxPacketSize     0x0008  1x 8 bytes
    104         bInterval              10
    105 Device Status:     0x0000
    106   (Bus Powered)
    107 ```
    108 
    109 [1]: https://web.archive.org/web/20220522013217/https://www.co2meter.com/products/co2mini-co2-indoor-air-quality-monitor
    110 [2]: https://i3wm.org/i3status/
    111 [3]: https://web.archive.org/web/20220522013203/https://hackaday.io/project/5301/logs?sort=oldest
    112 [4]: https://web.archive.org/web/20220501135432/http://co2meters.com/Documentation/Other/AN_RAD_0301_USB_Communications_Revised8.pdf