Home / Community / Blog

If you want to calculate device value you have to fill "Formula" field, ie:

%value%*1

which of course returns value multiplied by 1 ;-).

In my case I had to calculate voltage measured by 1:2 divider and 1:3.3 divider, so my formula was:

%value%/1024*3.3*2

the value is divided by 1024 because ADC has 10 bit resolution.

This is example how to use ESP Easy rules on ESP Witty (ESP8266). It shows timer, events, and assigning value to "variable".

The pins are connected as below:

  • GPIO4 - Push Button
  • GPIO12 - Green LED
  • GPIO13 - Blue LED
  • GPIO15 - Red LED

One device is set to Switch input and it is named button with "1st GPIO" set to GPIO-4. You cannot have variables, but You can have dummy device to store values. So I've created Dummy Device with name zmienna and set "Value Name 2" to indeks. In this example this dummy device is "Task" 3.

How it works?

If you push button the one LED is turn on for 1 second. If you push it again the next LED is turn on.

On button#Switch do
  if [button#Switch]=0.00
    event zgas
    // increment task 3, value 2
    TaskValueSet,3,2,[zmienna#indeks]+1
    event zapal
  endif
endon

// turn on one LED
on zapal do
  timerSet,1,1 // timer 1, one second
  if [zmienna#indeks] > 2
    // reset counter
    TaskValueSet,3,2,0
  endif
  if [zmienna#indeks] = 0
    gpio,12,1 // Green
  endif
  if [zmienna#indeks] = 1
    gpio,13,1 // Blue
  endif
  if [zmienna#indeks] = 2
    gpio,15,1 // Red
  endif
endon

On Rules#Timer=1 do  
  event zgas
endOn

// turn off all LEDs
on zgas do
  gpio,12,0
  gpio,13,0
  gpio,15,0
endon

Just my blog...

Mon Tue Wed Thu Fri Sat Sun
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30