Entre gpio

Forum dédie aux capteurs et gateway mysensors.org
Répondre
sphinxou
Messages : 231
Inscription : 03 déc. 2016, 13:37

Entre gpio

Message par sphinxou »

Bonjour

Est il possible d'utiliser les gpio de la passerelle mysensors?

Si oui comment faire?
Jai regarder sur Google mais je ne comprend pas trop


Merci
Domoticz 4.9700/ rfxcom /sonde diy/raspberry pi3+HDD/cirusms/contact de porte diy
fcBourgogne
Messages : 172
Inscription : 31 mars 2020, 14:22

Re: Entre gpio

Message par fcBourgogne »

Bonjour,

Les Gpio ou pin de la passerelle sont bien disponibles.
Je viens tout juste de terminer un montage avec un Nano, un clavier 4x4 et un mini écran oled, pour activer ou désactiver
l'alarme.
La passerelle Nano est branchée au RPI via un port USB.
MySensors1b.png
MySensors1b.png (199.59 Kio) Consulté 39745 fois
MySensors2b.png
MySensors2b.png (202.52 Kio) Consulté 39745 fois
A+
Dernière modification par fcBourgogne le 14 janv. 2023, 21:55, modifié 1 fois.
Raspberry PI5+ 1WIRE + I2C +ESP8266 +esp32
sphinxou
Messages : 231
Inscription : 03 déc. 2016, 13:37

Re: Entre gpio

Message par sphinxou »

Bonjour
Merci pour le retour mais comment déclaré les gpio dans la passerelle
Domoticz 4.9700/ rfxcom /sonde diy/raspberry pi3+HDD/cirusms/contact de porte diy
fcBourgogne
Messages : 172
Inscription : 31 mars 2020, 14:22

Re: Entre gpio

Message par fcBourgogne »

Ben, comme dans tous les programmes Arduino qui font fonctionner des actionneurs ou autres.

Quel est ton projet?
A+
Raspberry PI5+ 1WIRE + I2C +ESP8266 +esp32
Keros
Messages : 6638
Inscription : 23 juil. 2019, 20:57

Modération

Message par Keros »

Pour tes images fcBourgogne, peux-tu s'il te plait les redimensionner avant de les envoyer sur le forum ? Pour charger ton message, il faut télécharger 2 Mo d'image : c'est beaucoup.
Une image de 200 Ko suffit largement et ceux qui n'ont pas de fibre 100 Mo/s pourront continuer de profiter d'une navigation fluide. Sans parler des sauvegardes du forum qui vont exploser à ce rythme... Ce serait sympa si tu pouvais éditer ton post et recharger des photos plus légères. Merci
sphinxou
Messages : 231
Inscription : 03 déc. 2016, 13:37

Re: Entre gpio

Message par sphinxou »

Je voudrai utiliser les gpio d'un mega2560 avec my sensor et domoticz
Domoticz 4.9700/ rfxcom /sonde diy/raspberry pi3+HDD/cirusms/contact de porte diy
fcBourgogne
Messages : 172
Inscription : 31 mars 2020, 14:22

Re: Entre gpio

Message par fcBourgogne »

Bonsoir,

J'avais bien compris, il faut approfondir.
Donne un peu plus d'éléments, comme asservir un relai, un contact.
A+

PS: pour Keros, j'ai changé la taille des images.
Raspberry PI5+ 1WIRE + I2C +ESP8266 +esp32
sphinxou
Messages : 231
Inscription : 03 déc. 2016, 13:37

Re: Entre gpio

Message par sphinxou »

J'aimerais utiliser 20 sortie pour piloter des relais et 15 entre pour contact de portes
Domoticz 4.9700/ rfxcom /sonde diy/raspberry pi3+HDD/cirusms/contact de porte diy
fcBourgogne
Messages : 172
Inscription : 31 mars 2020, 14:22

Re: Entre gpio

Message par fcBourgogne »

Bonjour,

Ah oui quand même! Je ne peux que te conseiller de trouver des exemples de montage avec code ici dans MySensors.

A+
Dernière modification par Keros le 16 janv. 2023, 12:33, modifié 1 fois.
Raison : Citation supprimée. Merci de ne pas citer le message précédent lors d'une réponse directe.
Raspberry PI5+ 1WIRE + I2C +ESP8266 +esp32
sphinxou
Messages : 231
Inscription : 03 déc. 2016, 13:37

Re: Entre gpio

Message par sphinxou »

bonjour

ci joint mon premier prog

Code : Tout sélectionner

// Enable debug prints to serial monitor
#define MY_DEBUG 

// Enable and select radio type attached
//#define MY_RADIO_RF24
//#define MY_RADIO_RFM69

// Enable serial gateway
#define MY_GATEWAY_SERIAL

#include <MySensors.h>
#include <Bounce2.h>


#define CHILD_ID1 22
#define BUTTON_PIN1  22
#define CHILD_ID2 23
#define BUTTON_PIN2  23
#define CHILD_ID3 24
#define BUTTON_PIN3  24
#define CHILD_ID4 25
#define BUTTON_PIN4  25
#define CHILD_ID5 26
#define BUTTON_PIN5  26
#define CHILD_ID6 27
#define BUTTON_PIN6  27
#define CHILD_ID7 28
#define BUTTON_PIN7  28
#define CHILD_ID8 29
#define BUTTON_PIN8  29
#define CHILD_ID9 30
#define BUTTON_PIN9  30
#define CHILD_ID10 31
#define BUTTON_PIN10  31





#define RELAY_PIN 40  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
#define NUMBER_OF_RELAYS 20 // Total number of attached relays
#define RELAY_ON 0  // GPIO value to write to turn on attached relay
#define RELAY_OFF 1 // GPIO value to write to turn off attached relay

Bounce debouncer = Bounce(); 
int oldValue1=-1;
int oldValue2=-1;
int oldValue3=-1;
int oldValue4=-1;
int oldValue5=-1;
int oldValue6=-1;
int oldValue7=-1;
int oldValue8=-1;
int oldValue9=-1;
int oldValue10=-1;


// Change to V_LIGHT if you use S_LIGHT in presentation below
MyMessage msg1(CHILD_ID1,V_TRIPPED);
MyMessage msg2(CHILD_ID2,V_TRIPPED);
MyMessage msg3(CHILD_ID3,V_TRIPPED);
MyMessage msg4(CHILD_ID4,V_TRIPPED);
MyMessage msg5(CHILD_ID5,V_TRIPPED);
MyMessage msg6(CHILD_ID6,V_TRIPPED);
MyMessage msg7(CHILD_ID7,V_TRIPPED);
MyMessage msg8(CHILD_ID8,V_TRIPPED);
MyMessage msg9(CHILD_ID9,V_TRIPPED);
MyMessage msg10(CHILD_ID10,V_TRIPPED);

void before()
{
    for (int sensor=1, pin=RELAY_PIN; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
        // Then set relay pins in output mode
        pinMode(pin, OUTPUT);
        // Set relay to last known state (using eeprom storage)
        digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
    }
}


void setup()  
{  
  // Setup the button
  pinMode(BUTTON_PIN1,INPUT);
  pinMode(BUTTON_PIN2,INPUT);
  pinMode(BUTTON_PIN3,INPUT);
  pinMode(BUTTON_PIN4,INPUT);
  pinMode(BUTTON_PIN5,INPUT);
  pinMode(BUTTON_PIN6,INPUT);
  pinMode(BUTTON_PIN7,INPUT);
  pinMode(BUTTON_PIN8,INPUT);
  pinMode(BUTTON_PIN9,INPUT);
  pinMode(BUTTON_PIN10,INPUT);
  
  // Activate internal pull-up
  digitalWrite(BUTTON_PIN1,HIGH);
  digitalWrite(BUTTON_PIN2,HIGH);
  digitalWrite(BUTTON_PIN3,HIGH);
  digitalWrite(BUTTON_PIN4,HIGH);
  digitalWrite(BUTTON_PIN5,HIGH);
  digitalWrite(BUTTON_PIN6,HIGH);
  digitalWrite(BUTTON_PIN7,HIGH);
  digitalWrite(BUTTON_PIN8,HIGH);
  digitalWrite(BUTTON_PIN9,HIGH);
  digitalWrite(BUTTON_PIN10,HIGH);
  
  // After setting up the button, setup debouncer
  debouncer.attach(BUTTON_PIN1);
  debouncer.interval(100);
  debouncer.attach(BUTTON_PIN2);
  debouncer.interval(100);
  debouncer.attach(BUTTON_PIN3);
  debouncer.interval(100);
  debouncer.attach(BUTTON_PIN4);
  debouncer.interval(100);
  debouncer.attach(BUTTON_PIN5);
  debouncer.interval(100);
  debouncer.attach(BUTTON_PIN6);
  debouncer.interval(100);
  debouncer.attach(BUTTON_PIN7);
  debouncer.interval(100);
  debouncer.attach(BUTTON_PIN8);
  debouncer.interval(100);
  debouncer.attach(BUTTON_PIN9);
  debouncer.interval(100);
  debouncer.attach(BUTTON_PIN10);
  debouncer.interval(100);
}

void presentation() {
  // Register binary input sensor to gw (they will be created as child devices)
  // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. 
  // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
  present(CHILD_ID1, S_DOOR);
  present(CHILD_ID2, S_DOOR);
  present(CHILD_ID3, S_DOOR);
  present(CHILD_ID4, S_DOOR);
  present(CHILD_ID5, S_DOOR);
  present(CHILD_ID6, S_DOOR);
  present(CHILD_ID7, S_DOOR);
  present(CHILD_ID8, S_DOOR);
  present(CHILD_ID9, S_DOOR);
  present(CHILD_ID10, S_DOOR);  


 sendSketchInfo("JUL", "2.0");

    for (int sensor=1, pin=RELAY_PIN; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
        // Register all sensors to gw (they will be created as child devices)
        present(sensor, S_BINARY);
    }
}



//  Check if digital input has changed and send in new value
void loop() 
{
  debouncer.update();
  // Get the update value
  int value1 = debouncer.read();
  int value2 = debouncer.read();
  int value3 = debouncer.read();
  int value4 = debouncer.read();
  int value5 = debouncer.read();
  int value6 = debouncer.read();
  int value7 = debouncer.read();
  int value8 = debouncer.read();
  int value9 = debouncer.read();
  int value10 = debouncer.read();

   value1 = digitalRead(BUTTON_PIN1);
  value2 = digitalRead(BUTTON_PIN2);
  value3 = digitalRead(BUTTON_PIN3);
 value4 = digitalRead(BUTTON_PIN4);
 value5 = digitalRead(BUTTON_PIN5);
 value6 = digitalRead(BUTTON_PIN6);
 value7 = digitalRead(BUTTON_PIN7);
 value8 = digitalRead(BUTTON_PIN8);
 value9 = digitalRead(BUTTON_PIN9);
 value10 = digitalRead(BUTTON_PIN10);

  if (value1 != oldValue1) {
     // Send in the new value
     send(msg1.set(value1==HIGH ? 1 : 0));
          oldValue1 = value1;
  }
  if (value2 != oldValue2) {
     // Send in the new value
     send(msg2.set(value2==HIGH ? 1 : 0));
          oldValue2 = value2;
  }
  if (value3 != oldValue3) {
     // Send in the new value
     send(msg3.set(value3==HIGH ? 1 : 0));
          oldValue3 = value3;
  }
  if (value4 != oldValue4) {
     // Send in the new value
     send(msg4.set(value4==HIGH ? 1 : 0));
          oldValue4 = value4;
  }
   if (value5 != oldValue5) {
     // Send in the new value
     send(msg5.set(value5==HIGH ? 1 : 0));
          oldValue5 = value5;
  }
   if (value6 != oldValue6) {
     // Send in the new value
     send(msg6.set(value6==HIGH ? 1 : 0));
          oldValue6 = value6;
  }
   if (value7 != oldValue7) {
     // Send in the new value
     send(msg7.set(value7==HIGH ? 1 : 0));
          oldValue7 = value7;
  }
   if (value8 != oldValue8) {
     // Send in the new value
     send(msg8.set(value8==HIGH ? 1 : 0));
          oldValue8 = value8;
  }
   if (value9 != oldValue9) {
     // Send in the new value
     send(msg9.set(value9==HIGH ? 1 : 0));
          oldValue9 = value9;
  }
   if (value10 != oldValue10) {
     // Send in the new value
     send(msg10.set(value10==HIGH ? 1 : 0));
          oldValue10 = value10;
  }
} 

void receive(const MyMessage &message)
{
    // We only expect one type of message from controller. But we better check anyway.
    if (message.getType()==V_STATUS) {
        // Change relay state
        digitalWrite(message.getSensor()-1+RELAY_PIN, message.getBool()?RELAY_ON:RELAY_OFF);
        // Store state in eeprom
        saveState(message.getSensor(), message.getBool());
        // Write some debug info
        Serial.print("Incoming change for sensor:");
        Serial.print(message.getSensor());
        Serial.print(", New status: ");
        Serial.println(message.getBool());
    }
}
les entres ne fonctionne pas très bien une idée ?

merci
Domoticz 4.9700/ rfxcom /sonde diy/raspberry pi3+HDD/cirusms/contact de porte diy
Répondre