ESP Easy (Rules): setpoint for connected thermostat (Jeedom, 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 (Jeedom, Domoticz …) or a project Node-RED or Javascript. 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 Wemos D1 mini ESP8266 ESP-12 module. For example Wemos D1 Mini
mini switch x3 mini switch
Broches DHT22 Temperature sensor (optional)

DHT11 or DHT22

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

SSD1306

jumper dupont Jumper Dupont
breadboard 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.

iot thermostat ESP EASY

Configuring ESP Easy Devices

We will create 4 Devices:

  • UP: associated with push button increase
  • DOWN: associated with push button decrease
  • NOTE: a Dummy device that will contain the value of the setpoint
  • OLED: a display allowing to see the value of the setpoint with each change.

Here is the configuration completed.

https://www.projetsdiy.fr/wp-content/uploads/2017/01/5-esp-easy-consigne-setpoint-configuration-finale.png

Increase button (Switch Input, UP)

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

  • Name: UP
  • Delay: no need to allocate a delay, let ESP Easy handle detection
  • IDX: 1 (or another number but different from 0)
  • GPIO: the number of the spindle on which the button is connected, here D4 (GPIO2)
  • Check Pull UP and Inversed
  • Type: Switch
  • Switch button Type: here we use a pushbutton, we want to increment the setpoint when we press it, so choose Push Button Active Low
  • Uncheck Send data to avoid unnecessarily publishing each press on the pushbutton
  • Value name: val (or another name)
  • Register with submit

esp easy consigne setpoint bouton up augmenter

Down Button (Switch Input, DOWN)

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

  • Name: DOWN
  • Delay: 0
  • IDX: 2 (or another number but different from 0)
  • GPIO: the number of the spindle on which the button is connected, here D3 (GPIO0)
  • Check Pull UP and Inversed
  • Type: Switch
  • Switch button Type: idem, Push Button Active Low
  • Uncheck Send data
  • Value name: val
  • Register with submit

esp easy consigne setpoint bouton down diminuer

Setpoint (Dummy Device, SENSOR_TYPE_SINGLE)

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

  • Name: SETUP (in uppercase)
  • Delay: 1 second, you probably want the home automation software to quickly know the value of the new setpoint
  • IDX: 3
  • Simulate Data Type: choose SENSOR_TYPE_SINGLE
  • Value name: consigne (lowercase)
  • Check Send Data
  • Decimal: Choose the number of decimal places for the setpoint. Here 1 decimal place.
  • Register with submit

espeasy consigne setpoint dummy device sensor_single_type

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:

  • Name: OLED for example
  • Delay: display refresh time, 1 second
  • Setpoint: To display the value of the setpoint on a line, the value of the variable is retrieved as follows [SETPOINT # setpoint]
  • Display button: the screen display can be called up using the button. Here it is connected to pin D5 (GPIO14). The display will remain displayed for 30 seconds.
  • Register with submit

esp easy consigne setpoint affichage diplay oled ssd1306

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).
esp easy activer rules

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>

  • task nr : number of the Device (recovered in the Devices table, column Task)
  • taskvalue nr : index of the variable (1 to 4) the Dummy Device
  • value or formula : value assigned to the variable, or calculation.
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

esp easy setpoint consigne boutons

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.

    Subscribe to the weekly newsletter

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

    Tags:

    1 Comment
    1. well done!
      maybe you have arduino sketch?

    Leave a Reply

    DIY Projects