Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
gaia-js-controllers
Advanced tools
Gaia-js is a NodeJs library for climate control in terrariums, aquariums, vivariums and grow rooms using a RaspberryPi
To start using GaiaJs you only need to install the main module:
npm install gaia-js
After install the core module you need to install the controllers module for add basic functionality:
npm install gaia-js-controllers
The best way to control values like temperature or humidity is using a PID controller:
var Gaia = require('gaia-js');
var PidController = require('gaia-js-controllers').PidController;
// Create the new PID controller
var temperatureZone1 = new PidController({
name: 'Temperature_Zone1',
input: temperature, // The temperature input usually obtained from a sensor
setPoint: 23, // The desired temperature
kp: 500, // PID algorithm settings
ki: 200,
kd: 0,
limits: { // The output limits used for control the temperature
outMin: 0,
outMax: 255
}
});
// Add the controller callback
temperatureZone1.addOnComputeCallback(function(controller, output) {
controller.setInput(temperature); // Update the controller input
// Use the PID output to modify the desired value
});
// Add the controller to the GaiaJs core
Gaia.controller(temperatureZone1);
// Start GaiaJs
Gaia.start();
The use of this controller is recommended whenever is possible to adjust the output level of the device used to control the desired values
You can change the PID direction in the constructor options or with the direction setter:
var temperatureZone1 = new PidController({
name: 'Temperature_Zone1',
direction: PidController.REVERSE
...
});
temperatureZone1.setDirection(PidController.DIRECT);
The use of this controller is recommended when the device used to control the desired values have only on/off states.
var Gaia = require('gaia-js');
var LevelController = require('gaia-js-controllers').LevelController;
// Create the new PID controller
var humidityZone1 = new LevelController({
name: 'Humidity_Zone1',
input: humidity, // The humidity input usually obtained from a sensor
setPoint: 80 // The desired humidity
});
// Add the controller callback
humidityZone1.addOnCheckLevelCallback(function(controller, levelExceed) {
controller.setInput(humidity); // Update the controller input
// Use the PID output to modify the desired value
if(levelExceed) {
// The humidity is over the desired value
} else {
// The humidity is under the desired value
}
});
// Add the controller to the GaiaJs core
Gaia.controller(humidityZone1);
// Start GaiaJs
Gaia.start();
Use this controller to perform actions depending on a time interval, such as turning lights on and off
var Gaia = require('gaia-js');
var TimeIntervalController = require('gaia-js-controllers').TimeIntervalController;
// Create the new Time Interval controller
var mainLightsControl = new TimeIntervalController({
name: 'Main_Lights_Control',
intervals: [
{
start: '17:06',
end: '17:07'
},
{
start: '17:08',
end: '17:09'
}
]
});
// Add the controller tick callback
mainLightsControl.addOnTickCallback(function(isInInterval) {
if(isInInterval) {
// Switch lights on
} else {
// Switch lights off
}
});
// Add the controller to the GaiaJs core
Gaia.controller(mainLightsControl);
// Start GaiaJs
Gaia.start();
Author Vicente Giner Tendero
FAQs
Basic controllers package for use with GaiaJs
The npm package gaia-js-controllers receives a total of 0 weekly downloads. As such, gaia-js-controllers popularity was classified as not popular.
We found that gaia-js-controllers demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.