Tag Archives: wemos

New CO2 sensor

Today I got, amongst other goodies a new CO2 sensor in the mail.

This is a MH-Z19C CO2/Temperature sensor.
(Easy to implement with ESPHome)

Calibrate using HD 7 seconds to GND
(Do this in a well ventilated room)

YAML Code

# Board: Wemos D1 Mini (ESP8266) (Wemos)
# Definition: definitions/boards/d1_mini/manifest.yaml

esphome:
  name: newco2
  friendly_name: NewCO2

esp8266:
  board: d1_mini

logger:

api:
  encryption:
    key: "c/vSFcxi1YgYlXtvsjXXXXXXXXXXXXXXXXXXXXXX="

ota:
  - platform: esphome

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  ap:
    ssid: NewCO2 Fallback Hotspot
    password: "tepe9XXXXXXXXXXX"

captive_portal:

uart:
  - baud_rate: 9600
    rx_pin: 4
    tx_pin: 5
    id: uart_1

sensor:
  - platform: mhz19
    uart_id: uart_1
    co2:
      id: sensor_mhz19_1_co2
      name: CO2
    temperature:
      id: sensor_mhz19_1_temperature
      name: Temperature
    id: sensor_mhz19_1
    automatic_baseline_calibration: true
    detection_range: "5000ppm"
    
switch:
  - platform: template
    name: "MH-Z19 ABC"
    optimistic: true
    on_turn_on:
      mhz19.abc_enable: sensor_mhz19_1
    on_turn_off:
      mhz19.abc_disable: sensor_mhz19_1

light:
  - platform: status_led
    name: status
    id: light_status_led_1
    pin: GPIO12

Analog Meters to display CPU and memory load

While this is a old project from 2019, I decided to make a more responsive one, after my friend Tyrone mentioned a project somewhere on the internet (forgot where).
Time to dust off this project!

2019 version

Above version worked but was slow.
I used a python script to send values to de controller.

Memory setup was the same.

Below my new schematic, using an opamp to drive the analog meter.

Untested design .. Yeah I got bored on new year’s eve

Utilizing a MCP41000 digital potmeter and a LM358 signal amplifier I hope to get a more responsive setup.

Input to display MQTT and maybe Serial.

Old version

Easy cheap touch light

Remember those expensive touch lights you can buy?

This is a less than 5 euro version.

Warning : Some tricks I used

  • Using D5 as GND (I didn’t want to splice GND Wire.)
  • Using PWM for dimming
  • Using 5V led, use resistor if using a generic LED (220ohm)

TTP223 sensors are only a few cents!
And react even without touching (< 5mm)
So, you can build this in a case or behind fabric!

NOTE: If you are using an ESP32 you can configure a pin as touch!!!
So no TTP223 needed.
But ESP32 are more expensive as Wemos mini.

Code:

#define TOUCH_PIN D2 // My video has D7
#define LED_PIN   D6
#define FAKE_GND D5

// Brightness steps (0 = off, 255 = full bright)
int brightnessLevels[] = {0, 25, 125, 255};
int currentLevel = 0;
bool lastTouchState = LOW;

void setup() {
  
  pinMode(TOUCH_PIN, INPUT);
  pinMode(LED_PIN, OUTPUT);
  pinMode(FAKE_GND, OUTPUT);

  digitalWrite(FAKE_GND, LOW);  
  analogWrite(LED_PIN, brightnessLevels[currentLevel]);  // start OFF
}

void loop() {
  bool touchState = digitalRead(TOUCH_PIN);

    if (touchState == HIGH && lastTouchState == LOW) {
      // Advance brightness step
      currentLevel = (currentLevel + 1) % 4;  // 0-3 steps
      int pwmValue = brightnessLevels[currentLevel];
      analogWrite(LED_PIN, pwmValue);
    }

  lastTouchState = touchState;
}

Dim levels less obvious on recording, but you can change the levels in the code!