DIY Projects

ESP Easy (Rules). Setpoint for connected thermostat. Home Assistant, Domoticz, Node-RED

Here is another example of applying ESP Easy Rules that will allow us to create a mini thermostat connected 100% DIY. For example, you can use this Rule to increase or decrease the thermostat setpoint. You can easily retrieve this instruction on a home automation software (Home assistant, Domoticz …) or a Node-RED or Javascript project.

 

For this tutorial, we will use two pushbuttons (increase, decrease) as well as an OLED display SSD1306 to display the setpoint. The OLED display will be controlled by a push button.

Equipment used

ESP8266 ESP-12 module. For example Wemos D1 Mini
x3 mini switch
Temperature sensor (optional)

DHT11 or DHT22

OLED monochrome SSD1306 display 168×64 pixels 0.96″

SSD1306

Jumper Dupont
Breadboard

Circuit

On the Wemos D1 mini, the SD1306 OLED screen is connected to the D1 (SCK) and D2 (SDA) pins. It is possible to modify the pins but in this case, do not forget to apply the changes on the Hardware page of ESP Easy. There are no special settings for the buttons. Be careful to use the 3V3 output to avoid damaging the GPIO of the ESP8266.

Configuring ESP Easy Devices

We will create 4 Devices:

Here is the configuration completed.

Increase button (Switch Input, UP)

Add a new Device and choose the Switch input type from the list and configure it like this:

Down Button (Switch Input, DOWN)

Add a new Device and choose the Switch input type from the list and configure it like this:

Setpoint (Dummy Device, SENSOR_TYPE_SINGLE)

Add a new Device and choose the Dummy Device type from the list and configure it like this:

OLED Display (SSD1306)

Finally, we will add a display to facilitate setting of the setpoint. Add a new Device and choose Display – OLED SSD1306. To find the address of the OLED screen on the I2C bus, you can find it with the I2C scanner located in the Tools. Configuration:

Rules

If the Rule tab is not visible, go to the Tools tab and select System -> Advanced and check Rules (at the bottom of the settings).

As we saw in the previous tutorial in which we created a virtual BME280, to create a setpoint, the trick is to create a Dummy Device. We will use the Rule system to increment and decrease the setpoint. For this to work, the formula must be bracketed. As usual, the current value of the setpoint is recovered by following the formalist [DEVICE # variable]. The new value of the setpoint is then assigned using the TaskValueSet command, which is written like this

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

TaskValueSet 3,1,([CONSIGNE#consigne]+0.5)

The increment is triggered with the trigger on UP#val do . We do the same to decrease on DOWN#val do . To avoid the setpoint remaining within a certain range, for example between 15°C. and 30°C., it is sufficient to add a small test, for example if the setpoint exceeds 30°C.

if [CONSIGNE#consigne]>30
  TaskValueSet 3,1,30
endif

Note. You have to respect the spaces and ‘paste’ the operators otherwise it does not work.

At start-up, it is not desired for the heating to stop, so the setpoint is initialized to a default value, for example 19°C.

on System#Boot do
  // Consigne par défaut au démarrage - default value at boot
  TaskValueSet 3,1,19 
endon

It only remains to paste in the Rule this complete code.

on System#Boot do
 // Consigne par défaut au démarrage - default value at boot
 TaskValueSet 3,1,19 
endon

on UP#val do 
 // Augmente la consigne - Up setpoint 
 TaskValueSet 3,1,([CONSIGNE#consigne]+0.5)
 if [CONSIGNE#consigne]>30
 TaskValueSet 3,1,30
 endif
endon

on DOWN#val do 
 // Diminue la consigne - down setpoint
 TaskValueSet 3,1,([CONSIGNE#consigne]-0.5)
 if [CONSIGNE#consigne]<15
 TaskValueSet 3,1,15
 endif
endon

Here, we now have a small diy connected thermostat manufactured at low cost to control the heating from a home automation server. There are still some small improvements to be made. The (+, -) button must be held for at least one second (this is probably because the refresh rate is limited to one second minimum of the dummy device). It would be useful to retrieve the current heating value.

Click to rate this post!
[Total: 1 Average: 4]
Exit mobile version