Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. ioBroker Allgemein
    4. RPi-Adapter GPIO-Event

    NEWS

    • Neues Video über Aliase, virtuelle Geräte und Kategorien

    • Wir empfehlen: Node.js 22.x

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    RPi-Adapter GPIO-Event

    This topic has been deleted. Only users with topic management privileges can see it.
    • Dutchman
      Dutchman Developer Most Active Administrators last edited by

      @Bröselbube:

      Hallo

      Kann man mithilfe des RPi-Adaters auf ein GPIO Event reagieren.

      Möchte einen Pin mit der Klingel verbinden und möglichst sofort reagieren.

      Also den Pin mit cron zu überwachen reicht mir nicht.

      Gruß `

      Jup, per script (blockly/Java) zum beispiel.

      Manche run blockly script, trigger aug den gpio pin and dan gewünschte aktion

      –-----------------------

      Send from mobile device

      1 Reply Last reply Reply Quote 0
      • B
        Bröselbube last edited by

        Danke das hört sich gut an. Leider ist Blockly nicht mein liebstes Kind.

        Könntest du mir kurz zeigen wie so ein Trigger in JS aussieht?

        Wäre dir sehr dankbar!

        Gruß

        1 Reply Last reply Reply Quote 0
        • Dutchman
          Dutchman Developer Most Active Administrators last edited by

          Hilft das hier?

          Erklärung der "on" funktion mit Beispiel

          https://github.com/ioBroker/ioBroker.ja ... some-state


          Send from mobile device

          1 Reply Last reply Reply Quote 0
          • B
            Bröselbube last edited by

            Oje, das sieht kompliziert aus :shock:

            Versuche einen Code Schnipsel zu googeln, ohne Erfolg.

            1 Reply Last reply Reply Quote 0
            • Dutchman
              Dutchman Developer Most Active Administrators last edited by

              @Bröselbube:

              Oje, das sieht kompliziert aus :shock:

              Versuche einen Code Schnipsel zu googeln, ohne Erfolg. `

              Nim doch blockly und klicke es dir einfach zusammen 😉

              Wen ich wieder am pc sitze kan ich ein Beispiel posten

              –-----------------------

              Send from mobile device

              1 Reply Last reply Reply Quote 0
              • B
                Bröselbube last edited by

                Also ich habs jetzt gelöst (hoffe ich, ich sitze nicht zu Hause).

                var GPIO = require('onoff').Gpio,
                    button = new GPIO(12, 'in', 'both');
                
                button.watch(function(err, state) {
                  if(state === true) {
                      	log("GONG");
                      	sendTo("pushover", "Es hat geklingelt!");
                      	setState("tr-064.0.states.ring"/*ring*/, '**1 10');
                    	setState("mqtt.0.Home.Door", "GONG");
                  }
                });
                

                Letzteres bekommt ein ESP8266 mitgeteilt und setzt ein akustisches Signal im Garten in Gang.

                Hoffe das läuft so.

                1 Reply Last reply Reply Quote 0
                • Dutchman
                  Dutchman Developer Most Active Administrators last edited by

                  Warum nicht in der ersten Reihe mit getstate ? wird die so überhaupt gefüllt?

                  Kenne Button.watch nicht Rest sieht ok aus auf ersten Blick

                  Was steht in Log wen du

                   log(button)
                  

                  Einfügst?

                  –-----------------------

                  Send from mobile device

                  1 Reply Last reply Reply Quote 0
                  • paul53
                    paul53 last edited by

                    @Dutchman:

                    Kenne Button.watch nicht `
                    Das ist eine Funktion des https://www.npmjs.com/package/onoff, die auf Interrupts reagiert.

                    Will man das NPM-Modul in Javascript verwenden, muss man es unter "Zusäzliche NPM-Module" der Javascript-Instanz eintragen.

                    1 Reply Last reply Reply Quote 0
                    • Thisoft
                      Thisoft last edited by

                      Das geht doch vieeel einfacher wenn du den RPi-Adapter laufen hast.

                      var idKlingel ="rpi2.0.gpio.21.state"/*Klingel*/;
                      on({id: idKlingel, val: true},function(obj){
                               log("GONG");
                               sendTo("pushover", "Es hat geklingelt!");
                               setState("tr-064.0.states.ring"/*ring*/, '**1 10');
                             setState("mqtt.0.Home.Door", "GONG");
                      });
                      
                      1 Reply Last reply Reply Quote 0
                      • B
                        Bröselbube last edited by

                        Genau das habe ich gesucht. Besten Dank!

                        Musste nur einen anderen GPIO-Pin nehmen.

                        Grüsse

                        Jo

                        1 Reply Last reply Reply Quote 0
                        • Thisoft
                          Thisoft last edited by

                          Freut mich dass es geklappt hat.

                          1 Reply Last reply Reply Quote 0
                          • Dutchman
                            Dutchman Developer Most Active Administrators last edited by

                            warum nich einfach:

                            on({id: "rpi2.0.gpio.21.state"/*Klingel*/, val: true},function(obj){
                                     log("GONG");
                                     sendTo("pushover", "Es hat geklingelt!");
                                     setState("tr-064.0.states.ring"/*ring*/, '**1 10');
                                   setState("mqtt.0.Home.Door", "GONG");
                            });
                            
                            
                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post

                            Support us

                            ioBroker
                            Community Adapters
                            Donate
                            FAQ Cloud / IOT
                            HowTo: Node.js-Update
                            HowTo: Backup/Restore
                            Downloads
                            BLOG

                            778
                            Online

                            32.1k
                            Users

                            80.6k
                            Topics

                            1.3m
                            Posts

                            4
                            13
                            1626
                            Loading More Posts
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes
                            Reply
                            • Reply as topic
                            Log in to reply
                            Community
                            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                            The ioBroker Community 2014-2023
                            logo