-
Notifications
You must be signed in to change notification settings - Fork 4
Plugins
A TFBrew system is composed of sensing, decision making, acting and displaying components. The sensing is implemented with Sensor plugins. The decision making is implemented with Logic plugins. The acting is implemented with Actor plugins. Displaying is implemented with extensions that communicate with e.g. Blynk or Web interfaces.
TFBrew support various sensors, e.g. temperature sensors and specific gravity sensors, that can be used with Controllers and Logic to create behaviour in a system. They can also be connected to e.g. user interface extensions to display measurements.
The W1Sensor plugin can be used on a Raspberry Pi to read the temperature values from a one-wire sensor such as the ds18b20. To use it you need to have the w1_therm and w1_gpio kernel modules loaded and the w1 support enabled in raspi-config.
Run sudo raspi-config
and navigate into "Interfacing options" and enable "1-Wire".
Then create the file /etc/modules-load.d/w1.conf
with the content
w1-gpio
w1-therm
You will need to reboot for the 1-wire support to be enabled.
The W1Sensor emits event on an endpoint called temperature
.
Example config:
- KettleTemperature:
plugin: W1Sensor
id: 10-000803628fd8
offset: 1.2 # optional, default 0
pollInterval: 5 # optional, default 2 seconds
Example connections:
- KettleTemperature.temperature=>blynk.v4
Can be used on the Raspberry Pi together with the MAX31865 (e.g. Adafruit PT100 RTD Temperature Sensor Amplifier ) to read temperature from a PT100 RTD temperature sensor.
You will need to connect the MAX31865 to the SPI bus of the Raspberry Pi and then enable SPI support. This is done by running raspi-config
and enabling SPI in Interface options.
- PT100:
plugin: RTDSensor
# SPI devices in Linux are /dev/spidev##.##, e.g. /dev/spidev0.0 for bus 0 device 0
bus: 0 # optional, default 0
device: 0 # optional, default 0
referenceResistance: 430 # optional, default 430 for the Adafruit PT100 amp
zeroDegResistance: 100 # optional, nominal resistance of RTD at 0 deg Celsius
offset: 1.2 # optional, default 0
pollInterval: 5 # optional, default 2 seconds
The TiltSensor reads temperature and gravity from a wireless Tilt Hydrometer. It uses the iBeacon protocol over Low Power Bluetooth. You will need to have a Raspberry Pi 3 or a bluetooth interface that supports low power communication (BLE).
The TiltSensor emits the events
- temperature
- gravity (specific gravity)
- brix
- Tilt:
plugin: TiltSensor
The iSpindelSensor reads temperature and gravity from an wireless iSpindel hydrometer. The iSpindel uses WiFi to connect to the TFBrew controller. You need to configure your iSpindel to send data to a HTTP server. The iSpindel should send data to the /ispindel/ACTORNAME HTTP endpoint in TFBrew (called URL in the iSpindel configuration).
The iSpindel emits everything sent by the iSpindel to TFBrew in the HTTP POST as events, including
- temperature
- gravity
- battery
- angle
- RSSI
To use the iSpindelSensor, add to your config.yaml
- mySpindel:
plugin: iSpindelSensor
In the configuration example above, the HTTP endpoint/URL in the iSpindel configuration should be set to /ispindel/mySpindel
The DummySensor generates fake temperature data. Its main purpose is for testing and developing without needing any actual hardware.
It emits the temperature specified in the fakeTemp
configuration parameter plus a random value.
- FakeKettleTemperature:
plugin: DummySensor
fakeTemp: 67.0
The GPIOActor uses the GPIO pins on a Raspberry Pi to control an actor like a kettle heater or a pump. It supports and uses Pulse Width Modulation (PWM) to be able to support not just on/off states but also a continous level. This makes it possible to control the power output on a heater.
The PWM is just a high speed periodic on/off where the on-time vs. the off-time is varied based on the desired level. The period is set with the pwmFrequency
setting. A good staring value for heaters is 2 Hz (on/off times updated 2 times each second).
The gpio
configuration is the pin number on the Raspberry Pi (BCM numbering).
The GPIOActor responds to events on endpoint state
that will turn it on if the event is 1 and off if the event is 0.
- Heater:
plugin: GPIOActor
gpio: 18
pwmFrequency: 2
The TPLinkActor uses a WiFi controlled mains power socket as an actor. It supports the TP-Link HS100 (and most likely the HS110 as well).
The actor can be used to turn a mains powered device on and off. This can be used to control a fridge or a pump.
You will need to know the IP the socket has on your local network (it does not use the Kasa Cloud to communicate).
- Fridge:
plugin: TPLinkActor
ip: 192.168.1.65
The TPLinkActor responds to events on endpoint state
and power
.
Endpoint state
will turn it on if the event is 1 and off if the event is 0.
Endpoint power
will periodically (every 10 seconds) turn the actor on and off with on time the power*10 sec and off time the rest of the 10 seconds. power
should be between 0.0 (fully off) and 100.0 (fully on).
The DummyActor is just used for testing and development without the need for any actual hardware. It just prints out the events it receives on its state
endpoint.
- FakeHeater:
plugin: DummyActor
Process logic (Logic components) are always used together with a Controller.
A Controller always has a logic plugin, actor and sensor.
The logic plugin is configured with the logicCoeffs
parameters.
The PIDLogic implements a PID feedback algorithm to precisly control e.g. temperature. It is suitable for use in a mash kettle. It is not suited for controlling a compressor in a fridge.
- KettleController:
plugin: PIDLogic
logicCoeffs:
p: 50
i: 2
d: 10
actor: Heater
sensor: KettleTemperature
initialSetpoint: 23
initialState: off
The HysteresisLogic is a simple on/off control. It tries to maintain a temperature around a setpoint by ensuring the temperature does not go above the setpoint + allowed overshoot and not below setpoint + allowed undershoot.
By default the HysteresisLogic assumes it needs to actively maintain temperature by cooling, that is actor is enabled when temperatures go above the threshold. This can be changed by setting the keepHot
parameter to yes
or true
.
- FermentationFridge:
plugin: HysteresisLogic
logicCoeffs:
allowedOvershoot: 0.3
allowedUndershoot: 0.3
keepHot: yes
actor: Compressor
sensor: FridgeTemp
initialSetpoint: 4
initialState: on
- blynk:
plugin: BlynkLib
server: blynk-cloud.com
port: 8442
token: <insert your token>
- webView:
plugin: SimpleWebView
endpoints:
- enable
- setpoint
With this plugin you can visit http://yourip:8080/simpleview and see a json coded view of the events sent to it.
The endpoints
list is optional. It creates URL endpoints to use a webclient to set values through sending events with PUT requests.
When using SimpleWebView you set up connections like
connections:
- webView.enable=>KettleController.state
- Heater.power=>webView.heaterpower
You need to register the enable
as an endpoint to be able to PUT a value on http://yourip:8080/enable
As an example, this curl command can send 1 to the enable endpoint, resulting in KettleController being turned on in the example above
curl -X PUT http://localhost:8081/enable -d '1'
The webView.heaterpower
will be created automatically when an event with that name is received by the plugin.
Extension for logging event data (temperatures etc) to the Ubidots IoT cloud platform.
Create variable endpoint names under the variablesn
section for each variable in your Ubidots device.
- ubidots:
plugin: UbidotsLogger
token: <ubidots_api_token>
variables:
someVar: <ubidotts_variable_id>
Then connect the data endpoint that you would like to log to the Ubidots variable using a line in the connections:
section
connections:
- mashtun.temperature=>ubidots.someVar