[noob question] esp8266 rules + analog read mq-2 senor

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
pdrobek
New user
Posts: 2
Joined: 27 Dec 2018, 21:33

[noob question] esp8266 rules + analog read mq-2 senor

#1 Post by pdrobek » 27 Dec 2018, 21:46

Hi folks

Near 4 days ago i switched to espeasy from my own firmware for wemos d1 mini pro(esp8266).I read whole wiki page for rules which could be set on espeasy and still something work wrong in my opinion.

Please see where i am doing wrong things

I create device Analog input internal named it mq2 with values named value. In short mq2#value

I also create rule(s) to switch on/off relay connected to GPIO5

Code: Select all

on [mq2]#value>75 do
gpio,5,1
endon
on [mq2]#value<=75 do
gpio,5,0
endon
In log i see

Code: Select all

1125701: ADC : Analog value: 63
1125704: EVENT: mq2#value=63.00
1125721: Domoticz: Sensortype: 1 idx: 64 values: 63
....
As far i observe my relay it wont switch on even if mq2#value is greater than 100

Please tell how to create rule to frequently check for analog value and power on/off relay

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: [noob question] esp8266 rules + analog read mq-2 senor

#2 Post by dynamicdave » 27 Dec 2018, 22:11

You could try this piece of code.
It checks the value of mq2 every 2 seconds (adjust the timing to suit your needs).

Code: Select all

On System#Boot do
  GPIO,5,0
  timerSet,1,2  //Set timer1 for 2 seconds (adjust the timing to suit your needs)
endon

on Rules#Timer=1 do    //This is executed when timer1 runs out
  if [mq2#value]>75
    GPIO,5,1
  else
    GPIO,5,0
  endif
  timerSet,1,2  // set timer1 for another 2 seconds
endon
Last edited by dynamicdave on 28 Dec 2018, 09:39, edited 1 time in total.

pdrobek
New user
Posts: 2
Joined: 27 Dec 2018, 21:33

[Solved][noob question] esp8266 rules + analog read mq-2 senor

#3 Post by pdrobek » 27 Dec 2018, 22:26

It works!

So i have to read another wiki for timers :-)

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: [noob question] esp8266 rules + analog read mq-2 senor

#4 Post by dynamicdave » 28 Dec 2018, 10:25

Glad to help.

Cheers from david

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 24 guests