Sonof Question

OWSOO Sonoff Smart Remote Control Wireless Switch Universal Module 4ch DC 5V 12V 32V Wifi Switch Timer Phone APP Remote Control Support Alexa Voice Control for Smart Home

Hello. I have just purchased one of these and I want to send a command to open and close the relay from 50-500 times in quite quick succession say 200ms. Is this possible with the phone app.

This is the basic idea I have but can expand on it if you have the time to help me.

Thanks

Kevin

I doubt this is possible with the hardware you have. Even at your low end (50 times in 0.2secs) that would require the relay to have a switching time of 4ms. That is getting very close to the nominal switch on time of most electro-mechanical relays (~5ms) the switch off times can be 3x times that or more depending on voltage (due to arc quenching time).

Even allowing for it using a solid state relay (1ms to 0.5 ms switching times) you have the problem that HA will not be able to issue commands anywhere near that fast. In fact it will be orders of magnitude slower.

What are you trying to accomplish?

Hello

Sorry I didn’t explain it very well.

I need it to operate the relay every 200-300 ms from 50 times to 500 times so between 3 and 5 times a second for an on of cycle.

I have a coin drop electric meter that I want to control electronically. As the coin drops through the slot it makes a connection on a microswich that adds credit to the meter. The problem is I have the security of the meter and the emptying I am trying to eliminate.

The relay would take the place of the microswitch.

The plan is that the person renting the cottage will buy credit by PayPal and I will send the credit (relay clicks) over using the Sonof board.

Kevin

Ah ok. So it’s not actually that important what the delay is, you just want it small so that it does not take forever. Should be do-able.

Is the microswitch switching mains power or ELV (below 60V)?

Hello

Yes each click is 10p and as you can imagine its a bit of a pain for the renters to get enough 10p/s and keep feeding it.

There is no voltage across the relay or microswitch just a make and break circuit.

There will be some voltage when it is open other wise the circuit would not be able to sense anything, so lets go with ELV.

Most Sonoffs output mains voltage from the relay. You would either have to add another relay or modify the sonoff so the the relay contacts are voltage free. The 4 Channel Pro has voltage free contacts but is a bit of overkill and more expensive.

Your other option is a Wemos D1 mini and any relay running ESPhome. It is very simple to configure with a yaml file. Have a look at the getting started here: https://esphome.io/guides/getting_started_hassio

Which device do you reckon you would like to use?

It will have little impact on the configuration to add credits.

I would do it this way,

Define two input numbers, (1) amount paid in $ and (2) cost of a credit (in case this changes in future).

Calculate the number of credits, (amount paid/cost per credit) and set a counter with this number.

Write a pair of script loops that to toggles the switch and decrements the counter until the counter reaches zero.

You should probably also add another input number for an adjustable delay in milliseconds to tune the loop to run as fast as it can but not overwhelm the electric meter or relay switching time.

My goodness this all looks very complicated. I will look later when I have more time. Would you be willing to build this for me if I can’t get my head around it?

Kevin

I think I will need help