ESP Home & ESP C3 Super Mini Version
Description
Since migrating to Homeassistant we have also migrated all of our ESPs to ESPHome. This allows easy maintenance and OTA updates. Luckily ESPHome has excellent support for our existing CO2 monitors.
Additionally we also designed a custom case to house the ESP C3 and the Cables.
Hardware
- ESP C3 Super Mini
- Zyaura CO2 sensor
- 4x Jumper wires
- 1x Pin header
Wiring
As before you have to solder one additional Pin to the TFA Dostmann CO2-Sensor AirCO2ntrol Sensor.
| Sensor | Usage | ESP32 C3 Super Mini |
|---|---|---|
| Top pin | Ground | GND |
| Second pin | Clock | Pin 6 |
| Third pin | Data | Pin 5 |
| Lowest pin | Power | 5V |
Case
We designed a case which provides additional space for the ESP32 microcontoller and allows to power the sensor via USB-C. You can download the backplate from these sources.



Software
Extend your ESPHome config with this code block. According to the Internet the clock and data pins are swapped on some models.
sensor:
- platform: zyaura
clock_pin: 6
data_pin: 5
co2:
name: "Hackcenter CO2"
temperature:
name: "Hackcenter Temperature"DIY Version
Description
Someday a TFA Dostmann CO2-Sensor AirCO2ntrol appeared in our hackerspace - but the CO² reading couldn't be easily acquired through USB or any other connector. There are some implementations using python or nodejs, but they require a raspberry pi or at least a PC nearby to read the values to publish and store them somewhere.
Nowadays ESP8266, NodeMCU or in our case a Wemos D1 mini (which also has a ESP8266 on it) exist and is totally suitable for the job! Sadly, on the TFA Dostmann there's only a USB interface on the outside, and our Microcontroller does not support USB natively. So we opened the sensor and found a "CALIB" interface
Hardware
Inside the TDA Dostmann CO² sensor, there's a CALIB interface, which consist of four PINs. GND and 5V can easily be determined using a multimeter with continuity test. These PINs are directly connected to the USB port and can be used to power our microcontroller. The other 2 PINs in the middle seem to send some data. After connecting them to a oscilloscope one PIN was obviously just clock, and the other data.



Test readings using SIGROK and a logic analyser can be found on b4ckspace/esp8266-co2monitor/sigrok-captures.
Software
The signals look like they're just I2C, but actually they're not. Using the scope to decode the data failed - the same is true using the Wemos. After wiring up the sensor to the Wemos we used an external interrupt on the clock pin and a digitalRead on the data pin which is basically "bit banging".
The results were promising: Using a simple python script and the documentation from another manufacturer, we were able to verify the checksum. Also implementing the decode of the data was quite simple using the PDF:
case 0x50:
co2Measurement = (data[IDX_MSB] << 8) | data[IDX_LSB];
break;
case 0x42:
temperature = ((data[IDX_MSB] << 8) | data[IDX_LSB]) / 16.0 - 273.15;
break;
The last thing to do was connecting to wifi and publishing the data on MQTT. The source code can be found on GitHub and is licensed under the MIT-License.