Jump to content
View in the app

A better way to browse. Learn more.

Tinkerunity

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Geschrieben

Hi

Folgendes simple node.js Programm:

var TF = require('tinkerforge');

var HOST = 'myhost';
var PORT = 4223;

var ipcon = new TF.IPConnection();
var masterBrick = new TF.BrickMaster('6esCZX', ipcon);
var tempBricklet = new TF.BrickletTemperature('dCf', ipcon);
var distUSBricklet = new TF.BrickletDistanceUS('nY3', ipcon);

ipcon.connect(HOST, PORT, function(error) {
    console.log("Could not open connection: "+error);        
});

ipcon.on(TF.IPConnection.CALLBACK_CONNECTED, function(connectReason) {
    // Configure Bricklets
    masterBrick.setWifiPowerMode(TF.BrickMaster.WIFI_POWER_MODE_LOW_POWER);
    tempBricklet.setI2CMode(TF.BrickletTemperature.I2C_MODE_SLOW); // to prevent outlier
    tempBricklet.setTemperatureCallbackPeriod(5000);
    distUSBricklet.setMovingAverage(100);
    distUSBricklet.setDistanceCallbackPeriod(5000);
    
});

tempBricklet.on(TF.BrickletTemperature.CALLBACK_TEMPERATURE, function(temp){
    console.log('Temperature: '+temp/100);
}); 

distUSBricklet.on(TF.BrickletDistanceUS.CALLBACK_DISTANCE, function(distance) {
    console.log('Distance: '+distance);
});

 

Alle 5 Sekunden wird Temperatur und US Distanz angegeben.

 

Starte ich nun den Brickv und gehe auf das DistanceUS Brickelt, dann sehe ich in meinem Node.js Program sehr viele und schnell hintereinander folgende Ausgaben:

Temperature: 11.37
Temperature: 11.31
Distance: 1234
Temperature: 11.37
Distance: 1233
Distance: 1234
Distance: 1233
Distance: 1234
Distance: 1233
Distance: 1232
Distance: 1231
Distance: 1232
Distance: 1231
Distance: 1232
Distance: 1231
Distance: 1232
Distance: 1233
Distance: 1232
Distance: 1233
Distance: 1232
Distance: 1231
Distance: 1232
Distance: 1231
Distance: 1232
Distance: 1231
Distance: 1232

 

Warum beeinflusst der Bickv mein node Script? Es sollten doch unterschiedliche IPConnectios sein ?

Geschrieben

Warum beeinflusst der Bickv mein node Script? Es sollten doch unterschiedliche IPConnectios sein ?

 

Callbacks werden nicht per IP Connection eingestellt, sondern die Callback Einstellungen sind auf dem Brick(let)s und somit global über alle IP Connections hinweg. Daher können sich zwei Programme die die gleichen Callbacks nutzen in die quere kommen.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gast
Reply to this topic...

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.