| 
    muwerk mupplet Sensor Library
    
   muwerk applets; mupplets: functional units that support specific hardware or reusable applications for sensors 
   | 
 
mupplet-sensor analog sensor sensor More...
#include <mup_analog_sensor.h>
Public Member Functions | |
| AnalogSensor (String name, uint8_t analogPort, FilterMode filterMode=FilterMode::MEDIUM, String topicName="") | |
| double | getUnitAnalogSensor () | 
| void | begin (Scheduler *_pSched, uint32_t _pollRateMs=2000, double _linTransA=1.0, double _linTransB=0.0) | 
mupplet-sensor analog sensor sensor
The analog_sensor mupplet measures analog sensor using a simple analog sensor sensor
| topic | message body | comment | 
|---|---|---|
<mupplet-name>/sensor/unitanalogsensor    | normalized analog sensor [0.0..1.0] or [b..a+b] | Float value encoded as string, rescaled if a non-default linear transformation is given at begin() | 
<mupplet-name>/sensor/<topicName>    | normalized analog sensor [0.0..1.0] or [b..a+b] | Float value encoded as string, topicName is an optional parameter of the object initialization | 
<mupplet-name>/sensor/mode    | FAST, MEDIUM, or LONGTERM    | Integration time for analog sensor values | 
| topic | message body | comment | 
|---|---|---|
<mupplet-name>/sensor/unitanalogsensor/get    | - | Causes current value to be sent. | 
<mupplet-name>/sensor/<topicName>/get    | - | Causes current value to be sent, if an additional topicName was given at object creation. | 
<mupplet-name>/sensor/mode/get    | - | Returns filterMode: FAST, MEDIUM, or LONGTERM     | 
<mupplet-name>/sensor/mode/set    | FAST, MEDIUM, or LONGTERM    | Set integration time for analog sensor values | 
 Hardware: AnalogSensor, 10kΩ resistor
Note: For ESP32 make sure to use a port connected to ADC #1, since ADC #2 conflicts with Wifi and ports connected to ADC #2 cannot be used concurrently with Wifi!
      
  | 
  inline | 
Instantiate an AnalogSensor sensor mupplet
| name | Name used for pub/sub messages | 
| analogPort | GPIO port with A/D converter capabilities. | 
| filterMode | FAST, MEDIUM or LONGTERM filtering of sensor values of analog port | 
| topicName | optional additional mqtt topic name, generating additional mqtt messages | 
      
  | 
  inline | 
Start processing of A/D input from AnalogSensor
The analog sensor mupplet by default measures the analog port, and maps values always into the range [0..1]. Optionally, a linear transformation can be applied to map the range value into a different range: if a value v is measured, v is by default [0..1] and now a * v + b is applied. With the defaults of a=1, b=0, no change is made by the transformation, since 1*v+0 = v. By changing _linTransA (for a) and/or _linTransB (for b), the output range can be rescaled linearily.
Note: if you are not using the linear transformation feature, make sure that _linTransA is set to 1.0 and _linTransB is set to 0.0!
| _pSched | pointer to muwerk scheduler object | 
| _pollRateMs | Optional measurement pollrate in ms, default 2000, a measurement every 2 secs. | 
| _linTransA | Optional transformation factor a, default 1.0, values v read from analog sensor are transformed with a*v+b. | 
| _linTransB | Optional transformation factor b, default 0.0, values v read from analog sensor are transformed with a*v+b. | 
      
  | 
  inline | 
Get current analog sensor value