In order to further automate the ventilation of my house I want to be able to measure CO2 levels in the livingroom and have the ventilation adjusted according.
This post describes how to connect everything and get the readings to Domoticz. In a next post I will describe how to use these readings to setup automatic home ventilation.
Before we start messing with the ESP and connecting the MH-Z19 to the arduino, we need to create a dummy device to update the status to in Domoticz.
In Domoticz go to Setup > Hardware and, if you don’t have one already, add the dummy hardware (1,2). And then click create a virtual switch.
Now add a new virtual sensor, choose Custom Sensor as the Sensor Type. The name is up to you.
In Domoticz go to Setup > Devices, locate the custom sensor just created and make note of it’s IDx, we will need it later.
I prefer to have the correct and most recent arduino drivers present on my computer, to do this. I install Arduino IDE from the windows 10 store, this way it is kept up to date for me automatically. But obviously there are several way’s to get the drivers.
Next we download the latest version of ESP Easy by letscontrolit. ESP Easy can be found on their github page.
Then flash the firmware by using FlashESP8266.exe
For a much more comprehensive story on how to flash these see their wiki.
Finish the installation by following the last steps on the wiki.
Where to go from here
If everything has gone right you have a useable ESP Easy device now.
As no parameters are set it will go to "AP mode" for configuration.
Use your computer, tablet or smartphone and search a WiFi network named "ESP_Easy_0".
Connect to ESP_Easy_0 using the password "configesp" (without "").
Open your internet browser and type 192.168.4.1 as internet address into the browser. The WiFi setup of the ESP Easy opens.
You can choose your WiFi network now. Select the SSID and enter your passphrase, click connect.
It will take 20 seconds until a result is shown. If you typed everything correctly it will show a message that it is connected to the network and it shows the IP address.
Note the IP address!
Connect your computer or whatever back to your usual network. Open a browser and type the ip address into the browser.
You should see the config pages of ESPEasy now.
Connecting MH-Z19 to ESP8266
Now that we have got Domoticz and the ESP8266 ready let’s hook everything up. Connecting everything is very simple. Just connect everything up as in the follows. Note that i’m using VU (usb power output pin) to supply 5v to the MH-Z19.
Power-up the Arduino and connect to it’s ip adress.
Under the tab controllers input the details of your domoticz.
Next, under the devices tab add the MH-Z19 sensor and give the domoticz device IDx for the virtual device that was created at the beginning.
After submitting the settings you should see the device starts to update in Domoticz.