tinkerforge-device-manager
v0.7.0
Published
A node library to make connecting to and accessing Tinkerforge devices easier. Created at the University of Applied Sciences in Osnabrueck.
Downloads
8
Readme
Tinkerforge Device Manager
A node library to make connecting to and accessing Tinkerforge devices easier. Created at the University of Applied Sciences in Osnabrueck.
Supported Devices
Currently supported Tinkerforge devices:
- Accelerometer Bricklet
- Air Quality Bricklet
- Ambient Light 2.0 Bricklet
- Barometer 1.0 Bricklet
- Barometer 2.0 Bricklet
- C02 Bricklet
- Dust Detector Bricklet
- Distance IR Bricklet
- Distance US Bricklet
- GPS 2.0 Bricklet
- Humidity 2.0 Bricklet
- LCD 128x64 Bricklet
- Motion Detector 2.0 Bricklet
- NFC Bricklet
- OLED 128x64 Display Bricklet
- Outdoor Weather Bricklet
- Piezo Speaker Bricklet
- RGB LED Bricklet
- RGB LED Button Bricklet
- Sound Intensity Bricklet
- Sound Pressure Level Bricklet
- Thermal Imaging Bricklet
- UV Light 1.0 Bricklet
- UV Light 2.0 Bricklet
Example
Consider you have a Humidity V2 Bricklet connected to a Master Brick. You can then use the device manager to get the Humidity V2 Bricklet via its UID or its device identifier. The process is as follows:
- Initialize the device manager (
dm.initialize()
) - Set a callback that is called for each connected device (e.g.
dm.setConnectCallback(start);
) - In
start(device)
you'll have the current device as a wrapper object. Now you can check the type and register listeners (or do anything else)
Here is a full example (see also test.js
):
var dm = require('./index.js');
// You can pass host and port, default is 'localhost' and 4223
dm.initialize();
// This will call start for each enumerated device
dm.setConnectCallback(start);
function start(device) {
// Check the name of the current device
console.log(device.getName());
// Humidity V2 Bricklet
if (device.getDeviceIdentifier() == 283) {
device.registerListener(humidityChanged)
}
// Accelerometer Bricklet
if (device.getDeviceIdentifier() == 250) {
device.registerListener(accelerationChanged)
}
// And so on...
}
function humidityChanged(valObject) {
console.log(valObject);
}
function accelerationChanged(valObject) {
console.log(valObject);
}