Voltcraft CO-20

From Domoticz
Jump to: navigation, search

Voltcraft CO-20 has internal support for Linux


At this moment the Voltcraft CO-20 Air Quality Sensor support is only for Unix based systems (for example the Raspberry Pi). (Could not get it to work under Windows yet.... osx is also not supported [1])


I noticed that sometimes copy/past from forums/pages does not make a one-on-one paste in my putty screen. Be aware of this, and verify the device rule three times to make sure no characters are missing!


Follow the instruction on the following page: https://github.com/tuxedo0801/usb-sensors-linux


Install LibUSB-dev, which is needed when compiling the airsensor utility.

$ sudo apt-get install libusb-dev

Compile from sources

Install required software The 'build-essential' package is needed to be able to compile the source code.

$ sudo apt-get install build-essential

Download the source code and compile

Install the latest version from Github, no released version is packaged yet.

$ git clone https://github.com/tuxedo0801/usb-sensors-linux.git

Compile the source code

$ gcc -o airsensor airsensor.c -lusb


You can now execute the airsensor and see if you get readings, as seen on most Linux installations it seems that you must be root user, or then add udev rule to make the device read/write. To run with root access $ sudo ./airsensor -o 2013-04-28 14:55:56, VOC: 450, RESULT: OK $

Without root access it will print following

$ ./airsensor -o 2013-04-28 14:55:19, Error: claim failed with error: -1 $

Make Udev rule

Insert a udev rule to get read/write access to the device from normal user. Create and edit following file:

$ sudo nano /etc/udev/rules.d/99-usb.rules Add following lines;

SUBSYSTEM=="usb", ATTR{idVendor}=="03eb", ATTR{idProduct}=="2013", MODE="0666" Save and reboot, now the device should be writable and give you results. Example, without sudo $ ./airsensor -o 2013-04-28 15:08:55, VOC: 450, RESULT: OK $ Please see readme for more usage instructions


Error: claim failed with error: -1

If you get following issue when running air sensor:

$ ./airsensor -o 2013-04-28 14:55:19, Error: claim failed with error: -1 $

It means that you have no access to the USB device, two solutions; a) use sudo, eg "sudo ./airsensor" b) create the udev rule as above After this, you can add the device into Domoticz by using the hardware setup.

This page is a copy from: http://sourceforge.net/p/domoticz/wiki/Installing%20a%20Voltcraft%20CO-20%20Air%20Quality%20Sensor/