Connecting CCS811 CO2 Sensor and MAX7219 to Tasmota

Description:

This is a project reads some environmental sensors (temperature, humidity, CO2), sends the data to a home automation server, and displays info on a 8×32 dot matrix display. Home automation

Main parts used:

1 x NodeMCU v3 ESP8266 dev board
1 x CJMCU-811 CO2 sensor (a CCS811 mounted on a PCB)
1 x MAX7219 32×8 dot matrix LED module
1 x DHT22 temperature/humidity sensor

The CCS811 support is included in the “sensors” build, while the MAX7219 matrix is supported in the “displays” build. To get both parts operating together, we need a custom Tasmota build.

Electrical Connection:

DHT22 pin 1 (VCC) – connect to NodeMCU 3V
DHT22 pin 2 (DATA) – connect to NodeMCU D3
DHT22 pin 4 (GND) – connect to NodeMCU GND

CCS811 pin 1 (VCC) – connect to NodeMCU 3V
CCS811 pin 2 (GND) – connect to NoceMCU GND
CCS811 pin 3 (SCL) – connect to NodeMCU D1
CCS811 pin 4 (SDA) – connect to NodeMCU D2
CCS811 pin 5 (WAK) – connect to NodeMCU GND
CCS811 pin 8 (ADD) – connect to NodeMCU GND

MAX7219 module pin 1 (VCC) – connect to NodeMCU VU (V-USB)
MAX7219 module pin 2 (GND) – connect to NodeMCU GND
MAX7219 module pin 3 (DIN) – connect to NodeMCU D6
MAX7219 module pin 4 (CS) – connect to NodeMCU D7
MAX7219 module pin 5 (CLK) – connect to NodeMCU D5

Software Configuration:

  1. Download Tasmota source from https://github.com/arendst/Tasmota.git
  2. Open it in VSCode (with PlatformIO extension installed).
  3. Create a new file /tasmota/user_config_override.h. This can be copied from /tasmota/user_config_override_sample.h.
  4. Add the following to the file:
    #ifndef USE_CCS811
    #define USE_CCS811
    #endif
    #ifndef USE_DISPLAY
    #define USE_DISPLAY
    #endif
    #ifdef USE_DISPLAY_TM1637
    #undef USE_DISPLAY_TM1637
    #endif
    #ifndef USE_DISPLAY_MAX7219_MATRIX
    #define USE_DISPLAY_MAX7219_MATRIX
    #endif
    #ifdef TELE_PERIOD
    #undef TELE_PERIOD
    #endif
    #define TELE_PERIOD 60
  5. Extra lines can be added to automatically connect to wifi and the MQTT server:
    #undef  STA_SSID1
    #define STA_SSID1         “(AP name here)”             // [Ssid1] Wifi SSID
    #undef  STA_PASS1
    #define STA_PASS1         “(AP password here)”     // [Password1] Wifi password
    // — Setup your own MQTT settings  —————
    #undef  MQTT_HOST
    #define MQTT_HOST         “(mqtt server ip address here)” // [MqttHost]
  6. Build the base tasmota and upload into the NodeMCU.
  7. Set the IO pin configurations as in the picture:
  8. Set the MQTT topic and FullTopic.
  9. After a reset, the NodeMCU will be available to the MQTT server, display commands can be sent with (Full Topic)cmnd/DisplayText
← All posts
← Using VS Code to Create a Windows Forms Application (View Webcam) Benq GL2440 24” Monitor Repair →