npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gaia-js-controllers

v0.0.2

Published

Basic controllers package for use with GaiaJs

Downloads

5

Readme

Welcome to Gaia-Js!

License

Gaia-js is a NodeJs library for climate control in terrariums, aquariums, vivariums and grow rooms using a RaspberryPi


Getting Started

Installation

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

Examples

PID controller

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);

Level controller

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();

Time interval controller

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();

People

Author Vicente Giner Tendero

License

MIT