ldleman / yana-server

Interface PHP de domotique Y.A.N.A (You Are Not Alone)
http://projet.idleman.fr/yana
107 stars 59 forks source link

STORY: Utilisation Gpio 0 1 2 3 en entrée #266

Closed juliendiotworldtour closed 8 years ago

juliendiotworldtour commented 8 years ago

Bonjour @Idleman, comment vas tu? Concernant Yana4all j'ai envoyé un message a Alexandre Roland, ça devrait s'arranger bientôt. Je t'écris aujourd'hui car j'ai voulu utiliser les Gpio 0 1 2 3 en entrée sur mon Rpi2 et j'aurai aimé avoir des info par rapport aux branchements a faire. Pour le moment j'ai fait ça (je suppose qu'il s'agit d'un montage Pull down):

montage actuel

Comment les brancherais tu si ce montage ne convient pas? Car actuellement, j'ai des problèmes. Est ce qu'il faut absolument avoir une résistance de 10kohms à chaque fois (interférences?)?

Sur un Tuto pour l'utilisation des GPIO en entrée/sortie, il est précisé que le RPI embarque déjà des résistances pull up pull down, nous évitant ainsi d'avoir à en rajouter. voici l'extrait en anglais:

What’s all this about internal ones then? In our button circuit, we used resistors to pull down the voltage. This was to demonstrate the idea.

But, in fact, the Raspberry Pi has built-in pull-up and pull-down resistors which can be enabled in software. This means we can eliminate our pull-down resistors for the button – as long as we enable the internal ones.

How do you do that? RPi.GPIO to the rescue.

You enable these internal pull-ups/pull-downs at the time of setting up the port for input or output, by adding an extra, optional, argument to the GPIO.setup() function call.

We’re using pull-down, so it’s pull_up_down=GPIO.PUD_DOWN. If you want/need pull-up you can change the PUD_DOWN for PUD_UP. (It depends on how you’ve wired your circuit.)

GPIO.setup(port_or_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

voici le lien vers l'article: http://raspi.tv/2013/rpi-gpio-basics-6-using-inputs-and-outputs-together-with-rpi-gpio-pull-ups-and-pull-downs

Merci de ton aide pour les branchements! Bonne soirée