DIY Temperature sensor for Home Assistant that will cost you $6 - Kiril Peyanski's Blog (2023)

Nowadays, DIY temperature sensor for Home Assistant can be very easy and cheap – especially, if you have a complete guide like this one that will show you all the steps.

I will try my best to show you everything needed for the DIY Temperature sensor for Home Assistant:

  • What parts are needed?
  • How much they cost?
  • From where to buy them?
  • How to connect them?
  • How to configure them?
  • How to install ESPHome?
  • And finally, how to add your smart DIY Temperature & Humidity sensor to Home Assistant?

On top, if you have access to a 3D printer I will also show some enclosures that can make the sensor looks better.

DIY Temperature sensor for Home Assistant that will cost you $6 - Kiril Peyanski's Blog (1)

So, buckle your belts as we are starting with the needed parts for this DIY Temperature & Humidity sensor.

Table of Contents

What parts are needed?

Wemos D1 Mini

The first thing that you will need Is an ESP8266 device, and I’m going to use a Wemos D1 Mini.

DIY Temperature sensor for Home Assistant that will cost you $6 - Kiril Peyanski's Blog (2)
(Video) Add Samsung SmartThings to Home Assistant (HOW-TO)

Later, on the D1 Mini I will install the ESPHome software.

DHT22 – Temperature and Humidity Sensor

Also, on the D1 Mini I will attach the Temperature & Humidity sensor. The exact model of the sensor that I’m going to use is AM2302 DHT22 and it is looking like this:

Jumper Wires

I will also need 3 female-to-female jumper wires, also known as Dupont wires. Of course, if you have other suitable cables you can use them instead.

DIY Temperature sensor for Home Assistant that will cost you $6 - Kiril Peyanski's Blog (4)

USB Cable & optionally USB Adapter

The final things that are needed are micro USB cable and optionally an USB adapter (if you have plans to plug this Cheap & Smart Temperature & Humidity sensor in the power socket).

DIY Temperature sensor for Home Assistant that will cost you $6 - Kiril Peyanski's Blog (5)
DIY Temperature sensor for Home Assistant that will cost you $6 - Kiril Peyanski's Blog (6)

As I said this USB adapter is optional as you can just plug the sensor in any USB port that you have available.

How much does it all cost?

All components will cost you around $5 to $6 US Dollars (if you already have microUSB cable) and you can buy them using the AliExpress affiliate links below:

At the end of the day, it is not so important from where you will get the needed parts, but how you will connect them and how you will configure them. So, moving to the next step, which is how to connect the D1 Mini and DHT22 sensor together.

How to connect D1 Mini and DHT22 sensor?

D1 Mini comes with these pins and these pins are not soldered so I recommend to solder them as later on, plugging the Jumper wires will be pretty easy.

DIY Temperature sensor for Home Assistant that will cost you $6 - Kiril Peyanski's Blog (7)

Here are the steps to connect D1 Mini and DHT22 Sensor:

  1. Connect the + (plus) output on the DHT22 to the 3V3 pin on the D1 mini.
  2. Then connect the middle output of the DHT22 labeled Out to the D2 pin on the D1 Mini
  3. Finally, connect the - (minus) on the DHT22 to the G (Ground) pin on the D1 mini.

This is how everything looks like at the end:

DIY Temperature sensor for Home Assistant that will cost you $6 - Kiril Peyanski's Blog (8)

How to install ESPHome on the D1 Mini

Next step is to upload ESPHome software on the D1 Mini device. There are multiple ways doing this, but I will use one of the easiest, which is to install ESPHome add-on in the Home Assistant. If you don’t have Home Assistant yet, check this article of mine where I’m explaining what are your options 👉 LINK.

Let’s see how to install the ESPHome add-on.

  • Add the official ESPHome add-on repository by click on this link.
  • While in Home Assistant, press the “c” button on your keyboard and start typing Add-on, then select Navigate Add-on store.
  • Next, search for ESPHome, click on the result and then click on the Install button.
  • When the installation is finished the Install button will be replaced with Start button – click on it to start the ESPHome add-on.
  • Wait few seconds for the ESPHome to start and then click on the Open Web UI button.
  • You should see similar screen as above. And you should click on the New Device button.
DIY Temperature sensor for Home Assistant that will cost you $6 - Kiril Peyanski's Blog (10)

New device dialog will appear on which you should enter a device name of your choice as well as you WiFi name and password. I named my device: d1-mini-th.

When you are ready click on Next button.

  • From the next dialog, click no Pick specific Board radio button and select the Wemos D1 and Wemos D1 mini. Of course, if your ESP board is different – either find it from the list or select the more generic ESP32 or ESP8266 options depending of your board type. Finally, click Next button.
DIY Temperature sensor for Home Assistant that will cost you $6 - Kiril Peyanski's Blog (11)
  • On the next dialog click on Install button, and when possible installation options appear, click on Cancel button. That is needed, because we have to add some YAML configuration before we actually install ESPHome.
DIY Temperature sensor for Home Assistant that will cost you $6 - Kiril Peyanski's Blog (12)
  • Click on the Edit button under your device name (the future T&H sensor) in the ESPHome dashboard.
DIY Temperature sensor for Home Assistant that will cost you $6 - Kiril Peyanski's Blog (13)
  • Paste the following lines at the very bottom of the configuration:
sensor: - platform: dht pin: D2 temperature: name: "Living Room Temperature" humidity: name: "Living Room Humidity" update_interval: 20s
DIY Temperature sensor for Home Assistant that will cost you $6 - Kiril Peyanski's Blog (14)

Here is how my whole D1 Mini and DHT22 configuration looks like at the end:

  • You may wish to change both names (Living Room Temperature & Living Room Humidity) to whatever is suitable for you. When you are ready, click on the Save button and then on Install button.
  • You will see the same “How do you want to install this on your ESP device?” dialog.
  • Plug the D1 Mini in one of the USB ports on the device where Home Assistant and ESPHome are installed and select “Plug into the computer running ESPHome Dashboard” option from the list.
DIY Temperature sensor for Home Assistant that will cost you $6 - Kiril Peyanski's Blog (15)
  • The USB port where your device is connected will be auto detected and you should only click on it, example: /dev/ttyUSB0.
  • If everything is fine, a terminal will appear with a lot of text and multiple text based progress bars. Wait until you see some temperature and humidity readings or something like this below:
DIY Temperature sensor for Home Assistant that will cost you $6 - Kiril Peyanski's Blog (16)

Challenge for You!

I have a quick challenge for you! If you reach this point and you managed to install ESPHome on your future Smart Temperature & Humidity sensor – let me know in the comments by just type – #THowned

Where TH stands for Temperature and Humidity. I will be very happy to see such hashtags there!


Now, let’s finish this by adding the D1 mini and DHT22 based smart Temperature & Humidity sensor in Home Assistant.

Adding D1 Mini and DHT22 to Home Assistant

Before you continue further it is a good idea to check in the ESPHome dashboard if your DIY Temperature Sensor for Home Assistant is actually online.

DIY Temperature sensor for Home Assistant that will cost you $6 - Kiril Peyanski's Blog (17)

If the D1 Mini and DHT22 are online, then you are almost ready and you just have to add your ready to use T&H sensor in your Home Assistant. Here is how:

In Home Assistant go to:

  • Press the “c” button on your keyboard and start typing integrations, then select Navigate Integrations.

DIY Temperature sensor for Home Assistant that will cost you $6 - Kiril Peyanski's Blog (18)

  • Search for ESPHome integration within the list with discovered integrations and click on the Configure, then Submit and finally Finish buttons.
DIY Temperature sensor for Home Assistant that will cost you $6 - Kiril Peyanski's Blog (19)

As a result, 1 device with 2 entities will be added in your Home Assistant integrations page. Click on the 1 device link.

DIY Temperature sensor for Home Assistant that will cost you $6 - Kiril Peyanski's Blog (20)
  • On the next screen you can see your Temperature and Humidity readings and you can add this as a card in your Home Assistant Dashboard by just clicking on the Add to Lovelace button. From the same place you can start creating Home Assistant Automations, Scenes & Scripts.
DIY Temperature sensor for Home Assistant that will cost you $6 - Kiril Peyanski's Blog (21)

3D Printed enclosure/box

The only thing that is missing is a 3D printed enclosure. And here is what I managed to find and print on my Ender 3 v2 3D printer (my article about the printer):

Links to the 3D Models:

If you manage to find other good ones, please share them in the comments section below.

Summary

For around $5 to $6 US dollars and several minutes I managed to DIY temperature sensor for Home Assistant and with that to make my Home even Smarter. Try it out and you can do the same.

Feel free to secure this channel existence by using any of the supported methods in my Website support section.

Follow me on Twitter and join my Discord server.

Stay safe and don’t forget – Home Smart, but not hard!

I’m Kiril and I’m done writing. Bye!

FAQs

Which temperature sensor is less expensive? ›

Thermistors are inexpensive and accurate when measuring small changes in temperature.

How can I install xiaomi thermometer to home assistant? ›

Configuration
  1. Browse to your Home Assistant instance.
  2. In the sidebar click on Settings.
  3. From the configuration menu select: Devices & Services.
  4. In the bottom right, click on the Add Integration button.
  5. From the list, search and select “Xiaomi BLE”.
  6. Follow the instruction on screen to complete the set up.

Is there a temperature sensor that works with Alexa? ›

SwitchBot WiF Thermometer Hygrometer Set

This product is certified by Amazon to work with Alexa. This product can be controlled with your voice through Alexa-enabled devices such as Amazon Echo and Amazon Tap.

How do I add a sensor to my home assistant? ›

To add the Sensor card to your user interface, click the menu (three dots at the top right of the screen) and then Edit Dashboard. Click the “Add Card” button in the bottom right corner and select Sensor from the card picker. All options for this card can be configured via the user interface.

Which temperature sensor is best? ›

The fastest-possible temperature sensor is an exposed tip thermocouple. However, manufacturing improvements have also greatly improved the response times of thin-film PT100 probes. Accuracy: RTDs are generally more accurate than thermocouples. RTDs have typically an accuracy of 0.1°C, compared to 1°C for most.

What is the most accurate temperature sensor? ›

An RTD is the most accurate and stable temperature sensor and is more linear than a thermocouple or thermistor. However, RTDs are the slowest and most expensive temperature sensors. Therefore, they fit precision applications where accuracy is critical while speed and cost are less important.

How do you hook up a Mi temperature sensor? ›

The sensor is always paired exclusively via Bluetooth. The easiest way is to pair directly with your smartphone, via the Mi Home application. If the phone is within Bluetooth range, you will see the current temperature and humidity directly in the application.

Can home assistant connect to Bluetooth? ›

Home Assistant has support for remote Bluetooth controllers. Some controllers only support listening for advertisement data and do not support connecting to devices.

Does ESP32 have temperature sensor? ›

The ESP32-S2 has a built-in temperature sensor. The temperature sensor module contains an 8-bit Sigma-Delta ADC and a temperature offset DAC.

Does Echo Dot have temperature sensor? ›

The new Echo dot also features new sensors, including a room temperature sensor, so Alexa can turn on a smart fan when it notices the room getting too hot, and an accelerometer for tap gesture controls.

Where does Alexa get temperature? ›

Alexa uses AccuWeather for the latest weather information. This skill uses the device location set in the Alexa App settings.

› best-easiest-tempera... ›

Any switch will do. I am more concerned about the temperature sensor. Preferably I would like a simple thermometer/clock that has wifi capabilities. I really do...
What's up Smart Homers! In this article I'm going to compare 10 different temperature and humidity sensors that work with Home Assistant. Previously I&#...
In this video I review ten different smart temperature and humidity sensors that work with #HomeAssistant using Zigbee Home Automation (ZHA), Z-Wave JS, and ...

How do I add Hacs to my home assistant? ›

Select your User Account in the bottom left.
  1. Enable Advanced Mode in the account options.
  2. Now that Advanced Mode is enabled, we can install the Terminal & SSH application. ...
  3. Select Add-ons.
  4. In the bottom right, select Add-On Store.
  5. Search for Terminal & SSH, then select the Official add-on. ...
  6. Select the Install option.
15 Jun 2022

How do you reset the temperature and humidity sensor on a mi? ›

First method:

Remove battery from the XIAOMI Mi Temperature and Humidity Monitor 2 and keep it out for atleast 30 seconds. Install XIAOMI Mi Temperature and Humidity Monitor 2 battery back and wait a momment until device reboots. Awesome! Now all functionalities of XIAOMI Sensor should be restored.

Top Articles
Latest Posts
Article information

Author: Lidia Grady

Last Updated: 02/27/2023

Views: 6723

Rating: 4.4 / 5 (65 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Lidia Grady

Birthday: 1992-01-22

Address: Suite 493 356 Dale Fall, New Wanda, RI 52485

Phone: +29914464387516

Job: Customer Engineer

Hobby: Cryptography, Writing, Dowsing, Stand-up comedy, Calligraphy, Web surfing, Ghost hunting

Introduction: My name is Lidia Grady, I am a thankful, fine, glamorous, lucky, lively, pleasant, shiny person who loves writing and wants to share my knowledge and understanding with you.