ESP Easy+DHT22+BMP180 : how to create a virtual BME280 barometer

In this tutorial, we will see how to create a virtual instrument combining several measures of other sensors in a Dummy Device firmware ESP Easy. A practical use case is to combine the moisture measurement obtained using a DHT11 or DHT22 with the measurement of atmospheric pressure accomplished by using a BMP180. By combining the three measures, or can simulate one BME280 very easy to integrate into Domoticz for example.

List of material

esp8266 Wemos D1 mini Any ESP8266 ESP-12 module, for example Wemos D1 Mini
 BMP180 Atmospheric pressure

BMP180

Broches DHT22 Temperature and humidity sensor

DHT11 or DHT22

oled ssd1306 ecran i2c Monochrome OLED display 168×64 pixels 0.96″

SSD1306

jumper dupont Jumper Dupont
breadboard Breadboard
led 3mm Led (optional, follow the WiFi activity)
resistance 220ohms Resistor 220Ω (optional)

Circuit

Here is a mapping between Arduino and ESP8266 pins. You can also add a OLED SDSD1306 display if you want.

Component Pin Arduino Pin Equivalence ESP8266 (Wemos D1 mini)
DHT22 VDC 5V 5V
GND GND G
Data GPIO-14 G5
BMP180 VDC 5V 5V
GND ‘ GND G
SDA GPIO-4 D2
SCK GPIO-5 D1
OLED SSD1306 0.96 “ VDC 5V 5V
GND GND G
SDA GPIO-4 D2
SCK GPIO-5 [] D1
Led WiFi activity Pole + GPIO-12 D6
Pole- GND G

cablage espeasy + dht22 + ssd1306 + bmp180

Create Devices DHT22 and BMP180

I got the mini previous project based on DHT22 and BMP180. You must have a Device called DHT22 which has 2 variables TempDHT22 and HumDHT22 (to change at your convenience)

espeasy dht22 configuration

And a BMP180 Device with a variable pressure

espeasy configuration bmp180 bmp085

Create a dummy device under Domoticz

Under Domoticz, create a virtual device with the type sensor Temp + humidity + barometer. Give it a name and note the IDX in the list of devices.

domoticz capteur virtuel temp humidite barometre bme280

Add a dummy device under ESP Easy

Now we can create a new Device and select Dummy Device in the list then under ESP Easy with the following settings:

  • Name : give a name. For example BME280_Virtuel
  • Delay : frequency discount (or publication) values
  • IDX : ID of the virtual sensor Domoticz.
  • Simulate Data Type : choose Sensor_type_Temp_Hum_Baro to simulate a BME280
  • Send data : check to enable the sending of data to Domoticz
  • Decimals : select the number of digits after the decimal point
  • Value name 1 : Temperature
  • Value name 2 : moisture
  • Value name 3 : Pressure
  • save with submit

esp easy dummy device bme280 virtuel

In the Rules Editor, copy this code

on DHT22#TempDHT22 do   // A chaque actualisation de la mesure de température
  // Recopie dans le Device Dummy 
  TaskValueSet 4,1,[BMP180#Temperature] // la température 
  TaskValueSet 4,2,[DHT22#HumDHT22]     // le taux d'humidité
  TaskValueSet 4,3,[BMP180#Pression]    // et la pression atmosphérique
endon

What did this code?

Whenever a measure is referred back by the DHT22, we fill in the Dummy Device the temperature and air pressure of the BMP180 as well as the level of humidity in the DHT22 in the Dummy Device no. 4

the command TaskValueSet is written like this

TaskValueSet <task nr>,<taskvalue nr>,<value|formula>

  • task nr  : number of the Device (recovered in the Devices column Task table)
  • taskvalue nr : index of the variable (1 to 4) the Dummy Device
  • value or formula : value assigned to the variable, or formula with the operators +, -, /, * only.

Go back in the Devices. Each update of the temperature measured by the DHT22, the virtual BME280 will be updated.

esp-easy-bme280-virtuel

Display the virtual BME280 under Domoticz

Return now on Domoticz to see how fits the BME280.

are going first in the devices to check that we receive good measures of the ESP8266. The order of the variables is very important when setting up the Dummy Device since firmware publishes the measures of the virtual BME280 in the order of the variables. Here, we get good temperature, humidity and atmospheric pressure. As the units are metric by default, we have no conversion to do (otherwise the formulas are for).

domoticz espeasy bme280

Now go to the weather page to find the barometer.

domoticz barometre bme280

On the temperature page, we have now a new sensor that displays the temperature and the humidity in the air. It is the combination of the temperature measured by the BMP180 (or the DHT22, it’s equal) and the level of humidity in the DHT22. We find the atmospheric pressure measurement and calculation of the dew point.

domoticz bme280 temperature humidite

On this graph, you can see the integration of the measurement of the humidity. I simply stopped sending data on the device BMP180 and recovered the IDX for the attributed to the BME280 virtual so as not to lose the history of measures.
domoticz bme280 historique temperature

 

Here’s one of the possibilities of the Dummy Device very easy to implement with the new system of Rules of ESP Easy.

Subscribe to the weekly newsletter

No spam and no other use will be made of your email. You can unsubscribe anytime.

1 Comment
  1. Hi,

    Thanks for this Nice site and explaning how to use Domoticz.

    I was almost there but stuck on the editor thing.

    Where and how can I use the “rules editor” ? ?

    Regards and thanx.

    Allard

Leave a Reply

DIY Projects
%d bloggers like this: