Greg Young - Help with sensESP code ..please 🙂...
Help with sensESP code ..please 🙂
To date all my sensESP projects have used "sensors" and hence reading and sending status, values etc up to signalk.
Ive not had any experience with "controlling"something via sensESP.. and have looked in examples .. but didnt find anything comparable.
Im trying to "control" a relay from sensESP using a change of state in an skpath.
In particular i need to "pulse"the relay (aka GPIO output ) for around 500mS duration (turn it On for 500mS then off.. exact timing is not critical)
I know how to set the GPIO output based on the skpath (using below) ..
But how would i create a short pulse of the GPIO output?
Im aware that there are certain restrictions on putting delays into the sensesp code .. because of how react? works?
any examples of code others have used in a similar context would be very appreciated
**
// sensESP monitors an SKPath that is toggled "true/false" by NodeRed flow
auto* CockpitLightsListener = new BoolSKListener(CockpitLightsControlSKPath);
CockpitLightsListener
->connect_to(new DigitalOutput(5));
2 Replies
You're right that you shouldn't use
delay
in SensESP code - that blocks the whole event loop from working. But creating a pulse is still quite simple.
The delays are not totally accurate but unless something is off, should be there within a fraction of a ms.
To wrap this code into a consumer that can be used with ValueListeners, you use a LambdaConsumer:
coool... much appreciated. thanks