ESP12, rules question

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Tjeerd
Normal user
Posts: 16
Joined: 06 Jun 2016, 11:54

ESP12, rules question

#1 Post by Tjeerd » 28 Jul 2016, 00:03

Hello Evryone.

I have a question about the usage of the rules. i dont seem to get it (or atleast i do not get it to work.)

I have a ESP12, and i want to use it to turm on the lights by using it in domotics whit a releas.
I have it working that when i send a command to GPIO2 that a led is gooing on (or the releas but for the testing im using a led instead)
Further i want to be able to use a manual switch to power on the light. The idea is that i switch a GPIO pin on the ESP who then whit a rule switches GPIO2.

I made the following setup:

esp -> gpio 2 -> led -> ground when using the command the led is turning on.(http://192.168.178.21/control?cmd=GPIO,2,1)

esp -> gpio14 -> pushswitch ->ground. when i push the botten nothing seems to happend (do i miss a pulup/puldown resistor?) i configured the following: mode: switch input; Name: Schakelaar; GPIO14; Button type: push button active low

In the rules tab i set the following:

Code: Select all

if gpio,14,0 do
 gpio,2,1
else
 gpio,2,0
endif

The end goal is that the rule checks if the light is off, if the light is off then enable gpio2, if the light is on, then disable gpio2

i think it should be something like this, but i do not get it working:

Code: Select all

on gpio,14,0 do
if gpio,2,0
gpio,2,1
else
gpio,2,0
endif
endon 
Is anyone able to help me in to the right direction?

andy
Normal user
Posts: 65
Joined: 26 Jan 2016, 23:07

Re: ESP12, rules question

#2 Post by andy » 28 Jul 2016, 00:12

Look thru http://www.esp8266.nu/forum/viewtopic.php?f=4&t=1431. Let us know if this helps.

Tjeerd
Normal user
Posts: 16
Joined: 06 Jun 2016, 11:54

Re: ESP12, rules question

#3 Post by Tjeerd » 28 Jul 2016, 00:18

Thanks i will read it, i dint found it when i was searching for a similar issue

edit
i read the topic and i adjusted my rule to :

Code: Select all

on schakelaar#Switch=0 do
 gpio,2,1
else
 gpio,2,0
endif
endon
But stil it doesnt seem to work. do you have a clou of what im doing wrong?

I think that something is gooing wrong whit the imput switch. any toughts about that?

edit 2
I was reading in http://www.esp8266.nu/forum/viewtopic.php?f=6&t=1421, i basicly had the same questions and i learned that the correct syntax for the rule can be found in de logging (when something works for example my led)

I nothist that the rule partly works
when the led is on and i set gpio,14,0 the led will go off.

so for now i think i need to fix the switch first and then i will dive deeper in the rules section.

So the question for now is what im dooing wrong whit the switch. anyone any ideas about the flaw in my setup?

Tjeerd
Normal user
Posts: 16
Joined: 06 Jun 2016, 11:54

Re: ESP12, rules question

#4 Post by Tjeerd » 29 Jul 2016, 19:01

i have fixed the rules

when i use the following it seems that it does the trick.

Code: Select all

on schakelaar#Switch=1.00 do
if [led#Switch]=1
gpio,2,0
else
gpio,2,1
endif
endon
on schakelaar#Switch=0.00 do
if [led#Switch]=0
gpio,2,1
else
gpio,2,0
endif
endon
Only im completly stock on the switch thingy

could anyone help me out whit it?

The idea is that i use a normal switch (or a push botten to switch[schakelaar#Switch] (GPIO 14)
I have tryed all the settings in the devices tab

GPIO14 is connected to a push botten what is conencted to ground.
im using the valeus Pull up, and normal switch (and i have selected send boot state end send data) in the hardware tab i have set pin 14 to input.

i have tryed whitout the pull up, inversed, button type active low, active high but it wont work, so if anyone have an idea, please let me know

EDIT

I have found http://www.esp8266.nu/forum/viewtopic.php?t=437, but the strange thing is that it doenst work even i have set it up as BackBone mentioned

dduley
Normal user
Posts: 93
Joined: 06 Feb 2016, 17:56

Re: ESP12, rules question

#5 Post by dduley » 29 Jul 2016, 20:46

What is the message delay set to under Tools/Advanced? This should be about 1000. Any longer and the buttons won't be responsive. Also make sure the delay is set to 0 under your switch device task, finally make sure the Sensor delay is set to 1 under Config.

I use push buttons all over my house to activate lights. My rules are very simple:
On Garage#Garagesw=1 do
gpio,15,1
endon

On Garage#Garagesw=0 do
gpio,15,0
endon

Make sure your Switch task is named. Make sure your switch value is named. Make sure you have some value in the IDX variable. This can be any number. I use 1...2...3... etc.

Good Luck

Dave

Tjeerd
Normal user
Posts: 16
Joined: 06 Jun 2016, 11:54

Re: ESP12, rules question

#6 Post by Tjeerd » 29 Jul 2016, 22:05

Hello Dave,

Thanks again for answering on one of my questions,

I have checked the values you gave me, and it looks like you said.

Imageupload
Imageimage hosting 10mb limit

I will try if it works whit a small rule like you created, but im worring that it is the solution.

could i have made a mistake in the wireing?

edit


I changed the rules but this dint make any differance

Code: Select all

on schakelaar#Switch=1 do
gpio,2,1
endon

on schakelaar#Switch=0 do
gpio,2,
endon 
Regards,

Tjeerd

dduley
Normal user
Posts: 93
Joined: 06 Feb 2016, 17:56

Re: ESP12, rules question

#7 Post by dduley » 29 Jul 2016, 22:31

Hi Tjeerd,

Try one more thing. Give your second switch event an IDX number as well. Make it different than the first one.

Dave

Tjeerd
Normal user
Posts: 16
Joined: 06 Jun 2016, 11:54

Re: ESP12, rules question

#8 Post by Tjeerd » 29 Jul 2016, 22:44

Thanks, i will try that !

Tjeerd
Normal user
Posts: 16
Joined: 06 Jun 2016, 11:54

Re: ESP12, rules question

#9 Post by Tjeerd » 29 Jul 2016, 23:31

Still nothing.

Do i need to use a specail GPIO port for the incomming data?

the wireing is form gpio 14 to a push swhitch en then to ground.

i would acpect that hardwireing the gpio to ground would also give a reaction but this also doenst do any thing.*

Im placing the wire in de breadboard from the switch to ground

dduley
Normal user
Posts: 93
Joined: 06 Feb 2016, 17:56

Re: ESP12, rules question

#10 Post by dduley » 30 Jul 2016, 00:07

Tjeerd wrote:Still nothing.

Do i need to use a specail GPIO port for the incomming data?

the wireing is form gpio 14 to a push swhitch en then to ground.

i would acpect that hardwireing the gpio to ground would also give a reaction but this also doenst do any thing.*

Im placing the wire in de breadboard from the switch to ground
Hi Tjeerd,

GPIO 14 should be OK. I have used that port for exactly the same thing. Do you see the state change when you refresh the Devices Screen and press the button? I also would try an external "real" 10K resistor as your pullup. I noticed in your screen shot that the switch state is 1. Also you have checked pullup and inversed check-boxes. If your button is connected to GND , and the internal pullup is working, and you have the input set to inverse, (Its getting complicated!) then I would expect to see a 0 when the button is not pressed but we see a 1 on the screenshot. Do you follow me on this windy trip down the rabbit hole?
Try an external resistor pulling GPIO 14 up to +3.3.
Un check the internal pullup and uncheck the inversed box. (Its always best to simplify the problem before complicating things with inversion etc.)
With no button pressed you should then see a 1 and with the button pressed you should see a 0 (No pressed you have a 1 from the resistor and pressed you have the port pulled low through the switch). You will have to hit the browser refresh every few seconds to see the change on the /devices page.
If you can get the value to change from 1 to 0 and back again then the hardware is working. Then you can go play with rules! :D

Good luck

Dave

Tjeerd
Normal user
Posts: 16
Joined: 06 Jun 2016, 11:54

Re: ESP12, rules question

#11 Post by Tjeerd » 30 Jul 2016, 10:52

Hello Dave,

Thanks for the good pointers,

I will try to use a pull up resitor and "simplify" the whole.

I do not see the changes in de log or in de devices when i push the botten, i think thats where the problem starts?

Regards,

Tjeerd

Tjeerd
Normal user
Posts: 16
Joined: 06 Jun 2016, 11:54

Re: ESP12, rules question

#12 Post by Tjeerd » 30 Jul 2016, 12:38

a strange thing is happening...

the solution as you descriped dint work..

But in the light of hte resitor i was playing some around whit the settings and the resitor.

The strange thing now is the following:

When i have the following:
gpio14 -> 10K -> ground light is off
vgpio14 -> 10K -> floating light is gooing on untill i let off the resitor
gpio14 -> 10K -> 3.3v the kight is on.

Only now the interesting part.
When i connect the resitor by a cable to ground or 3.3v i do not see any changes.


For now i do not have any time to test it any more today. hopefully this evening and alse tomorrow in the afthernoon.

hamster
Normal user
Posts: 62
Joined: 27 Sep 2015, 21:01
Location: UK

Re: ESP12, rules question

#13 Post by hamster » 30 Jul 2016, 23:54

I have an esp12 with switched input on GPIO14

I have the pull up enabled also inversed is disabled
I have a switch connected to earth which is normally closed, when the switch goes open the pull up gives me a '1'
no resister needed. This setup has been working flawlessly for many months.

Also i did notice you are using GPIO2 as an output to an LED, but you also show GPIO2 as a switch input? you might need to remove this input

Tjeerd
Normal user
Posts: 16
Joined: 06 Jun 2016, 11:54

Re: ESP12, rules question

#14 Post by Tjeerd » 31 Jul 2016, 18:03

Hello Hamster,

You gave the solution!, now when i push the button i see the light gooing off.

i made the switch input becouse i want to switch a relaid with the gpio2, and the manual voor domotics discriped that i needed to make a switch input for that.

i will test this further, for now thank you very much and Dave also a lot apperiation for you time, it took me alot futher in the way of ESP`s

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: ESP12, rules question

#15 Post by tozett » 31 Jul 2016, 19:49

please, if you may be so kind, and mark first postings headline as "SOLVED ..."?

Tjeerd
Normal user
Posts: 16
Joined: 06 Jun 2016, 11:54

Re: ESP12, rules question

#16 Post by Tjeerd » 31 Jul 2016, 19:56

Hello Tozett,

i haved have it all working yet. All the loss parts work (the Rules work when the button doesnt and vica versa.

WHen i have solved this i will set the treath on solved so someone else can learn from these experiance.

The work in progress now is that i lose my led#Switch when i delete the switchport for the led. so my rule who checks if the led is 1 doesnt do it job.
Secondly, when i peer the IDX valeu whit domotics the button doest work anymore.

Post Reply

Who is online

Users browsing this forum: No registered users and 60 guests