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
|Any ESP8266 ESP-12 module, for example Wemos D1 Mini|
|Temperature and humidity sensor|
|Monochrome OLED display 168×64 pixels 0.96″|
|Led (optional, follow the WiFi activity)|
|Resistor 220Ω (optional)|
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)|
|OLED SSD1306 0.96 “||VDC||5V||5V|
|Led WiFi activity||Pole +||GPIO-12||D6|
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)
And a BMP180 Device with a variable pressure
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.
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
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.
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).
Now go to the weather page to find the barometer.
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.
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.
Here’s one of the possibilities of the Dummy Device very easy to implement with the new system of Rules of ESP Easy.