Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. pesh000
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    pesh000

    @pesh000

    0
    Reputation
    2
    Posts
    289
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    pesh000 Follow

    Best posts made by pesh000

    This user hasn't posted anything yet.

    Latest posts made by pesh000

    • Please help

      Hi everyone, can you help me with my new node.

      0_1467128596459_node.jpg
      i have problems with sending a signal to my garage door to get it open/close. the node doesn't sent anything. here is my code:

      #include <MySensor.h>
      #include <SPI.h>
      #include <Bounce2.h>
      #include <RCSwitch.h>

      #define CHILD_ID_GDOOR 0
      #define CHILD_ID_VDOOR 1
      #define CHILD_ID_RELAY1 2
      #define CHILD_ID_RELAY2 3
      #define CHILD_ID_RELAY3 4

      #define GDOOR_PIN 2
      #define VDOOR_PIN 3
      #define RELAY1_PIN 5
      #define RELAY2_PIN 6

      #define RELAY_ON 0
      #define RELAY_OFF 1

      #define DOOR_CLOSED 0
      #define DOOR_OPEN 1

      Bounce debouncer1 = Bounce();
      Bounce debouncer2 = Bounce();

      boolean oldValueA = 0;
      boolean oldValueB = 0;
      boolean trippedA = 0;
      boolean trippedB = 0;

      bool state;

      MySensor gw;
      MyMessage msggdoor(CHILD_ID_GDOOR,V_TRIPPED);
      MyMessage msgvdoor(CHILD_ID_VDOOR,V_TRIPPED);

      RCSwitch mySwitch = RCSwitch();

      void setup()
      {

      mySwitch.enableTransmit(4);

      // Optional set pulse length.
      // mySwitch.setPulseLength(320);

      // Optional set protocol (default is 1, will work for most outlets)
      // mySwitch.setProtocol(2);
      mySwitch.setRepeatTransmit(3);

      gw.begin(incomingMessage, AUTO, true);

      // Send the sketch version information to the gateway and Controller
      gw.sendSketchInfo("Relay & Button", "1.0");

      pinMode(GDOOR_PIN,INPUT);
      pinMode(VDOOR_PIN,INPUT);
      digitalWrite(GDOOR_PIN,HIGH);
      digitalWrite(VDOOR_PIN,HIGH);

      pinMode(RELAY1_PIN, OUTPUT);
      pinMode(RELAY2_PIN, OUTPUT);

      digitalWrite(RELAY1_PIN, RELAY_OFF);
      digitalWrite(RELAY2_PIN, RELAY_OFF);

      // Set relay to last known state (using eeprom storage)
      state = gw.loadState(CHILD_ID_RELAY1);
      digitalWrite(RELAY1_PIN, state?RELAY_ON:RELAY_OFF);

      gw.present(CHILD_ID_GDOOR, S_DOOR);
      gw.present(CHILD_ID_VDOOR, S_DOOR);
      gw.present(CHILD_ID_RELAY1, S_LIGHT);
      gw.present(CHILD_ID_RELAY2, S_LIGHT);
      gw.present(CHILD_ID_RELAY3, S_LIGHT);
      }

      void loop()
      {
      // Read digital reed switch value
      trippedA = digitalRead(GDOOR_PIN);
      trippedB = digitalRead(VDOOR_PIN);

      // Send value only if changed
      if(trippedA != oldValueA)
      {
      //Serial.print("Door A status: ");
      //Serial.println(trippedA);
      gw.send(msggdoor.set(trippedA ? DOOR_CLOSED : DOOR_OPEN));
      //gw.sendVariable(CHILD_ID_DOORA, V_LOCK_STATUS, trippedA?DOOR_CLOSED:DOOR_OPEN); // Send value change to gw
      delay(1000);
      oldValueA = trippedA;
      }

      // Send value only if changed
      if(trippedB != oldValueB)
      {
      //Serial.print("Door B status: ");
      //Serial.println(trippedB);
      gw.send(msgvdoor.set(trippedB ? DOOR_CLOSED : DOOR_OPEN));
      //gw.sendVariable(CHILD_ID_DOORB, V_LOCK_STATUS, trippedB?DOOR_CLOSED:DOOR_OPEN); // Send value change to gw
      delay(1000);
      oldValueB = trippedB;
      }

      gw.process();

      }

      void incomingMessage(const MyMessage &message) {
      // We only expect one type of message from controller. But we better check anyway.
      if (message.isAck()) {
      Serial.println("This is an ack from gateway");
      }

      if (message.type == V_LIGHT) {
      int actPin;
      // Change relay state
      if (message.sensor == 2){
      state = message.getBool();
      digitalWrite(RELAY1_PIN, state?RELAY_ON:RELAY_OFF);
      // Store state in eeprom
      gw.saveState(message.sensor, state);
      Serial.print("Incoming change for sensor:");
      Serial.print(message.sensor);
      Serial.print(", New status: ");
      Serial.println(message.getBool());

        }
      
        if (message.sensor == 3){ 
          state = message.getBool();
          digitalWrite(RELAY2_PIN,LOW);
          delay(1000);
          digitalWrite(RELAY2_PIN,HIGH);
          // Store state in eeprom
          gw.saveState(message.sensor, state);
       Serial.print("Incoming change for sensor:");
       Serial.print(message.sensor);
       Serial.print(", New status: ");
       Serial.println(message.getBool());
        }
        
        if (message.sensor == 4){ 
          state = message.getBool();
          mySwitch.send(739041, 24);
       Serial.print("Incoming change for sensor:");
       Serial.print(message.sensor);
       Serial.print(", New status: ");
       Serial.println(message.getBool());
        }
      

      }
      }

      posted in Troubleshooting
      pesh000
      pesh000
    • Help with a custom Mysensors Node

      Hi. I need help with a custom project. Can you help me with the code of that project. It should send a open/close signal to garage door via rf433 transmiter, control 2 relays and turn relay on for 5 sec and after that off to door lock

      0_1464286596044_node.jpg

      posted in Development
      pesh000
      pesh000