2014-11-16 10:04:43 -05:00
|
|
|
//
|
2014-11-16 10:00:08 -05:00
|
|
|
// FILE: Cozir.h
|
|
|
|
// AUTHOR: DirtGambit & Rob Tillaart
|
2014-12-07 05:29:14 -05:00
|
|
|
// VERSION: 0.1.05
|
2014-11-16 10:00:08 -05:00
|
|
|
// PURPOSE: library for COZIR range of sensors for Arduino
|
2014-11-16 10:04:43 -05:00
|
|
|
// Polling Mode
|
2014-11-16 10:20:59 -05:00
|
|
|
// URL: http://forum.arduino.cc/index.php?topic=91467.0
|
2014-11-16 10:04:43 -05:00
|
|
|
//
|
2014-11-16 10:00:08 -05:00
|
|
|
// READ DATASHEET BEFORE USE OF THIS LIB !
|
|
|
|
//
|
|
|
|
// Released to the public domain
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef Cozir_h
|
|
|
|
#define Cozir_h
|
|
|
|
|
|
|
|
#if defined(ARDUINO) && ARDUINO >= 100
|
2014-11-16 10:20:59 -05:00
|
|
|
#include "Arduino.h"
|
|
|
|
#include "SoftwareSerial.h"
|
2014-11-16 10:00:08 -05:00
|
|
|
#else
|
2014-11-16 10:20:59 -05:00
|
|
|
#include "WProgram.h"
|
|
|
|
#include "NewSoftSerial.h"
|
2014-11-16 10:00:08 -05:00
|
|
|
#endif
|
|
|
|
|
2014-12-07 05:39:59 -05:00
|
|
|
#define COZIR_LIB_VERSION "0.1.05"
|
2014-11-16 10:00:08 -05:00
|
|
|
|
2014-11-16 10:04:43 -05:00
|
|
|
// OUTPUTFIELDS
|
2014-11-16 10:00:08 -05:00
|
|
|
// See datasheet for details.
|
|
|
|
// These defines can be OR-ed for the SetOutputFields command
|
|
|
|
#define CZR_LIGHT 0x2000
|
|
|
|
#define CZR_HUMIDITY 0x1000
|
|
|
|
#define CZR_FILTLED 0x0800
|
|
|
|
#define CZR_RAWLED 0x0400
|
|
|
|
#define CZR_MAXLED 0x0200
|
|
|
|
#define CZR_ZEROPOINT 0x0100
|
|
|
|
#define CZR_RAWTEMP 0x0080
|
|
|
|
#define CZR_FILTTEMP 0x0040
|
|
|
|
#define CZR_FILTLEDSIGNAL 0x0020
|
|
|
|
#define CZR_RAWLEDSIGNAL 0x0010
|
|
|
|
#define CZR_SENSTEMP 0x0008
|
|
|
|
#define CZR_FILTCO2 0x0004
|
|
|
|
#define CZR_RAWCO2 0x0002
|
|
|
|
#define CZR_NONE 0x0001
|
|
|
|
|
|
|
|
// easy default setting for streaming
|
|
|
|
#define CZR_HTC (CZR_HUMIDITY | CZR_RAWTEMP | CZR_RAWCO2)
|
|
|
|
// not in datasheet for debug only
|
2014-11-16 10:04:43 -05:00
|
|
|
#define CZR_ALL 0x3FFE
|
2014-11-16 10:00:08 -05:00
|
|
|
|
|
|
|
// OPERATING MODES
|
|
|
|
#define CZR_COMMAND 0x00
|
|
|
|
#define CZR_STREAMING 0x01
|
|
|
|
#define CZR_POLLING 0x02
|
|
|
|
|
|
|
|
class COZIR
|
|
|
|
{
|
2014-11-16 10:20:59 -05:00
|
|
|
public:
|
2014-11-16 10:02:53 -05:00
|
|
|
#if defined(ARDUINO) && ARDUINO >= 100
|
2014-11-16 10:20:59 -05:00
|
|
|
COZIR(SoftwareSerial&);
|
2014-11-16 10:02:53 -05:00
|
|
|
#else
|
2014-11-16 10:20:59 -05:00
|
|
|
COZIR(NewSoftSerial&);
|
2014-11-16 10:02:53 -05:00
|
|
|
#endif
|
|
|
|
|
2014-11-16 10:20:59 -05:00
|
|
|
float Celsius();
|
|
|
|
float Fahrenheit();
|
|
|
|
float Humidity();
|
|
|
|
float Light();
|
|
|
|
uint32_t CO2();
|
2014-11-16 10:00:08 -05:00
|
|
|
|
2014-11-16 10:20:59 -05:00
|
|
|
uint16_t FineTuneZeroPoint(uint16_t , uint16_t);
|
|
|
|
uint16_t CalibrateFreshAir();
|
|
|
|
uint16_t CalibrateNitrogen();
|
|
|
|
uint16_t CalibrateKnownGas(uint16_t );
|
|
|
|
uint16_t CalibrateManual(uint16_t );
|
|
|
|
uint16_t SetSpanCalibrate(uint16_t );
|
|
|
|
uint16_t GetSpanCalibrate();
|
2014-11-16 10:04:43 -05:00
|
|
|
|
2014-11-16 10:20:59 -05:00
|
|
|
void SetDigiFilter(uint8_t );
|
|
|
|
uint8_t GetDigiFilter();
|
2014-11-16 10:04:43 -05:00
|
|
|
|
2014-11-16 10:20:59 -05:00
|
|
|
void SetOutputFields(uint16_t );
|
|
|
|
void GetRecentFields();
|
2014-11-16 10:04:43 -05:00
|
|
|
|
2014-11-16 10:20:59 -05:00
|
|
|
void SetEEPROM(uint8_t , uint8_t );
|
|
|
|
uint8_t GetEEPROM(uint8_t );
|
2014-11-16 10:04:43 -05:00
|
|
|
|
2014-11-16 10:20:59 -05:00
|
|
|
void GetVersionSerial();
|
|
|
|
void GetConfiguration();
|
2014-11-16 10:04:43 -05:00
|
|
|
|
2014-11-16 10:20:59 -05:00
|
|
|
private:
|
2014-11-16 10:02:53 -05:00
|
|
|
#if defined(ARDUINO) && ARDUINO >= 100
|
2014-11-16 10:20:59 -05:00
|
|
|
SoftwareSerial& CZR_Serial;
|
2014-11-16 10:02:53 -05:00
|
|
|
#else
|
2014-11-16 10:20:59 -05:00
|
|
|
NewSoftSerial& CZR_Serial;
|
2014-11-16 10:02:53 -05:00
|
|
|
#endif
|
2014-11-16 10:04:43 -05:00
|
|
|
|
2014-11-16 10:20:59 -05:00
|
|
|
void SetOperatingMode(uint8_t mode);
|
2014-11-16 10:04:43 -05:00
|
|
|
|
2014-11-16 10:20:59 -05:00
|
|
|
void Command(const char* );
|
2014-12-07 05:29:14 -05:00
|
|
|
uint32_t Request(const char* );
|
2014-11-16 10:04:43 -05:00
|
|
|
|
2014-11-16 10:00:08 -05:00
|
|
|
char buffer[20];
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
2014-12-07 05:39:59 -05:00
|
|
|
// -- END OF FILE --
|