GithubHelp home page GithubHelp logo

maddindeiss / co2-monitor Goto Github PK

View Code? Open in Web Editor NEW
37.0 5.0 9.0 45 KB

Measure CO2 and temperature in nodejs with the TFA-Dostmann AirControl Mini

License: MIT License

JavaScript 100.00%
co2 monitoring nodejs usb npm co2monitor temperature

co2-monitor's Introduction

co2-monitor

Reads CO2, temperature and humidity from TFA-Dostmann CO2-Monitor devices via USB.

Just connect the sensor via USB and run the example script. There is no need to set up the sensor or USB port.

Supported Hardware

TFA-Dostmann CO2-Monitor AIRCO2NTROL MINI 31.5006

TFA-Dostmann CO2-Monitor AIRCO2NTROL COACH 31.5009

Install

npm install co2-monitor

Example

const Co2Monitor = require('co2-monitor');

let co2Monitor = new Co2Monitor();

co2Monitor.on('connected', () => {
  console.log('Co2Monitor connected');
});

co2Monitor.on('disconnected', () => {
  console.log('Co2Monitor disconnected');
});

co2Monitor.on('error', (error) => {
  console.error(error);

  co2Monitor.disconnect(() => {
    process.exit(1);
  });
})

co2Monitor.on('co2', (co2) => {
  console.log('co2: ' + co2.toString());
})

co2Monitor.on('humidity', (humidity) => {
  console.log('humidity: ' + humidity.toString());
})

co2Monitor.on('temperature', (temperature) => {
  console.log('temperature: ' + temperature.toString());
})

co2Monitor.on('data', (data) => {
  console.log('data: ' + data.toString());
})

co2Monitor.connect((error) => {
  if (error) {
    console.error(error);
    process.exit(1);
  }

  co2Monitor.startTransfer((error) => {
    if (error) {
      console.error(error);
    }
  });
});

Events

Temperature

temperature event which is triggered on an update of temperature.

The event result is an object with the following structure:

{
  "value": 23.73,
  "type": "float",
  "unit": "degree celsius",
  "symbol": "°C"
}

Co2

co2 event which is triggered on an update of Co2.

The event result is an object with the following structure:

{
  "value": 1744,
  "type": "int",
  "unit": "parts per million",
  "symbol": "ppm"
}

Humidity

humidity event which is triggered on an update of relative humidity.

Only the AIRCO2NTROL COACH supports humidity data. The AIRCO2NTROL MINI will report humidity data with 0.

The event result is an object with the following structure:

{
  "value": 40.75,
  "type": "float",
  "unit": "relative humidity",
  "symbol": "% rh"
}

Data

data event which is triggered on updates of humidity, temperature or co2.

The event result is an object with the following structure:

{
  "co2": {
    "value": 1744,
    "type": "int",
    "unit": "parts per million",
    "symbol": "ppm"
  },
  "temperature": {
    "value": 23.73,
    "type": "float",
    "unit": "degree celsius",
    "symbol": "°C"
  },
  "humidity": {
    "value": 40.75,
    "type": "float",
    "unit": "relative humidity",
    "symbol": "% rh"
  }
}

Credits

based on code by henryk ploetz

License

MIT

co2-monitor's People

Contributors

maddindeiss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

co2-monitor's Issues

Doesn´t work with Linux

The co2monitor module works perfect on my Windows System, and i can aquire data from my aircontrol mini Monitor. When i try to use it on my Raspberry Pi 2 it always throws an error that say "Error while connecting to device! ERROR: LIBUSB_ERROR_BUSY" The error gets thrown in the file co2monitor.js in line 61, which is in the connectToDevice function.
The Raspberry recognizes that the aircontrol mini Monitor is plugged in, when i type lsusb, the Monitor is listed, and when i replug it, the device number enumerates.
Any suggestions how to fix this Problem?

Support for AirCO2ntrol Coach (with code)

Disclaimer: I got a device sent for free to test its USB capabilities and develop some example code.

With just a few changes the AirCO2NTROL Coach can become compatible as well.

In addition to the CO2 concentration and temperature, it also measures the relative humidity.

I've forked this library to adapt it to the Coach. A next step would be to restore the compatibility with the Mini.

Code changes for compatibility with the Coach:
https://gitlab.com/jaller94/node-co2-monitor/commit/6d3ca1dbe185b373e22e696546943e4305d1cbf7

To tell them apart one can test this._device.deviceDescriptor.bcdDevice. The Mini's number is 256 (0x0100 for version 1.00) and the Coach's number is 512 (0x0200 for version 2.00).

Other than the Mini's data, the Coach's data does not need to be decrypted.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.