Principles
Use the Amphenol / Telaire T6703-5K CO2 sensor, measure every 30s, show the result on a small OLED display, and send the readout to the MySensors controller.
Use an Arduino Nano on 5V.
I read this for a commercial CO2 meter, see below (translated). Hence, it would be good to add green, yellow and red LEDs:
The CO2 meter fulfills the demands that are included in the Construction prescriptions. This includes the fact that the CO2 meter works on the continous mains net and that the device will calibrate itself. Also, the meter has a range from 0 - 5000 ppm and is equipped with 3 color codes: green for less than 800 ppm, yellow for 800 - 1200 ppm and red for a CO2-level of 1200 and higher.
This can be done using a single WS2812B chip and the library at: https://github.com/PinkNoize/ws2812B-arduino.
The result
Used Components
- ArduinoNano5V
- NRF24L01+
- Pull-up resistor 4K7 Ohm (it also works without)
- AdapterBoardForNrf24L01 Connects the NRF24L01+ with the Arduino
- CO2-sensor-T6703-5K 5000 ppm version
- OLED-Display-SSD1315 1.3" White
- WS2812B Addressable colour LED
- STWD100 Watchdog (see also the watchdog test circuit)
Wiring
Component | Pin | Wire color / component | Pin | Component |
---|---|---|---|---|
ArduinoNano5V | VCC | red | 5V | Breadboard / Power Supply |
ArduinoNano5V | GND | black | GND | Breadboard / Power Supply |
T6703 | 1 SDA | green | A4 | ArduinoNano5V |
T6703 | 2 SCL | blue | A5 | ArduinoNano5V |
T6703 | 3 | red | VCC | Breadboard / Power Supply |
T6703 | 4 | black | GND | Breadboard / Power Supply |
T6703 | 5 | PWM output (not used) | ||
T6703 | 6 | brown | GND | Breadboard / Power Supply |
OLED-Display | VCC | red | VCC | ArduinoNano5V |
OLED-Display | GND | black | GND | ArduinoNano5V |
OLED-Display | SCL | A5 | Purple | ArduinoNano5V |
OLED-Display | SDA | A4 | Green | ArduinoNano5V |
NRF24L01+ Adapter | VCC | red | 5V | Breadboard / Power Supply |
NRF24L01+ Adapter | GND | brown | GND | Breadboard / Power Supply |
NRF24L01+ Adapter | CE | blue | 9 | ArduinoNano5V |
NRF24L01+ Adapter | CSN | purple | 10 | ArduinoNano5V |
NRF24L01+ Adapter | SCK | yellow | 13 | ArduinoNano5V |
NRF24L01+ Adapter | M0 (MOSI) | gray | 11 | ArduinoNano5V |
NRF24L01+ Adapter | M1 (MISO) | white | 12 | ArduinoNano5V |
NRF24L01+ Adapter | IRQ | green - OPTIONAL - NOT USED! | 2 | ArduinoNano5V |
WS2812B | +5V | yellow | 5V | Power Supply |
WS2812B | IN | blue | D4 | ArduinoNano5V |
WS2812B | GND | brown | GND | Power Supply |
Programming
Code at: CO2Node.ino
Beware: Using the OLED display library, reading the CO2 meter, and MySensors is a bit much for the Arduino ATmega328p: there is barely enough RAM memory. The code had to be reduced to the bare essentials, to limit RAM and Flash-RAM use. Hence: no debug information from MySensors.
- Compile as follows:
- CD to the folder where the file platformio.ini is.
- Run pio run
- Run pio run -t upload -t monitor
First sign of life
__ __ ____ | \/ |_ _/ ___| ___ _ __ ___ ___ _ __ ___ | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __| | | | | |_| |___| | __/ | | \__ \ _ | | \__ \ |_| |_|\__, |____/ \___|_| |_|___/\___/|_| |___/ |___/ 2.3.2 1.0 3209 3257 3574 4676 5397 4255 3572
Initially, the meter is not very stable. After an hour, the measurements vary only 1 or 2 ppm per measurement. For calibration, it is imperative that the sensor at least once a day or week can measure outside air. In my case, it is sufficient to have no people in the room during the night, while the ventilation system refreshes the air; this way the level of CO2 will be the same as outside in the morning.
The stability problem
Once in a few weeks, the node crashes: the screen is frozen and no MySensors messages are sent.
In such crashed state, pressing the Arduino Nano reset button resolves the problem. Hence, I presume that the problem is caused by the oscillator, which just stops and does not restart by itself.
In an attempt to figure out what is causing the problem, I added a OpenLog device to the Nano. But since then, it did not crash yet.
As a solution, I added a hardware STWD100 watchdog circuit. It never crashed since!
Adding a Watchdog STWD100
Wiring
Component | Pin | Wire color / component | Pin | Component |
---|---|---|---|---|
ArduinoNano5V | VCC | red | 5: VCC | STWD100 |
ArduinoNano5V | GND | black | 2: GND | STWD100 |
STWD100 | 1: /WDO (watchdog out) | orange | /RESET | ArduinoNano5V |
STWD100 | 3: /EN (Watchdog enable) | D7 | ArduinoNano5V | |
STWD100 | 4: WDI (watchdog input) | yellow | D8 | ArduinoNano5V |
STWD100 | 3: /EN (watchdog enable) | pullup resistor 4.7KOhm | 5V | Power Supply |