Control garage door and read position

  1. i search in the forum but i can´t find the right answer
  2. i also check the documentation but everythink i try does not work
  3. Add details :
    • Raspberry 3b +
    • iPhone X
    • Blynk server

Hello together,

i have a problem with my actual project. Its the first project i try with blynk so my coding skills are not the best :wink:

I read a lot of documentation and tutorials but the most of them are are difficult to understand at the beginning.

I want to open and close my garage door via Blynk. In addition, a reed sensor should be used to check if the door is closed. This query also works with the code.
Now I want to control a Gpio with a button which controls the motor via a relay.

Can someone tell me what I have to add to the code so that the button of the app controls the Gpio.

Most of the code is from a tutorial but I hope you can add a button here.

Thanks for your answers.

var AUTH = 'XXX'

var blynk = new blynklib.Blynk(AUTH)

var Gpio = require('onoff').Gpio,
antrieb = new Gpio (22, 'out')
reed = new Gpio (17, 'in', 'both'), // register wechselt 'both', wenn der Schalter geöffnet und geschlossen wird.
led = new Gpio (7, 'out');

var virtualPin = 0;

reed.watch(function (err,value) {
led.writeSync(value)

if(value==1){
blynk.virtualWrite(virtualPin,"Tor geschlossen");
console.log('Tor geschlossen');
};

if (value==0){
blynk.virtualWrite(virtualPin,"Tor offen");
console.log('Tor geöffnet');

//blynk.notify("Garagentor ist jetzt geschlossen!");
};

});



process.on ('SIGINT', function () { 
        led.unexport (); 
        reed.unexport ();
}); 


Can I ask why you chose to use a Raspberry Pi for this?
It’s not the ideal hardware for this type of project, and it also prevent you from using C++ as your coding language.
If you search this forum there are numerous projects that do exactly what you are looking for, and some which gave additional functionality such as closing the door automatically after a set time, or sending you a notification if you’ve forgotten to close the door.
However. most of these projects use the NodeMCU board (which only costs a few Euros) and which is normally programmed in C++.

Pete.

I had already used the Raspberry to open the garage. This worked via the very simple app “MyPi”. Now I had the idea to extend it to check the position of the garage door. If it works better with other hardware, I would get it too.