Temperature Telemetry: Seize the Power of DIY ESP8266 Devices

The most universally applicable use of IoT devices is collecting a wide range of telemetry data. Whether your goal is to decrease energy consumption, gain new insights into your surroundings, enhance your security systems, improve your environmental quality, or catch early warnings of potential problems, the initial task is to gather the necessary data to work with. In this case, ESP8266 in conjunction with unicontrol can be an invaluable asset. Its versatile approach allows the measurement and publishing of various types of data, with temperature being a prime example.

Certainly, there is a multitude of sensors capable of reading temperature, so let’s begin with a brief overview of the options provided by unicontrol.

Temperature Telemetry dashboard

Available sensors

The table below provides a concise comparison of various thermometers compatible with unicontrol:

DHT11DHT22DS18B20NTC/PTC
Short descriptionBasic indoor home temperature and humidity sensor.Advanced home temperature and humidity sensor.Professional, industrial-grade digital thermometer probe.Temperature-sensitive resistor with no embedded electronics.
Voltage3.3V5.5V3.3V6V3V5VN/A
RangeT: 0°C50°C
H: 20%90%
T: -40°C80°C
H: 0%100%
-55°C125°CDepends on calibration and technical specifications of the chosen unit.
Accuracy±1°C/±5%±0.5°C/±2%±0.5°C (-10°C85°C)
Precision~0.25°C/1%0.1°C/0.1%<0.1°C
Advantages+ Cheap
+ Provides relative air humidity
+ High precision, accuracy, and range
+ Provides relative air humidity
+ High precision, accuracy, and range
+ Reliable
+ Several hardware variants, including waterproof
+ Very cheap
+ Many hardware variants, including waterproof
Disadvantages– Unreliable (the unit may freeze after some time)
– Low precision, accuracy, and range
– Unreliable (the unit may freeze after some time)
– Relatively higher price
N/A– Challenging set-up
– May be difficult to choose the right component (recommended 10k NTC)
ConclusionVery affordable, but potentially unreliable temperature and humidity sensor. Use when humidity readings are required, and precision is not critical. Adding a capacitor may be necessary to improve reliability.Highly precise, but potentially unreliable temperature and humidity sensor. Use when accurate humidity readings are required. Adding a capacitor may be necessary to improve reliability.Highly reliable, precise, and affordable industrial-grade thermometer. Should be a default choice for any temperature measurements.Highly reliable, precise, and cheap thermistor. Unlike the other alternatives this thermometer does not have its own processing unit, and the temperature needs to be derived by the microcontroller. Use only in large batches when the time-consuming calibration pays off.

Telemetry data example

Explore the gallery featuring various telemetry charts derived from the sensors discussed earlier. The differences in data quality and detail are immediately apparent when plotted.

Basic setup

The subsequent sections assume that unicontrol is already uploaded to your ESP8266 and it’s successfully connected to your Wi-Fi network. If this isn’t the case, please refer to these sources first:

  • If you have Chrome or Edge desktop browser available:
  • If you do not have Chrome or Edge desktop browser available:

DHT11 & DHT22

The DHT (Digital Humidity and Temperature) family of sensors represent the most basic choice for home projects. While there’s only one type for each of these sensors, they typically come with a wide array of supporting hardware. The choice among these options boils down to convenience and personal preference. Nevertheless, these sensors always come with three usable pins (identical for both versions) that connect as follows:

  • VCC – First, connect the power pin to either 3V or 5V (preferred) on the ESP8266.
  • GND – Secondly, connect the ground pin to the GND pin on the ESP8266.
  • DATA – Lastly, connect the data pin to one of the available digital pins, preferably D5, D6, or D7.

Within unicontrol, using either the DHT11 or DHT22 is straightforward. You simply need to define it as a peripheral device and select it in the relevant process:

Various DHT modules
Various DHT modules

Peripheral

To define the DHT11 or DHT22 in the Peripheral menu, you will need to expand the digital peripheral where the sensor’s DATA pin is physically connected, then select IN - DHT11 or IN - DHT22, respectively, as the Hardware.

DHT11 & DHT22 Peripheral setup

Process

The remainder of the task is handled in the individual processes, where you select the same pin as the Input source. Afterwards, this process will operate with the real-time values obtained from your DHT sensor.

The DHT family of sensors also natively offers information about the relative humidity of the ambient air. This data is differentiated from the temperature in the process’ Input section, where the default Channel of 0 represents Temperature, while changing it to 1 will return Humidity.

The DHT11 and DHT22 can be a suitable option and potentially reliable sensors, however this family of sensors appears to be highly dependent on steady and sufficient power supply. Otherwise their chips are prone to freezing. In that case, soldering a single capacitor (>200uF) is usually sufficient to improve the reliability.

D5 (DHT11), channel 0 (Temperature) selected as the process input
D5 (DHT11), channel 0 (Temperature) selected as the process input
D5 (DHT11), channel 1 (Humidity) selected as the process input
D5 (DHT11), channel 1 (Humidity) selected as the process input

DS18B20

The DS18B20 thermometer is considered the gold standard in most industrial applications, thanks to its reliability and capability to host multiple nodes on a single wire. It’s available in several case types, including the bare TO-92 sensor and various waterproof probes. Regardless of the type, they all come with three pins that connect as follows:

  • VCC – First, connect the power pin to either 3V or 5V (preferred) on the ESP8266.
  • GND – Secondly, connect the ground pin to the GND pin on the ESP8266.
  • DATA – Lastly, connect the data pin to one of the available digital pins, preferably D5, D6, or D7.

While it’s technically possible, due to the limited voltage and maximum current of ESP8266 GPIO pins, unicontrol does not support parasitic power supply on DS18B20. Additionally, even though it’s possible to host up to 12 sensors on a single GPIO pin, you can only select one pin to host the DS18B20.

Within unicontrol, using the DS18B20 is straightforward. It simply needs to be defined as a peripheral device and selected in the relevant process:

Peripheral

To define the DS18B20 in the Peripheral menu, you need to expand the digital peripheral where the sensor’s DATA pin is physically connected and select IN - DS18B20 as the Hardware.

Various DS18B20 modules
Various DS18B20 modules

The DS18B20 requires a pull-up resistor between its DATA and VCC pins.

DS18B20 Peripheral setup

In fact, the DS18B20 has two options in the Hardware setting, with the only difference being the frequency of the temperature readings. While the Fast option refreshes the temperature every 5 seconds, the Slow option only provides a new reading every 5 minutes.

Process

The remainder of the task is handled in the individual processes, where you select the same pin as the Input source. Afterwards, this process will operate with the real-time values obtained from your DS18B20 sensor.

A key feature of the DS18B20 is its ability to host multiple sensors on a single pin (unicontrol allows for up to 12 devices). The distinction between individual sensors is made through the Channel option, which indexes the existing nodes starting always from 0.

Channel 0 is automatically valid if you only have one device connected to the wire. If you have 4 different sensors connected, they will be indexed 03, and so on. While you do not have the option to index them by their own ID, the indexing remains constant.

D6 (DS18B20), channel 0 selected as the process input
D6 (DS18B20), channel 0 selected as the process input

NTC/PTC Thermistors

NTC (Negative Temperature Coefficient) and PTC (Positive Temperature Coefficient) resistors offer the most fundamental form of temperature measurement, as they enable the user to directly measure the resistance of the temperature-sensitive probe without the aid of built-in pre-calibrated electronics, as is the case with DS18B20 or DHT sensors. Hence they are especially useful and reliable in harsh environments such as ovens, 3D printer hotends, and more.

Natively, the ESP8266 only has one usable analog pin (A0), that can host a thermistor. However, by using an analog multiplexer , you can increase the number of potential analog inputs to eight, effectively substituting the A0 with I1I8 peripherals.

Various thermistor options
Various thermistor options

Wiring

As these thermometers are essentially simple resistors, they do not have any dedicated pins. Instead, they have two equivalent legs. Nevertheless, their connection significantly varies depending on the ESP8266 variant used for the project. If it is part of a development board (WeMos D1 mini, NodeMCU, etc.), then a simple voltage divider configuration is sufficient to obtain the readings.

The presented schematics make use of a 10k resistor and a 10k NTC thermistor as the recommended choice. However, these can be replaced with different values if needed.

The simple case with integrated voltage divider.

These development boards usually include a second (100k / 320k) voltage divider included between the A0 pin and their A-D Converter, reducing the maximum voltage to 1V from of 3.3V. If this is missing, as in the ESP-12x family, it needs to be manually added and should follow the included schematic.

You can see this done, for example, in the assembly section of the Irrigation System blog post, as the relay module used for the project carried the ESP-12F version of the ESP8266.

The case with the external voltage divider.

Peripheral

In the Peripheral menu, instead of defining the type of the thermistor, you will need to define the Mapping. This mapping serves as tailored calibration for the specific connected analog device.

In the Edit Mapping menu, you need to provide the mapping’s name, unit sign, and multiple pairs of ADC values and their corresponding unit values.

Please check the user guide to learn more about how the mapping works and how you can create one for yourself.

You can download the example mapping data for the 10k NTC thermistor:

Please refer to the user guide to learn how to import the backup files.

NTC Peripheral setup
Mapping of the analog input
Mapping of the analog input

Process

With all the Peripheral setup done, the only remaining step is to select the relevant analog pin as the Input source. From that moment on, this process will operate with the up-to-date mapped values obtained from the ESP8266’s ADC.

Compared to the digital DS18B20 or DHT sensors, the analog input excludes the Channel option, which is irrelevant for this input type.

A0 (NTC) selected as the process input
A0 (NTC) selected as the process input

Telemetry publishing

One of unicontrol‘s standout features is its robust internal protocol for publishing telemetry via MQTT. However, two conditions must be met for publishing to occur:

  1. Connection with the MQTT broker is active. This requires providing the correct MQTT settings. You can verify whether the connection is currently active in the System menu.
  2. Publishing is Allowed in the respective process’ Input section (this is set individually for each process).
Extract from the Input section of the Processes menu
Extract from the Input section of the Processes menu

Once connected to the MQTT, you can enable the respective process’ input telemetry publishing by clicking the Allowed checkbox. Additionally, you might find the Use name as Subtopic option useful, or you might want to define a specific publishing Frequency for an optimal balance between data granularity and the performance of both the wireless network and the ESP8266 itself.

If possible and allowed, the process input telemetry is automatically published at predefined intervals as payloads to standardized topics, structured as [Topic Level 1-3]/pub/[Process ID]/output. Please check the MQTT Telemetry documentation for more details on the built-in protocol.

To identify the correct telemetry topics, hover your mouse over the small symbol right next to the Publish option. An information pop-up window will immediately appear, containing the valid MQTT topic on which you will receive the published telemetry, if relevant.

Input publish info-box.

Telemetry examples

In the gallery below, you can see real-world examples of how unicontrol-generated telemetry was utilized using the Node-RED dashboard. “There are, however, many other third-party tools and apps that can take advantage of the data generated by unicontrol.

Besides MQTT, unicontrol also features a robust HTTP API that serves a similar purpose, making it easily integratable with other systems.

Here are some excellent resources and examples on how to build simple dashboards with MQTT telemetry as an input:

Casing

After completing your own ESP8266 thermometer device, you still only have the bare hardware. Obviously, this is aesthetically not very pleasing and your device is vulnerable to any physical contact. To address this, you can download the model of our universal thermometer enclosure from any of the sources below and print it for yourself. View the results in the included gallery.

2 thoughts on “Temperature Telemetry: Seize the Power of DIY ESP8266 Devices”

  1. Is it possible to send data from sensors to domoticz, or to use them somehow in InfluxDB and Grafana?
    When you will support ESP32 ?

    Reply
    • Thanks to fully standardized data protocols, it is possible to natively use with any tool supporting MQTT or HTTP exchange. Moreover, with the help of Node-RED or similar tool the data should be possible to collect and process in any database or data visualization tool. Unfortunately, I cannot give any specific information related to the ESP32 at the moment.

      Reply

Leave a Comment