Rules in ESPeasy
Moderators: grovkillen, Stuntteam, TD-er
Re: Rules in ESPeasy
Thank you. for now I'll leave it as it is. I will watch
Re: Rules in ESPeasy
Here is the A to Z of interfacing DS18B20 with ESPEasy: https://espeasy.readthedocs.io/en/lates ... 18b20.html
You can also use DHT22 instead of DS18B20. Here is an ESPeasy based project: https://www.pcbway.com/project/sharepro ... e5a39.html
It features DHT22 and ESP8266.
You can also use DHT22 instead of DS18B20. Here is an ESPeasy based project: https://www.pcbway.com/project/sharepro ... e5a39.html
It features DHT22 and ESP8266.
Re: Rules in ESPeasy
Good afternoon. please see my rules.
it should be like this:
if down#gerkon=1, then GPIO 26 is turned on and with a time delay of 20 minutes, GPIO 12 and GPIO 16 are turned on. then after 420 seconds 12 and 16 turn off. and so on when up#gerkon=1 GPIO 26 turns off and just in case they turn off again 12, 13, 16.
stop#bottom operation is a separate story and no problems have been noticed so far.
but in fact what happens is that when the karat is turned off after 420 seconds, GPIO 26 is also turned off. please tell me why is this happening?
in the log, at the moment when timer 2 should fire, there is a failed fatch
however, this does not always happen. sometimes the rules work as they should
Code: Select all
on Time#Initialized Do
LoopTimerSet_ms,5,1000 //this is just for monitoring
Endon
On Rules#Timer=5 do
TaskValueSet,11,1,[plugin#gpio#pinstate#13] // salt pump rotation speed
TaskValueSet,9,1,[plugin#gpio#pinstate#17] //sound alarm (Buzzer)
Endon
On up#gerkon Do
if %eventvalue1%=1
GPIO,12,0 // osmos
GPIO,26,0 //waterPump
GPIO,16,0 // karat
GPIO,13,0 // pump solt
Endif
Endon
On down#gerkon Do
if %eventvalue1%=1
GPIO,26,1
TimerSet,1,1200 // delay to turn on karat
Endif
Endon
On Rules#Timer=1 do
GPIO,16,1
GPIO,12,1
TimerSet,2,420 // karat duration
LoopTimerSet_ms,4,300
Endon
On Rules#Timer=2 do
GPIO,16,0
GPIO,12,0
GPIO,13,0
TimerSet,4,0
Endon
On Rules#Timer=3 do
If [var#4]=0
PWM,17,500 //sound alarm (Buzzer)
Let,4,1
GPIO,16,0
GPIO,12,0
GPIO,13,0
TimerSet,4,0
Endon
On stop#bottom=1 Do
TimerSet,6,1
Endon
On stop#bottom=11 Do
If [osmos#osmos]=0
GPIO,12,1
Elseif [osmos#osmos]=1
GPIO,13,0
GPIO,16,0
GPIO,12,0
TimerSet,4,0
TimerSet,3,0
Let,2,0
Endif
TimerSet,6,0
Endon
On Rules#Timer=6 Do
If [var#4]=0 And [karat#State]=0 And [osmos#osmos]=0
GPIO,16,1
GPIO,12,1
TimerSet,2,300 // karat duration
LoopTimerSet_ms,4,300
Elseif [var#4]=0 And [karat#State]=1 Or [osmos#osmos]=1
GPIO,13,0
GPIO,16,0
GPIO,12,0
TimerSet,4,0
TimerSet,3,0
Let,2,0
Endif
If [var#4]=1 And [var#2]=1
PWM,17,0
Let,4,0
Let,2,0
Endif
TimerSet,6,0
Endon
On Rules#Timer=4 do //salt pump operating mode
If [garag#analog]< 3100.00 And [plugin#gpio#pinstate#13]<= 1010
Let,1,[plugin#gpio#pinstate#13]+5
PWM,13,[int#1]
Elseif [garag#analog]> 3101.00 And [plugin#gpio#pinstate#13] >= 470
Let,1,[plugin#gpio#pinstate#13]-5
PWM,13,[int#1]
Endif
If [garag#analog]< 2400.00 And [var#2] = 0
TimerSet,3,45
Let,2,1
Elseif [garag#analog]>= 2400.00
TimerSet,3,0
Let,2,0
Endif
Endon
if down#gerkon=1, then GPIO 26 is turned on and with a time delay of 20 minutes, GPIO 12 and GPIO 16 are turned on. then after 420 seconds 12 and 16 turn off. and so on when up#gerkon=1 GPIO 26 turns off and just in case they turn off again 12, 13, 16.
stop#bottom operation is a separate story and no problems have been noticed so far.
but in fact what happens is that when the karat is turned off after 420 seconds, GPIO 26 is also turned off. please tell me why is this happening?
in the log, at the moment when timer 2 should fire, there is a failed fatch
however, this does not always happen. sometimes the rules work as they should
Re: Rules in ESPeasy
Is it possible that the unstable operation of the module is related to the use of gpio 5 and 12?
although there were never any problems loading the module.
now I tried several times to emulate the problem, but the module worked correctly.
although there were never any problems loading the module.
now I tried several times to emulate the problem, but the module worked correctly.
Re: Rules in ESPeasy
GPIO-12 should not be a problem on ESP8266.
GPIO-5 is by default assigned to be part of the I2C pins on ESP8266, but if you set those to use another pin (or no pin when I2C is not needed) then GPIO-5 is one of the most problem-free pins you can use on ESP8266.
See: https://espeasy.readthedocs.io/en/lates ... on-esp8266
For ESP32 it is a completely different story with those specific pins.
Using GPIO12 might even destroy your ESP board as the state of pin 12 during boot determines the voltage applied to the flash chip.
See: https://espeasy.readthedocs.io/en/lates ... e-on-esp32
GPIO-5 is by default assigned to be part of the I2C pins on ESP8266, but if you set those to use another pin (or no pin when I2C is not needed) then GPIO-5 is one of the most problem-free pins you can use on ESP8266.
See: https://espeasy.readthedocs.io/en/lates ... on-esp8266
For ESP32 it is a completely different story with those specific pins.
Using GPIO12 might even destroy your ESP board as the state of pin 12 during boot determines the voltage applied to the flash chip.
See: https://espeasy.readthedocs.io/en/lates ... e-on-esp32
Re: Rules in ESPeasy
I forgot to say that I have exactly ESP32. but there is no problem with booting the module. that is, I turn on the module, it booting and waits for one of the conditions of the rules to come. the module fulfills the initial rules well, for example, when the down#gerkon= 1 or stop#bottom=1. but at the moment when timer 2 should be activated, there are failures and the module disconnects all GPIOs
Re: Rules in ESPeasy
I now see you have a switch input on GPIO-12.
Please do NOT!! use that pin as an input which can be at a specific state during boot of the ESP.
As I said, the state of this pin does determine the voltage of the flash chip.
So either it is pulled high or low by the board or module manufacturer to match the used flash chip.
If the state during boot of the ESP is wrong, either the flash chip will be unstable as it is supplied with a voltage lower than required, or it will be fried as you would apply a voltage which is too high.
GPIO 16 and 17 are a bit tricky also, as on some boards these may be connected to PSRAM, which is on the same SPI bus as the flash.
By toggling those pins you may activate the PSRAM chip and thus interact with the flash chip signals.
So if you have an ESP32 with PSRAM, then please don't use GPIO 16 and 17.
This is also explained in the docs I linked.
Please do NOT!! use that pin as an input which can be at a specific state during boot of the ESP.
As I said, the state of this pin does determine the voltage of the flash chip.
So either it is pulled high or low by the board or module manufacturer to match the used flash chip.
If the state during boot of the ESP is wrong, either the flash chip will be unstable as it is supplied with a voltage lower than required, or it will be fried as you would apply a voltage which is too high.
GPIO 16 and 17 are a bit tricky also, as on some boards these may be connected to PSRAM, which is on the same SPI bus as the flash.
By toggling those pins you may activate the PSRAM chip and thus interact with the flash chip signals.
So if you have an ESP32 with PSRAM, then please don't use GPIO 16 and 17.
This is also explained in the docs I linked.
Re: Rules in ESPeasy
ок. Thank you! I'll try to change 12.16 and 17
Re: Rules in ESPeasy
could it be due to multiple concurrent tasks? Maybe needed to optimize the rules?
Re: Rules in ESPeasy
I didn't remember you mentioning the unit actualy crashed, so I read back to the last thing you mentioned:
Does the unit reboot? Or is it completely unresponsive?
How are things wired to the ESP?
Could it be that at some point there is some much higher voltage at some pin?
Can you draw a schematic of how things are wired?
Also, is the GND of the ESP the same as on the things you connect to it? Is GND always connected (for example are external switches switching the GND or the other end) ?
What do you mean by "disconnects all GPIOs" ?
Does the unit reboot? Or is it completely unresponsive?
How are things wired to the ESP?
Could it be that at some point there is some much higher voltage at some pin?
Can you draw a schematic of how things are wired?
Also, is the GND of the ESP the same as on the things you connect to it? Is GND always connected (for example are external switches switching the GND or the other end) ?
Re: Rules in ESPeasy
good day. that is, switches the state GPIOs 13,19,21 and 26 from 1 to 0, although according to rules GPIO 26 it should be 1. whether the module is reboot or not, I cannot say, since this situation is not permanent. Now I tried several times to reproduce this error, but the module worked as it should. What is the reason for the failure of the module, I can not understand.
Re: Rules in ESPeasy
Are you still using the same rules as you posted on the 30th of April ?
If not, can you post the updated rules, so we can be sure we're looking at the same rules.
Also I have to check online what the FET will do when it is turned on/off.
Maybe the resistor between the GPIO pin and the gate is too low, so the FET may pull the state to GND?
If not, can you post the updated rules, so we can be sure we're looking at the same rules.
Also I have to check online what the FET will do when it is turned on/off.
Maybe the resistor between the GPIO pin and the gate is too low, so the FET may pull the state to GND?
Re: Rules in ESPeasy
The rules are the same, only the GPIOs numbers have changed. but just in case
Code: Select all
on Time#Initialized Do
LoopTimerSet_ms,5,1000
Endon
On Rules#Timer=5 do
TaskValueSet,11,1,[plugin#gpio#pinstate#13]
TaskValueSet,9,1,[plugin#gpio#pinstate#18]
Endon
On up#gerkon Do
if %eventvalue1%=1
GPIO,21,0 // осмос
GPIO,26,0
GPIO,19,0 // карат
GPIO,13,0 // нас соль
TimerSet,4,0
Endif
Endon
On down#gerkon Do
if %eventvalue1%=1
GPIO,26,1
TimerSet,1,1200
Endif
Endon
On Rules#Timer=1 do
GPIO,19,1
GPIO,21,1
TimerSet,2,480 // вр раб карат
LoopTimerSet_ms,4,300
Endon
On Rules#Timer=2 do
GPIO,19,0
GPIO,21,0
GPIO,13,0
TimerSet,4,0
Endon
On Rules#Timer=3 do
If [var#4]=0
PWM,18,500
Let,4,1
GPIO,19,0
GPIO,21,0
GPIO,13,0
TimerSet,4,0
Endon
On stop#bottom=1 Do
TimerSet,6,1
Endon
On stop#bottom=11 Do
If [osmos#osmos]=0
GPIO,21,1
Elseif [osmos#osmos]=1
GPIO,13,0
GPIO,19,0
GPIO,21,0
TimerSet,4,0
TimerSet,3,0
Let,2,0
Endif
TimerSet,6,0
Endon
On Rules#Timer=6 Do
If [var#4]=0 And [karat#State]=0 And [osmos#osmos]=0
GPIO,19,1
GPIO,21,1
TimerSet,2,300 // вр раб карат
LoopTimerSet_ms,4,300
Elseif [var#4]=0 And [karat#State]=1 Or [osmos#osmos]=1
GPIO,13,0
GPIO,19,0
GPIO,21,0
TimerSet,4,0
TimerSet,3,0
Let,2,0
Endif
If [var#4]=1 And [var#2]=1
PWM,18,0
Let,4,0
Let,2,0
Endif
TimerSet,6,0
Endon
On Rules#Timer=4 do
If [garag#analog]< 3100.00 And [plugin#gpio#pinstate#13]<= 1010
Let,1,[plugin#gpio#pinstate#13]+5
PWM,13,[int#1]
Elseif [garag#analog]> 3101.00 And [plugin#gpio#pinstate#13] >= 450
Let,1,[plugin#gpio#pinstate#13]-8
PWM,13,[int#1]
Endif
If [garag#analog]< 2400.00 And [var#2] = 0
TimerSet,3,45
Let,2,1
Elseif [garag#analog]>= 2401.00
TimerSet,3,0
Let,2,0
Endif
Endon
on temp#boiler do
if %eventvalue1% <=67.0
GPIO,32,1
endif
if %eventvalue1% >=68.0
GPIO,32,0
endif
Endon
Don't know. took a typical wiring schematic
Re: Rules in ESPeasy
I see the pins you mentioned are all set to 0 when this event happens:
up#gerkon=1
Is it possible that this pin received some noise which shortly may alter its logic state?
For example long cables, not strong enough pull-up resistor, no small capacitor (100 nF) over the GPIO pin and GND?
up#gerkon=1
Is it possible that this pin received some noise which shortly may alter its logic state?
For example long cables, not strong enough pull-up resistor, no small capacitor (100 nF) over the GPIO pin and GND?
Re: Rules in ESPeasy
It seems to me that this is not connected, since the cable is only 1.5 meters long and the failure occurs exactly at the moment when 19.13 and 21 should turn 0 (at the moment when timer 2 should be activated). that is, if the problem was in the noise (for example, the length of the cable), then the problem would appear at different times.
now I asked the electronics about connecting the mosfet, maybe they will tell something.
Re: Rules in ESPeasy
electronics say that this is possible because of the mosfet, but this is unlikely. All the same, I will change the mosfets to others and I will observe.
Re: Rules in ESPeasy
Good afternoon. there is such a code.
that is, the same action is performed five times a day. Is it possible to somehow optimize the code so that it is shorter?
Code: Select all
on Time#Initialized do
If %systm_hm_0% <= 22:00 And %systm_hm_0% >= 01:00
gpio,33,1
gpio,12,1
else
gpio,33,0
endif
If %systm_hm_0% >= 01:00 And %systm_hm_0% <= 01:25
GPIO,27,1
TimerSet_ms,1,2500
TimerSet,3,60
else
gpio,27,0
endif
If %systm_hm_0% >= 06:00 And %systm_hm_0% <= 06:25
GPIO,27,1
TimerSet_ms,1,2500
TimerSet,3,60
else
gpio,27,0
endif
If %systm_hm_0% >= 11:00 And %systm_hm_0% <= 11:25
GPIO,27,1
TimerSet_ms,1,2500
TimerSet,3,60
else
gpio,27,0
endif
If %systm_hm_0% >= 16:00 And %systm_hm_0% <= 16:25
GPIO,27,1
TimerSet_ms,1,2500
TimerSet,3,60
else
gpio,27,0
endif
If %systm_hm_0% >= 21:00 And %systm_hm_0% <= 21:25
GPIO,27,1
TimerSet_ms,1,2500
TimerSet,3,60
else
gpio,27,0
endif
TimerSet,8,90
LoopTimerSet_ms,9,10000
endon
On Clock#Time=All,22:00 do //выкл. насос
If [boiler#boiler] =1
gpio,33,1
else
gpio,33,0
Endif
endon
On Clock#Time=All,01:00 do // вкл. нас
gpio,33,1
endon
on Clock#Time=All,01:00 do
GPIO,27,1
TimerSet_ms,1,2500
TimerSet,3,60
endon
on Clock#Time=All,01:25 do
GPIO,27,0
TimerSet,4,0
endon
on Clock#Time=All,06:00 do
GPIO,27,1
TimerSet_ms,1,2500
TimerSet,3,60
endon
on Clock#Time=All,06:25 do
GPIO,27,0
TimerSet,4,0
endon
on Clock#Time=All,11:00 do
GPIO,27,1
TimerSet_ms,1,2500
TimerSet,3,60
endon
on Clock#Time=All,11:25 do
GPIO,27,0
TimerSet,4,0
endon
on Clock#Time=All,16:00 do
GPIO,27,1
TimerSet_ms,1,2500
TimerSet,3,60
endon
on Clock#Time=All,16:25 do
GPIO,27,0
TimerSet,4,0
endon
on Clock#Time=All,21:00 do
GPIO,27,1
TimerSet_ms,1,2500
TimerSet,3,60
endon
on Clock#Time=All,21:25 do
GPIO,27,0
TimerSet,4,0
endon
Re: Rules in ESPeasy
You can shorten this in a number of ways.
One way can be to simply use LongPulse for those 25-minute pulses, but then timer 4 will not be cleared.
You don't seem to use this timer, unless this isn't the complete rules set.
Another way can be to use some feature I fixed quite recently.
That is to use variables in the "on Clock#Time=All,01:00 do" line.
This way you only need to set "the next" time in variables.
Another not really generic way, but quite suitable for this timing schema is to simply compare hours and minutes.
For example:
Can also be seen as something like this:
So a large chunk of your Time#Initialized block can be reduced to something like this:
The same can be done for these blocks:
(and all similar other blocks)
into this:
One way can be to simply use LongPulse for those 25-minute pulses, but then timer 4 will not be cleared.
You don't seem to use this timer, unless this isn't the complete rules set.
Another way can be to use some feature I fixed quite recently.
That is to use variables in the "on Clock#Time=All,01:00 do" line.
This way you only need to set "the next" time in variables.
Another not really generic way, but quite suitable for this timing schema is to simply compare hours and minutes.
For example:
Code: Select all
If %systm_hm_0% >= 06:00 And %systm_hm_0% <= 06:25
Code: Select all
if %syshour% = 6 and %sysmin% <= 25
Code: Select all
if (%syshour% = 1 or %syshour% = 6 or %syshour% = 11 or %syshour% = 16 or %syshour% = 21) and %sysmin% <= 25
GPIO,27,1
TimerSet_ms,1,2500
TimerSet,3,60
else
gpio,27,0
endif
Code: Select all
on Clock#Time=All,01:00 do
GPIO,27,1
TimerSet_ms,1,2500
TimerSet,3,60
endon
on Clock#Time=All,01:25 do
GPIO,27,0
TimerSet,4,0
endon
into this:
Code: Select all
on Clock#Time=All,**:00 do
if (%syshour% = 1 or %syshour% = 6 or %syshour% = 11 or %syshour% = 16 or %syshour% = 21)
GPIO,27,1
TimerSet_ms,1,2500
TimerSet,3,60
endif
endon
on Clock#Time=All,**:25 do
if (%syshour% = 1 or %syshour% = 6 or %syshour% = 11 or %syshour% = 16 or %syshour% = 21)
GPIO,27,0
TimerSet,4,0
endif
endon
Re: Rules in ESPeasy
THANKS FOR THE HELP
almost 1000 characters shorter
and if I want to do this action 6 times a day, can I add one more hour? What is the data limit?
for example is it possible?
Code: Select all
if (%syshour% = 1 or %syshour% = 6 or %syshour% = 11 or %syshour% = 16 or %syshour% = 21 or %syshour% = 23) and %sysmin% <= 25
GPIO,27,1
TimerSet_ms,1,2500
TimerSet,3,60
else
gpio,27,0
endif
Re: Rules in ESPeasy
Not sure what is the limit, if there is one.
But you can easily split it into if...elseif...else...endif
See: https://espeasy.readthedocs.io/en/lates ... lseif-else
Keep in mind that nesting if's is essentially the same as an "AND".
Is the same as:
Thus you can wrap it all in a single check for "if %sysmin%<=25"
For readablility you may need to write the "gpio,27,0" twice then, but you'll find out if it comes to splitting the OR's
But you can easily split it into if...elseif...else...endif
See: https://espeasy.readthedocs.io/en/lates ... lseif-else
Keep in mind that nesting if's is essentially the same as an "AND".
Code: Select all
if A=0 and B=0
...
endif
Code: Select all
if A=0
if B=0
...
endif
endif
For readablility you may need to write the "gpio,27,0" twice then, but you'll find out if it comes to splitting the OR's
Re: Rules in ESPeasy
Good afternoon . maybe it will be useful and interesting for someone.
here I asked a question about the work of the rules and could not understand why they do not work
it was all about writing the rules, more precisely the use of spaces and = and>/<
it was
this is how it became
everything works now
and of course removed GPIOs 12, 5 from work
here I asked a question about the work of the rules and could not understand why they do not work
it was all about writing the rules, more precisely the use of spaces and = and>/<
it was
Code: Select all
On Rules#Timer=4 do //salt pump operating mode
If [garag#analog]< 3100.00 And [plugin#gpio#pinstate#13]<= 1010
Let,1,[plugin#gpio#pinstate#13]+5
PWM,13,[int#1]
Elseif [garag#analog]> 3101.00 And [plugin#gpio#pinstate#13] >= 470
Let,1,[plugin#gpio#pinstate#13]-5
PWM,13,[int#1]
Endif
If [garag#analog]< 2400.00 And [var#2] = 0
TimerSet,3,45
Let,2,1
Elseif [garag#analog]>= 2400.00
TimerSet,3,0
Let,2,0
Endif
Endon
Code: Select all
On Rules#Timer=4 Do
If [garag#analog] <=3200.00 And [plugin#gpio#pinstate#13] <=1010
Let,1,[plugin#gpio#pinstate#13]+5
PWM,13,[int#1]
Elseif [garag#analog] >= 3201.00 And [plugin#gpio#pinstate#13] >=350
Let,1,[plugin#gpio#pinstate#13]-9
PWM,13,[int#1]
Endif
If [garag#analog] <=2400.00 And [var#2] =0
TimerSet,3,45
Let,2,1
Elseif [garag#analog] >=2401.00
TimerSet,3,0
Let,2,0
Endif
Endon
and of course removed GPIOs 12, 5 from work
Re: Rules in ESPeasy
Good afternoon. Is there a difference in coding between the two rules?
Code: Select all
on Clock#Time=All,**:** do
if [int#9] = 0
if %sysmin% >= 01
asyncevent,startDisinfection
endif
endif
endon
Code: Select all
on Clock#Time=All,**:** do
if [int#9] = 0 AND %sysmin% >= 01
asyncevent,startDisinfection
endif
endon
Re: Rules in ESPeasy
There should not be a difference.
However when comparing numericals like "> 01" in your rules, it is best not to have a leading zero.
The number parsing in ESPEasy is done using a more elaborate function which will not consider octal numbering.
But I'm not 100% sure all compares use this function, so there might be some piece of code which can consider a leading 0 as an octal number.
For "01" this does not make any difference, but for values > 7 it might yield strange results.
However when comparing numericals like "> 01" in your rules, it is best not to have a leading zero.
The number parsing in ESPEasy is done using a more elaborate function which will not consider octal numbering.
But I'm not 100% sure all compares use this function, so there might be some piece of code which can consider a leading 0 as an octal number.
For "01" this does not make any difference, but for values > 7 it might yield strange results.
Re: Rules in ESPeasy
thank youTD-er wrote: ↑28 Jul 2023, 10:52 There should not be a difference.
However when comparing numericals like "> 01" in your rules, it is best not to have a leading zero.
The number parsing in ESPEasy is done using a more elaborate function which will not consider octal numbering.
But I'm not 100% sure all compares use this function, so there might be some piece of code which can consider a leading 0 as an octal number.
For "01" this does not make any difference, but for values > 7 it might yield strange results.
Re: Rules in ESPeasy
Good afternoon. I'm trying to change the speed of an AC motor to 220 volts. I connect via a triac according to this scheme and the motor rotates at maximum speed. that is, the rotation speed is always maximum, regardless of the PWM value. at least like that PWM,27,1. at least like that PWM,27,1000.
if the PWM,27,0. then the motor does not rotate
please tell me what could be the problem
I'm writing a simple rule Code: Select all
On bot#State=1 Do
PWM,27,1
Endon
if the PWM,27,0. then the motor does not rotate
please tell me what could be the problem
Re: Rules in ESPeasy
Typically a triac only opens at the zero-crossing of the AC voltage.
So you may have to alter the PWM frequency.
However, I don't know whether the PWM pulse should also be somehow synced with the mains frequency as it may otherwise cause unpredictable behavior.
I really doubt this will work well and I don't know what would be a good PWM frequency for this.
Seems like you have taken the schematic from this site:
https://circuitdigest.com/microcontroll ... -and-triac
Here they also suggest to sample the AC frequency.
And ESPEasy is probably not fast enough to respond to this using rules.
One other thing to realize...
They do have the mains voltage parts on separate prints, but they have drawn it as if it were mounted to a breadboard.
Don't ever use a breadboard for mains voltage.
Also the experimental board they used isn't really suited for mains voltage without taking special care of removing copper.
Each hole of such a board does have a copper 'island', each with a distance of less than 3 mm from eachother.
This allows for sparks when switching mains voltage.
So you may have to alter the PWM frequency.
However, I don't know whether the PWM pulse should also be somehow synced with the mains frequency as it may otherwise cause unpredictable behavior.
I really doubt this will work well and I don't know what would be a good PWM frequency for this.
Seems like you have taken the schematic from this site:
https://circuitdigest.com/microcontroll ... -and-triac
Here they also suggest to sample the AC frequency.
And ESPEasy is probably not fast enough to respond to this using rules.
One other thing to realize...
They do have the mains voltage parts on separate prints, but they have drawn it as if it were mounted to a breadboard.
Don't ever use a breadboard for mains voltage.
Also the experimental board they used isn't really suited for mains voltage without taking special care of removing copper.
Each hole of such a board does have a copper 'island', each with a distance of less than 3 mm from eachother.
This allows for sparks when switching mains voltage.
Re: Rules in ESPeasy
that is, I won’t be able to change the rotation speed?
What options are there to solve my problem?
The diagram was taken from the Internet, I had a ready-made board, but it was similar to the one I showed. there was a processor MEGA (I don’t remember the number). I decided to remove it and put ESP32 in its place
Re: Rules in ESPeasy
Those ATmega microprocessors don't do anything else.
So their loop() call is really simple and something like this:
- Read potentiometer value + compute delay
- Wait for zero-crossing
- pull pin high
- Wait for computed 'delay' number of msec
- pull pin low.
Since that's all they need to do, I would wire up that microcontroller again and just try to 'emulate' the potentiometer.
That's just a DC analog value, which can be easily generated via ESPEasy.
Either via one of the ESP32 DAC pins, or send a PWM signal and add some resistor + capacitor to make the value more stable.
So their loop() call is really simple and something like this:
- Read potentiometer value + compute delay
- Wait for zero-crossing
- pull pin high
- Wait for computed 'delay' number of msec
- pull pin low.
Since that's all they need to do, I would wire up that microcontroller again and just try to 'emulate' the potentiometer.
That's just a DC analog value, which can be easily generated via ESPEasy.
Either via one of the ESP32 DAC pins, or send a PWM signal and add some resistor + capacitor to make the value more stable.
Re: Rules in ESPeasy
This is a sliding gate drive. It's fully functional, but I wanted to control the gate via the Internet. Therefore, I decided to change the standard microprocessor to ESP32. It is necessary to regulate the rotation speed of the motor so that the gate does not hit the gate trap. that is, the speed must be reduced before stopping.
Re: Rules in ESPeasy
Since the ESP32 is doing so much more, it is not the best choice for truly real-time tasks.
It is best to have a small microcontroller responsible for the really tight loop you need to control the motor speed.
This leaves only a slowly changing input option which can be controlled by the ESP.
It is best to have a small microcontroller responsible for the really tight loop you need to control the motor speed.
This leaves only a slowly changing input option which can be controlled by the ESP.
Re: Rules in ESPeasy
please tell me how to remove the potentiometer in this circuit and put ESP32 in its place all that comes to my mind is to install an optocoupler instead of a potentiometer, and apply a PWM signal to the optocoupler input. but not sure if it will work
Re: Rules in ESPeasy
To control it purely digital, you need to detect the zero crossing.
But maybe you can exchange the potentiometer with some LDR and add a PWM controlled LED in front of the LDR and put it in a black tube to keep out other light?
Got the idea of using an LDR via Google image search which led me here: https://www.eleccircuit.com/ac-lights-dimmer-circuit/
Section "The automatic Daylight dimmer circuit"
Maybe you need some small capacitor across the LDR if it may change too quickly.
I have no idea how fast an LDR may respond to light changes, but PWM is pulsating light.
Or just put a small capacitor over the LED.
Edit:
Found an even better blog post describing what you want to achieve.
http://jespereklund.blogspot.com/2012/1 ... duino.html
But maybe whenever you have questions like these, it is better to open a new topic next time.
As this doesn't have much to do with ESPEasy rules.
Edit2:
Here some more info on LDRs: http://lednique.com/opto-isolators-2/li ... 20darkness.
But maybe you can exchange the potentiometer with some LDR and add a PWM controlled LED in front of the LDR and put it in a black tube to keep out other light?
Got the idea of using an LDR via Google image search which led me here: https://www.eleccircuit.com/ac-lights-dimmer-circuit/
Section "The automatic Daylight dimmer circuit"
Maybe you need some small capacitor across the LDR if it may change too quickly.
I have no idea how fast an LDR may respond to light changes, but PWM is pulsating light.
Or just put a small capacitor over the LED.
Edit:
Found an even better blog post describing what you want to achieve.
http://jespereklund.blogspot.com/2012/1 ... duino.html
But maybe whenever you have questions like these, it is better to open a new topic next time.
As this doesn't have much to do with ESPEasy rules.
Edit2:
Here some more info on LDRs: http://lednique.com/opto-isolators-2/li ... 20darkness.
Re: Rules in ESPeasy
I also thought about LDR when I wrote the previous question. Thank you. And I apologize for the off-topic questions.
Maybe it's worth creating a topic about one-time questions
Maybe it's worth creating a topic about one-time questions
Re: Rules in ESPeasy
Good afternoon. I have sliding gates. I need the gate to start moving smoothly and end moving smoothly.there is a pulse counter on the motor. and everything is fine when the gate moves from start to finish, that is, the gate starts moving smoothly and slows down before stopping.but if you stop the gate manually and start moving again, the gate will move in the other direction, and the pulse counter will continue to count pulses and there will be no reduction in speed before stopping.
that is, with each increase in datchik#Total need to subtract odd numbers from the datchik#Total.
please tell me how to teach the gate to stop smoothly in the extreme position from any initial position
Code: Select all
On Rules#Timer=1 Do
If [datchik#Total] <=4999 And [plugin#gpio#pinstate#19] <=900
Let,3,[plugin#gpio#pinstate#19]+50
PWM,19,[int#3]
Elseif [datchik#Total] >=5000 And [plugin#gpio#pinstate#19] >=150
Let,3,[plugin#gpio#pinstate#19]-15
PWM,19,[int#3]
Endif
Endon
please tell me how to teach the gate to stop smoothly in the extreme position from any initial position
Re: Rules in ESPeasy
did it differently
Code: Select all
On Rules#Timer=1 Do
If [datchik#Total]<=4999 And [plugin#gpio#pinstate#19]<=900
Let,3,[plugin#gpio#pinstate#19]+50
PWM,19,[int#3]
Elseif [datchik#Total]>=5000 And [plugin#gpio#pinstate#19]>=100 And [var#4]=0
Let,3,[plugin#gpio#pinstate#19]-25
PWM,19,[int#3]
Elseif [datchik#Total]>=[var#4]-1500 And [plugin#gpio#pinstate#19]>=100 And [var#4]<>0
Let,3,[plugin#gpio#pinstate#19]-25
PWM,19,[int#3]
Endif
Endon
On Rules#Timer=4 Do
Let,4,[datchik#Total]*2
TaskValueSet,6,1,[var#4]
Endon
Re: Rules in ESPeasy
Not sure if this will work:
Just to be sure, you could change it to this:
Code: Select all
Elseif [datchik#Total]>=[var#4]-1500
Code: Select all
On Rules#Timer=1 Do
If [datchik#Total]<=4999 And [plugin#gpio#pinstate#19]<=900
Let,3,[plugin#gpio#pinstate#19]+50
PWM,19,[int#3]
Elseif [datchik#Total]>=5000 And [plugin#gpio#pinstate#19]>=100 And [var#4]=0
Let,3,[plugin#gpio#pinstate#19]-25
PWM,19,[int#3]
Elseif [plugin#gpio#pinstate#19]>=100 And [var#4]<>0
let,3,[var#4]-1500
if [datchik#Total]>=[var#3]
Let,3,[plugin#gpio#pinstate#19]-25
PWM,19,[int#3]
Endif
Endif
Endon
Re: Rules in ESPeasy
my version also works, but yours is probably more reliable. Thank you
Who is online
Users browsing this forum: No registered users and 1 guest