Skip to content

Commit 50c8a2e

Browse files
committed
0.3.0 Cozir
1 parent e67bc3a commit 50c8a2e

File tree

10 files changed

+752
-364
lines changed

10 files changed

+752
-364
lines changed

libraries/Cozir/README.md

Lines changed: 125 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -12,96 +12,114 @@ Arduino library for COZIR range of temperature, humidity and CO2 sensors.
1212
## Description
1313

1414
The Cozir library is **experimental** as I do not have a sensor to test the library.
15-
The polling mode as used in the examples seems to work quite well.
15+
The polling mode as used in the examples seems to work quite well as this is tested by DirtGambit.
16+
17+
This library supports only the Serial interface. An I2C based library will be written
18+
when I have access to a Cozir sensor that supports I2C.
19+
Idea is to make the interface identical if possible.
20+
1621

1722
#### Notes
1823
- the **CozirDemoHWSerial.ino** example needs to run on a MEGA or a Teensy,
1924
at least a board with more than one Serial port.
20-
- Read the datasheet before using this library. It helps to understand the working of the Cozir sensor.
25+
- Read the datasheet before using this library.
26+
It helps to understand the working of the Cozir sensor.
2127

2228

2329
## Interface
2430

25-
Read the datasheet (again)
31+
Read the datasheet (again).
2632

2733

2834
### Constructor and initialisation
2935

30-
- **COZIR(Stream \*)** constructor
31-
- **void init()** sets operatingMode to CZR_POLLING
32-
- **void SetOperatingMode(uint8_t mode)** set the operating mode either to **CZR_COMMAND**, **CZR_POLLING** or **CZR_STREAMING**
36+
- **COZIR(Stream \* str)** constructor.
37+
- **void init()** sets operatingMode to CZR_POLLING.
38+
- **bool isInitialized()** returns true if enough time has passed after the call to **init()** for the sensor.
39+
40+
41+
### Operating mode
42+
43+
- **void setOperatingMode(uint8_t mode)** set the operating mode either to **CZR_COMMAND**, **CZR_POLLING** or **CZR_STREAMING**
44+
- **uint8_t getOperatingMode()** returns the mode set, **CZR_STREAMING** is the default.
45+
Please note that **init()** sets the operating mode to **CZR_POLLING**.
3346

3447

3548
### Core
36-
- **float Celsius()** idem
37-
- **float Fahrenheit()** idem, wrapper around **Celsius()**
38-
- **float Humidity()** idem
39-
- **float Light()** idem
40-
- **uint32_t CO2() ** idem.
49+
- **float celsius()** idem.
50+
- **float fahrenheit()** idem, 'wrapper' around **celsius()**
51+
- **float humidity()** idem.
52+
- **float light()** idem.
53+
- **uint32_t CO2()** idem.
4154
- **uint16_t getPPMFactor()** returns 1, 10, 100 See Page 14.
4255

4356

4457
### Calibration
4558

46-
Read datasheet before use
59+
Read datasheet before using these functions:
4760

48-
- **uint16_t FineTuneZeroPoint(uint16_t v1, uint16_t v2)**
49-
- **uint16_t CalibrateFreshAir()**
50-
- **uint16_t CalibrateNitrogen()**
51-
- **uint16_t CalibrateKnownGas(uint16_t value)**
61+
- **uint16_t fineTuneZeroPoint(uint16_t v1, uint16_t v2)**
62+
- **uint16_t calibrateFreshAir()**
63+
- **uint16_t calibrateNitrogen()**
64+
- **uint16_t calibrateKnownGas(uint16_t value)**
5265

5366

5467
#### Calibration NOT Recommended
5568

56-
Following 3 functions are **NOT RECOMMENDED** by the datasheet.
57-
Feel free to uncomment but use at your own risk. Read datasheet before use.
69+
Following 3 functions are **NOT RECOMMENDED** by the datasheet.
70+
Feel free to uncomment and use at your own risk.
71+
Read datasheet before using these functions:
5872

59-
- **uint16_t CalibrateManual(uint16_t value)**
60-
- **uint16_t SetSpanCalibrate(uint16_t value)**
61-
- **uint16_t GetSpanCalibrate()**
73+
- **uint16_t calibrateManual(uint16_t value)**
74+
- **uint16_t setSpanCalibrate(uint16_t value)**
75+
- **uint16_t getSpanCalibrate()**
6276

6377

6478
### Digifilter
6579

66-
use with care, read datasheet before use
80+
use with care, read datasheet before use.
6781

6882
| value | meaning |
6983
|:-----:|:--------|
7084
| 0 | Special, see datasheet page ... |
71-
| 1 | fast, but can be noisy |
72-
| 32 | default, good average |
73-
| 255 | slow, max smoothed |
85+
| 1 | fast, but can be noisy |
86+
| 32 | default, good average |
87+
| 255 | slow, max smoothed |
7488

75-
- **void SetDigiFilter(uint8_t value)**
76-
- **uint8_t GetDigiFilter()**
89+
- **void setDigiFilter(uint8_t value)**
90+
- **uint8_t getDigiFilter()**
7791

7892

7993
### Streaming MODE
8094

8195
Warning: Not tested ,
8296

83-
- **void SetOutputFields(uint16_t fields)** Sets the fields in the output stream.
84-
- **void ClrOutputFields()** clears all the fields.
85-
- **void GetRecentFields()** After a call to GetRecentFields() you must read the serial port yourself as the internal buffer of this Class cannot handle the possible large output. It can be over 100 bytes long lines!
86-
87-
The fields must be set as a bit mask, the order of the fields in the output is undetermined. So parse carefully.
88-
89-
| Field | Value | Notes |
90-
|:------------------|:-------|:------|
91-
| CZR_LIGHT | 0x2000 | |
92-
| CZR_HUMIDITY | 0x1000 | |
93-
| CZR_FILTLED | 0x0800 | |
94-
| CZR_RAWLED | 0x0400 | |
95-
| CZR_MAXLED | 0x0200 | |
96-
| CZR_ZEROPOINT | 0x0100 | |
97-
| CZR_RAWTEMP | 0x0080 | |
98-
| CZR_FILTTEMP | 0x0040 | |
99-
| CZR_FILTLEDSIGNAL | 0x0020 | |
100-
| CZR_RAWLEDSIGNAL | 0x0010 | |
101-
| CZR_SENSTEMP | 0x0008 | |
102-
| CZR_FILTCO2 | 0x0004 | |
103-
| CZR_RAWCO2 | 0x0002 | |
104-
| CZR_NONE | 0x0001 | reset |
97+
- **void setOutputFields(uint16_t fields)** Sets the fields in the output stream as a 16 bit mask. See table below.
98+
- **void clearOutputFields()** clears all the fields.
99+
- **uint16_t getOutputFields()** returns the 16 bit mask of set output fields.
100+
- **bool inOutputFields(uint16_t field)** returns true if the field is set.
101+
- **void getRecentFields()** After a call to getRecentFields() you must read the serial stream yourself.
102+
The internal buffer of this Class cannot handle the possible large output. Lines can be over 100 bytes long!
103+
104+
The fields must be set as a bit mask, the order of the fields in the output is undetermined.
105+
So one need to parse the output of the sensor carefully.
106+
107+
| Field | Value | Notes |
108+
|:------------------|:-------|:---------|
109+
| CZR_LIGHT | 0x2000 | |
110+
| CZR_HUMIDITY | 0x1000 | |
111+
| CZR_FILTLED | 0x0800 | |
112+
| CZR_RAWLED | 0x0400 | |
113+
| CZR_MAXLED | 0x0200 | |
114+
| CZR_ZEROPOINT | 0x0100 | |
115+
| CZR_RAWTEMP | 0x0080 | |
116+
| CZR_FILTTEMP | 0x0040 | |
117+
| CZR_FILTLEDSIGNAL | 0x0020 | |
118+
| CZR_RAWLEDSIGNAL | 0x0010 | |
119+
| CZR_SENSTEMP | 0x0008 | |
120+
| CZR_FILTCO2 | 0x0004 | |
121+
| CZR_RAWCO2 | 0x0002 | |
122+
| CZR_NONE | 0x0001 | reset |
105123
| CZR_HTC | 0x1082 | shortcut |
106124
| CZR_ALL | 0x3FFE | debug |
107125

@@ -111,32 +129,64 @@ The fields must be set as a bit mask, the order of the fields in the output is u
111129
Read datasheet Page 11-12 about the addresses and their meaning.
112130
Use with care.
113131

114-
- **void SetEEPROM(uint8_t address, uint8_t value)**
115-
- **uint8_t GetEEPROM(uint8_t address)**
116-
117-
118-
| Name | Address | Default | Notes |
119-
|:---------|:-------:|:-------:|:------|
120-
| AHHI | 0x00 | | reserved |
121-
| ANLO | 0x01 | | reserved |
122-
| ANSOURCE | 0x02 | | reserved |
123-
| ACINITHI | 0x03 | 87 | |
124-
| ACINITLO | 0x04 | 192 | |
125-
| ACHI | 0x05 | 94 | |
126-
| ACLO | 0x06 | 128 | |
127-
| ACONOFF | 0x07 | 0 | |
128-
| ACPPMHI | 0x08 | 1 | |
129-
| ACPPMLO | 0x09 | 194 | |
130-
| AMBHI | 0x0A | 1 | |
131-
| AMBLO | 0x0B | 194 | |
132-
| BCHI | 0x0C | 0 | |
133-
| BCLO | 0x0D | 8 | |
134-
135-
136-
### Misc
137-
138-
- **void GetVersionSerial()** requests version over serial. The user should read (and parse) the serial output as it can become large. Also the user must reset the operating mode either to **CZR_POLLING** or **CZR_STREAMING**
139-
- **void GetConfiguration()** requests configuration over serial. The user should read (and parse) the serial output as it can become large. Also the user must reset the operating mode either to **CZR_POLLING** or **CZR_STREAMING**
132+
In 0.3.0 the EEPROM function have been replaced by specific accessor
133+
functions. Read datasheet for the details.
134+
135+
- **void setAutoCalibrationPreload(uint16_t value)**
136+
- **uint16_t getAutoCalibrationPreload()**
137+
- **void setAutoCalibrationInterval(uint16_t value)**
138+
- **uint16_t getAutoCalibrationInterval()**
139+
- **void setAutoCalibrationOn()**
140+
- **void setAutoCalibrationOff()**
141+
- **bool getAutoCalibration()**
142+
- **void setAutoCalibrationBackgroundConcentration(uint16_t value)**
143+
- **uint16_t getAutoCalibrationBackgroundConcentration()**
144+
- **void setAmbientConcentration(uint16_t value)**
145+
- **uint16_t getAmbientConcentration()**
146+
- **void setBufferClearTime(uint16_t value)**
147+
- **uint16_t getBufferClearTime()**
148+
149+
150+
#### EEPROM addresses used by above functions.
151+
152+
Read datasheet for the details.
153+
154+
| Name | Address | Default | Notes |
155+
|:---------|:-------:|:-------:|:---------|
156+
| AHHI | 0x00 | ? | reserved |
157+
| ANLO | 0x01 | ? | reserved |
158+
| ANSOURCE | 0x02 | ? | reserved |
159+
| ACINITHI | 0x03 | 87 | |
160+
| ACINITLO | 0x04 | 192 | |
161+
| ACHI | 0x05 | 94 | |
162+
| ACLO | 0x06 | 128 | |
163+
| ACONOFF | 0x07 | 0 | |
164+
| ACPPMHI | 0x08 | 1 | |
165+
| ACPPMLO | 0x09 | 194 | |
166+
| AMBHI | 0x0A | 1 | |
167+
| AMBLO | 0x0B | 194 | |
168+
| BCHI | 0x0C | 0 | |
169+
| BCLO | 0x0D | 8 | |
170+
171+
172+
### Miscellaneous
173+
174+
- **void getVersionSerial()** requests version over serial.
175+
The user should read (and parse) the serial output as it can become large.
176+
Also the user must reset the operating mode either to **CZR_POLLING** or **CZR_STREAMING**
177+
- **void getConfiguration()** requests configuration over serial.
178+
The user should read (and parse) the serial output as it can become large.
179+
Also the user must reset the operating mode either to **CZR_POLLING** or **CZR_STREAMING**
180+
181+
182+
## Future
183+
184+
- test test test test and ...
185+
- add a **setEEPROMFactoryDefault()**?
186+
- example two Cozir sensors
187+
- example Cozir with I2C display?
188+
- build a Arduino COZIR simulator for testing.
189+
- Cozir I2C class for newer generation ~ same interface
140190

141191

142192
## Operation

0 commit comments

Comments
 (0)