Build a cheap water usage sensor using ESPhome and a proximity sensor

water usage in home assistant energy dashboard

This article will provide you with a walkthrough on how you can build a water usage meter sensor that integrates with your Home Assistant for under 10 $/EURO without the need for any soldering or coding skills.

This article will also cover the configuration that’s needed in Home Assistants to translate the ‘pulse’ to liters (or any other non-metric measurement) in Home Assistant. In the end you will have clear insights in how much water you are using per day, hour, and week.

Why do you want to measure water usage of your home?

These days it’s all about insights. I measure pretty much all my utilities, including power and city heating. The last missing piece is water usage. Although the water in the Netherlands is not really expensive, I wanted to get more insights into how much water we are using and if there is any way to save some water. Unfortunately, water delivery doesn’t come with a smart meter. There’s just an analog counter. So how do you measure the water usage and make this analog meter smart?

See water usage in the Home Assistant Energy Dashboard

The 2022.11 release of Home Assistant added the option to track water usage in the Home Assistant Energy dashboard. The ESPhome configuration has been updated to support this feature. Thanks to MJV for sharing his configuration on the Home Assistant forums.

Continue reading “Build a cheap water usage sensor using ESPhome and a proximity sensor”

2022 update: Flash ESPhome on ESP32 ESP2866 NodeMCU board

A lot is changed since I wrote multiple articles around ESPhome. One of the mayor things is that ESPhome is now part of HomeAssistant core and it comes with a nice integrated User Interface.

What are ESP32 and ESP2866 nodeMCU boards?

ESP boards are a low cost Wi-Fi chips that have built in flash chips allowing you to build a single chip device capable of connecting to Wi-Fi. newer versions like the ESP32 boards also provide you BLE (Bluetooth low energy) and there’s loads of variety of boards you can use.  

With ESP you can easy make smart solutions for HomeAutomation. You can buy them for about 4-9 dollar/euro on AliExpress or for a bit more with faster delivery on Amazon.

Read more about ESP boards in my introduction to ESP boards article

This article is an updated version of the the Compile and flash your ESP with ESPhome article.

Continue reading “2022 update: Flash ESPhome on ESP32 ESP2866 NodeMCU board”

Adding centerfire, increase and decrease to your smart Bellfire fireplace solution

In previous article series I provided an overview and step by step instruction how to make you Bellfire fireplace with Mertik Maxitrol controller smart. This project that was presented during the Home Assistant Conference 2020.

In the article series and presentation I focused on the essential controls, basically turning the fireplace on and off. I received number of requests to extend the controls to support increasing and decreasing the fire and also activating the so called center burner.

After doing some research and trial and error I’ve found the combinations for the relays to add these features to your smart fireplace.

Continue reading “Adding centerfire, increase and decrease to your smart Bellfire fireplace solution”

Build a cheap air quality sensor using ESPhome, Home Assistant and a particulate matter sensor

This article will provide a walkthrough of how you can build a Particulate Matter Air Quality meter that integrates with your Home Assistant for under 20$, without any soldering or coding skills needed.

The sensor will provide multiple air-quality measurements directly visible in Home Assistant.

After seeing all kinds of air purifiers in the market, like the one from Xiaomi and Philips. I got interested in the topic air quality. First, I needed to learn more about how and what to measure, followed by actually measuring the air quality in my home. I don’t want to buy a air purifier if the quality of the air in my home is not bad. But how do you measure air quality?

What is a Particulate Matter sensor?

My search started with looking for a particulate matter sensor. A particulate matter sensor measures tiny particles or droplets in the air that have a specific size in microns or micrometers (µm). Like inches, meters and miles, a micron is a unit of measurement for distance. There are about 25,000 microns in an inch.

Particulate matter is the sum of all solid and liquid particles suspended in air many of which are hazardous. This complex mixture includes both organic and inorganic particles, such as dust, pollen, soot, smoke, and liquid droplets. These particles vary greatly in size, composition, and origin.

Source: www.greenfacts.org

Particulate matter (PM) is generally classified into two main size categories: PM10 and PM2.5. As an example, the particulate classified as PM2.5 is the size of 2.5 µm and would be thirty times smaller than that of a human hair.

Continue reading “Build a cheap air quality sensor using ESPhome, Home Assistant and a particulate matter sensor”

Step 5: Wire the relays to the fireplace

This article is part of the Make your Bellfire fireplace smart project that I presented during the Home Assistant Conference 2020.

It’s time to execute the final step, you can find all steps in the overview how it all going to work article.

Now everything is set. We now can connect the relays to the fireplace and light up the fireplace using Home Assistant.

The wiring

Again very basic wiring is needed.  I need to make sure that I connect the wiring to map the pinout of the fireplace.

If we look at the pin-out on the fireplace, going bottom up.

  • Pin 0 is the common circuit and need to be connected to the COM of all three relay.
  • Pin 1 wires to the Normal Open (NO) port of relay 1
  • Pin 2 wires to the Normal Open (NO) port of relay 3
  • Pin 2 wires to the Normal Open (NO) port of relay 3

See wiring details below.

wiring

That’s it! Now sit back, open Home Assistant and press the ignite button. Your fireplace will now lite up.

Step 4: Configure ESPHome to control the relays from Home Assistant

This article is part of the Make your Bellfire fireplace smart project that I presented during the Home Assistant Conference 2020.

It’s time to execute the fourth step, you can find all steps in the overview how it all going to work article.

The wiring is now ready, let’s expose three switches to Home Assistant to control the relays.

Expose pins as switches

Open ESPHome and click EDIT on your node. The ESPHome configuration editor will now show. Add following configuration in the bottom of the configuration.

switch:
  - platform: gpio
    pin: GPIO13   #D7
    name: "IN1" 
    id: IN1
  - platform: gpio 
    pin: GPIO12  #D6
    name: "IN2"
    id: IN2
  - platform: gpio 
    pin: GPIO14  #D5
    name: "IN3" 
    id: IN3

Note: The PIN name is translated from the physical D number printed on the ESP to the addressable name used in configurations and programming.  E.g. pin D7 is referred to as GPIO13, all mappings can be found in the image in the ESP Intro section.

UPDATE (thanks Petr): “Fortunately ESPHome knows the mapping from the on-board pin numbers to the internal pin numbering, but you need to prefix the pin numbers with D as in the image below in order for this automatic mapping to occur. In general, it is best to just use the D0, D1, … pin numbering to avoid confusion”

We are adding three switches of the platform type GPIO, this means that the switch will 1:1 control the GPIO pins. For every switch we define the GPIO pin that is controlled, and we provide a name and ID.

Flash the firmware Over The Air (OTA)

That’s it, now flash the firmware of the ESP with the updated firmware based on our new configuration. We do not need to use the flasher tool anymore, we can use the Over-The-Air flash feature to flash the chip with the new firmware over the WiFi Connection. It is as easy as clicking the UPLOAD button.

ESPHome will compile the new firmware, send it over to the ESP that will than flash itself. After flashing the ESP will come back online with the new firmware. It does not get much easier!

Control the relay from Home Assistant

Wait till the ESP has been flashed successful and is connected to the WiFi.

Find your device in Home Assistant, noticed that the device now has 3 entities. Click on the device and you’ll see that it has three switches, called IN1, IN2 and IN3.

Press the switches and enjoy the sound of clicking relays. Every switch should control the matching relay.

Create timing to control the fireplace

To control the fireplace I need to match following sequences with the switches:

  • Ignition, close contacts 1 and 3 simultaneously for 2 seconds
  • Fire off, clos contact 1,2, and 3 simultaneously for 1 second

We need to control the relays in these sequences with the ESP board. We can do this by extending the ESP configuration. We’ll add an Ignition switch that will execute sequences above when turned on and off.

Open ESP home and click edit on the node to go to the configuration editor.

Add a new Switch (right under IN3) with following configuration.

- platform: template
    name: "Fireplace_ignition"
    id: Fireplace_ignition
    turn_on_action:
      - then:
        - switch.turn_on: IN1
        - switch.turn_on: IN3
        - delay: 2s
        - switch.turn_off: IN1
        - switch.turn_off: IN3
        - switch.template.publish:
            id: Fireplace_ignition
            state: ON
    turn_off_action:
      - then:
        - switch.turn_on: IN1
        - switch.turn_on: IN2
        - switch.turn_on: IN3
        - delay: 1s
        - switch.turn_off: IN1
        - switch.turn_off: IN2
        - switch.turn_off: IN3
        - switch.template.publish:
            id: Fireplace_ignition
            state: OFF

Press the Upload to compile, upload and flash the ESP with the new firmware. Test your new switch and verify that the relay react as expected.

Now it’s time to for the last step, time to wire the relays to the fireplace.

Step 3: Wiring the ESP to the relay

This article is part of the Make your Bellfire fireplace smart project that I presented during the Home Assistant Conference 2020.

It’s time to execute the third step, you can find all steps in the overview how it all going to work article.

To control the relay we need to provide high or low power to the IN ports of the board. This board has four relays. In my example I only need to use three relays.

Wiring the relay board to the ESP is easy. I always use Dupont cables and mini breadboards, this way soldering is not required.

Powering the relay board

The relay board needs 5v power. We will power the relay board directly from the ESP using the 5v VIN pin.

Controlling the relays

Pin D5, D6, and D7 will be used to control the three relays on the board.

See wiring image below for more details.

The wiring is now ready, let’s expose three switches to Home Assistant to control the relays. Read the next article.