muwerk mupplet Sensor Library
muwerk applets; mupplets: functional units that support specific hardware or reusable applications for sensors
|
mupplet-sensor, binary sensor More...
#include <mup_binary_sensor.h>
Public Member Functions | |
BinarySensor (String name, uint8_t digitalPort, bool inverseLogic=false, String topicName="state") | |
bool | getPhysicalState () |
bool | getBinarySensorLogicalState () |
void | begin (Scheduler *_pSched, uint32_t _pollRateMs=2000) |
mupplet-sensor, binary sensor
The binary_sensor mupplet measures a digital input
Note: this mupplet uses two topics in parallel, with sensor
and binary_sensor
in the topic path. So applications can chose which one to use.
Physical and logical state values of the GPIO assigned to the binary_sensor are opposite, if inverseLogic is set to true during instantiation. Only logical state values are sent automatically on state changes.
topic | message body | comment |
---|---|---|
<mupplet-name>/sensor/<topicName> | ON or OFF | state of binary sensor, topicName given at instantiation, default binary_sensor , automatically sent on state changes |
<mupplet-name>/binary_sensor/<topicName> \ilinebr </td> <td class="markdownTableBodyNone"> ONor OFF\ilinebr </td> <td class="markdownTableBodyNone"> state of binary sensor using binary_sensor/topicName with topicName given at object instantiation, automatically sent on state changes \ilinebr </td> </tr> <tr class="markdownTableRowOdd"> <td class="markdownTableBodyNone"> <mupplet-name>/sensor/physical/<topicName>\ilinebr </td> <td class="markdownTableBodyNone"> ONor OFF\ilinebr </td> <td class="markdownTableBodyNone"> state of binary sensor, topicName given at instantiation, default binary_sensor, not sent automatically on state change, but only as reply to the corresponding GET message (s.b.) \ilinebr </td> </tr> <tr class="markdownTableRowEven"> <td class="markdownTableBodyNone"> <mupplet-name>/binary_sensor/physical/<topicName> | ON or OFF | state of binary sensor using binary_sensor/topicName with topicName given at object instantiation, not set automatically on state change. |
topic | message body | comment |
---|---|---|
<mupplet-name>/sensor/<topicName>/get | - | Causes current logical state value to be sent with. |
<mupplet-name>/binary_sensor/<topicName>/get | - | Causes current logical state value to be sent. |
<mupplet-name>/sensor/physical/<topicName>/get | - | Causes current physical state value to be sent with. |
<mupplet-name>/binary_sensor/physical/<topicName>/get | - | Causes current physical state value to be sent. |
Hardware: BinarySensor, 10kΩ resistor
|
inline |
Instantiate an BinarySensor sensor mupplet
name | Name used for pub/sub messages |
digitalPort | GPIO port for binary sensor input |
inverseLogic | default false. If true, 'ON' is signaled if GPIO is low (inverse logic) |
topicName | MQTT topic used to send both sensor/<topicName> and binary_sensor/<topicName> messages. |
|
inline |
Start processing of binary sensor input
_pSched | pointer to muwerk scheduler object |
_pollRateMs | measurement interval in ms, default 2secs. |
|
inline |
get the current logical state of the binary sensor.
Note: if inverseLogic is set the true
during object instantiation, true is returned, if GPIO is low (inverted logic). getPhysicalState()
|
inline |
get the current physical state of the binary sensor
Note: this gives true for GPIO state HIGH and false for GPIO state LOW, regardless of inverseLogic setting. getBinarySensorLogicalState()