command LongPulse: possible to pulse between state 0 and state 2?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
midrag
Normal user
Posts: 6
Joined: 16 May 2020, 09:17

command LongPulse: possible to pulse between state 0 and state 2?

#1 Post by midrag » 16 May 2020, 09:24

hey,

i am trying to use a 16-relay board with Easyesp Version mega-20200426.
I can turn on the relay by using the gpio command (http://<espeasyip>/control?cmd=GPIO,12,0). the specific relay card won't turn off with setting the GPIO to high (http://<espeasyip>/control?cmd=GPIO,12,1) but with setting the GPIO to High-Z (http://<espeasyip>/control?cmd=GPIO,12,2).
Now i want to use the LongPulse command (http://<espeasyip>/control?cmd=LongPulse,12,0,600). the relay won't turn off.
Here is my question:
- Can the LongPulse command be configured to pulse between state 0 and state 2?

best regards,
midrag

User avatar
Ath
Normal user
Posts: 84
Joined: 10 Jun 2018, 12:06
Location: NL

Re: command LongPulse: possible to pulse between state 0 and state 2?

#2 Post by Ath » 16 May 2020, 10:10

Have you tried adding a pull-up resistor (10k should do fine) to that output pin?

What board are you using?

midrag
Normal user
Posts: 6
Joined: 16 May 2020, 09:17

Re: command LongPulse: possible to pulse between state 0 and state 2?

#3 Post by midrag » 16 May 2020, 17:32

yes, i've tried 10kOhm and 83kOhm. It didn't help.

I'm using an ESP32 devkitc_v4 and this relay-card:
https://cdn.shopify.com/s/files/1/1509/ ... .pdf?53659

Link to ESP32 devkit: https://docs.espressif.com/projects/esp ... vkitc.html

midrag
Normal user
Posts: 6
Joined: 16 May 2020, 09:17

Re: command LongPulse: possible to pulse between state 0 and state 2?

#4 Post by midrag » 16 May 2020, 17:59

I've made a little workaround using the rules function.

Code: Select all

On LongPulseGPIO12 do 
  gpio,12,0 //turn relay on GPIO12 on
  timerSet,1,%eventvalue% //timer 1 set for eventvalue
endon
 
On Rules#Timer=1 do  
  gpio,12,2 //turn relay on GPIO12 off
endOn
it works (http://<espeasyip>/control?cmd=event,LongPulseGPIO12=600) but it is limited to 8 GPIOs. It would be nice to be able to configure the LongPulse-function.

User avatar
Ath
Normal user
Posts: 84
Joined: 10 Jun 2018, 12:06
Location: NL

Re: command LongPulse: possible to pulse between state 0 and state 2?

#5 Post by Ath » 16 May 2020, 19:38

Do you have a ESP8266 board available to check if that is able to 'longpulse' the relay? I'm a bit puzzled that your ESP32 isn't able to perform such basic functionality, so I suspect there is some incompatibility with that reley board. It could be related to the 5V supplied to the optocouplers, and the ESP high output being 3.3V. That may not be high enough to flip it back off.

midrag
Normal user
Posts: 6
Joined: 16 May 2020, 09:17

Re: command LongPulse: possible to pulse between state 0 and state 2?

#6 Post by midrag » 16 May 2020, 19:47

I'll check if i find some 8266 module.

User avatar
Ath
Normal user
Posts: 84
Joined: 10 Jun 2018, 12:06
Location: NL

Re: command LongPulse: possible to pulse between state 0 and state 2?

#7 Post by Ath » 16 May 2020, 20:03

I was going to try an ESP32 with a relayboard, but the optocouplers on mine are all powered with 3.3V, so no easy way to replay your situation.

User avatar
Ath
Normal user
Posts: 84
Joined: 10 Jun 2018, 12:06
Location: NL

Re: command LongPulse: possible to pulse between state 0 and state 2?

#8 Post by Ath » 16 May 2020, 20:19

I thought of an alternative to your rules to extend to 16:
(Because of the rather large number of script lines, the 1 second timer delay may be a bit extended, maybe subtract a few percent when using larger numbers like > 100?)
NB: Untested code!

Code: Select all

on LongpulseGPIO do // usage: event,LongpulseGPIO,<gpio>,<seconds>
  if %eventvalue1% > 0 and %eventvalue2% > 0
    let,%eventvalue1%,%eventvalue2%
    gpio,%eventvalue1%,0  // Turn relay on
  endif
endon

on Rules#Timer=1 do
  if %v1% > 0
    let,1,%v1%-1 // Decrement counter
    if %v1% = 0  // Time to turn it off?
      gpio,1,2 // Set to high-z == Relay off
    endif
  endif
  if %v2% > 0
    let,2,%v2%-1
    if %v2% = 0
      gpio,2,2
    endif
  endif
  // repeat for 3..16
  TimerSet,1,1 // Repeat
endon

on System#Boot do
  TimerSet,1,1 // Start timer-loop
endon

midrag
Normal user
Posts: 6
Joined: 16 May 2020, 09:17

Re: command LongPulse: possible to pulse between state 0 and state 2?

#9 Post by midrag » 02 Jun 2020, 16:26

Ath wrote:
16 May 2020, 19:38
Do you have a ESP8266 board available to check if that is able to 'longpulse' the relay? I'm a bit puzzled that your ESP32 isn't able to perform such basic functionality, so I suspect there is some incompatibility with that reley board. It could be related to the 5V supplied to the optocouplers, and the ESP high output being 3.3V. That may not be high enough to flip it back off.
i've got an old wemos d1 r1 board with an esp8266 from a friend. With the newest Release (Release mega-20200515) the LongPulse command doesn't work either. Is my relay board so special?

midrag
Normal user
Posts: 6
Joined: 16 May 2020, 09:17

Re: command LongPulse: possible to pulse between state 0 and state 2?

#10 Post by midrag » 02 Jun 2020, 16:27

Ath wrote:
16 May 2020, 20:19

Code: Select all

on LongpulseGPIO do // usage: event,LongpulseGPIO,<gpio>,<seconds>
  if %eventvalue1% > 0 and %eventvalue2% > 0
    let,%eventvalue1%,%eventvalue2%
    gpio,%eventvalue1%,0  // Turn relay on
  endif
endon

on Rules#Timer=1 do
  if %v1% > 0
    let,1,%v1%-1 // Decrement counter
    if %v1% = 0  // Time to turn it off?
      gpio,1,2 // Set to high-z == Relay off
    endif
  endif
  if %v2% > 0
    let,2,%v2%-1
    if %v2% = 0
      gpio,2,2
    endif
  endif
  // repeat for 3..16
  TimerSet,1,1 // Repeat
endon

on System#Boot do
  TimerSet,1,1 // Start timer-loop
endon
Many thanks for your example! It did help me a lot!

User avatar
Ath
Normal user
Posts: 84
Joined: 10 Jun 2018, 12:06
Location: NL

Re: command LongPulse: possible to pulse between state 0 and state 2?

#11 Post by Ath » 02 Jun 2020, 20:22

midrag wrote:
02 Jun 2020, 16:26
Is my relay board so special?
Well, most likely the high value (1) of the ESP, working on 3.3V, isn't high enough to be recognized as high by the 5V input of your relay board. Quite good described in this Hackaday article
You could add level shifters between the ESP and the inputs to resolve this, or find a relay board that accepts active-low as input. That should work also.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 11 guests