Jump to content

Water Flow Sensor YF-S401 über Industrial Digital In 4 Bricklet 2.0 auslesen


hellomichibye

Recommended Posts

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

 

IMG_3134.thumb.JPG.4af516d1b2b806eaa546dee4fa79177d.JPG

Link to comment
Share on other sites

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...