Hallo,
ich habe einen Water Flow Sensor YF-S401 an einem Industrial Digital In 4 Bricklet 2.0 angeschlossen (siehe angehängtes Bild).
Nun würde ich gerne zählen wie oft sich das Rädchen im Sensor dreht. Dazu habe ich folgenden Code:
const Tinkerforge = require('tinkerforge');
const ipcon = new Tinkerforge.IPConnection();
const idi4 = new Tinkerforge.BrickletIndustrialDigitalIn4V2('HXN', ipcon);
ipcon.connect(HOST, PORT, (err) => {
console.log('IPConnection error', err);
});
ipcon.on(Tinkerforge.IPConnection.CALLBACK_CONNECTED, (connectReason) => {
console.log('IPConnection CALLBACK_CONNECTED', connectReason);
idi4.setEdgeCountConfiguration(Tinkerforge.BrickletIndustrialDigitalIn4V2.CHANNEL_0,Tinkerforge.BrickletIndustrialDigitalIn4V2.EDGE_TYPE_BOTH, 1);
setInterval(() => {
idi4.getEdgeCount(Tinkerforge.BrickletIndustrialDigitalIn4V2.CHANNEL_0, false,
(count) => console.log('Count: ' + count),
(error) => console.log('Error: ' + error)
);
}, 1000);
});
Ausgabe:
IPConnection CALLBACK_CONNECTED 0
Count: 0
Count: 0
Count: 0
Count: 0
Count: 0
Count: 0
Count: 0
Count: 0
Count: 0
Count: 0
Count: 0
Count: 0
Count: 0
Count: 0
...
Ich wäre bin um jeden Hinweis dankbar.
Viele Grüße
Michael