Navigation

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

    Marco Avallone

    @Marco Avallone

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

    Marco Avallone Follow

    Best posts made by Marco Avallone

    This user hasn't posted anything yet.

    Latest posts made by Marco Avallone

    • RE: HELP!! NODE WITH RELAY VOLTAGE AND DETECTOR

      OK, I rephrase the request.

      I have at home this CONFIGURATION

      0_1485349496573_deviatore_schema_funzionamento.png

      I created the following script:

      // Enable debug prints to serial monitor
      #define MY_DEBUG 
      
      // Enable and select radio type attached
      #define MY_RADIO_NRF24
      //#define MY_RADIO_RFM69
      
      // Enabled repeater feature for this node
      #define MY_REPEATER_FEATURE
      
      #include <SPI.h>
      #include <MySensors.h>
      
      
      #define RELAY_PIN  3  // Arduino Digital I/O pin number for relay 
      #define BUTTON_PIN  4  // Arduino Digital I/O pin number for button 
      #define CHILD_ID 1   // Id of the sensor child
      #define RELAY_ON 0
      #define RELAY_OFF 1
      
      
      
        bool state;
        int luce;
        int soglia = 25; //  imposed sensor sensitivity
        int statorelay = 0; //  variable that saves in memory initial state relay
      
      MyMessage msg(CHILD_ID,V_LIGHT);
      
      void setup()  
      {   
       
       
        pinMode(RELAY_PIN, OUTPUT); // 
        digitalWrite(RELAY_PIN, RELAY_OFF); //  Initial setting relay on off
      
      
      }
      
      void presentation()  {
      
        sendSketchInfo("RELAY DEVERTER", "1.0");
        present(CHILD_ID, S_LIGHT);
      }
      
      
      void loop() 
      {  
          
            int value;
            luce = (1023-analogRead(A0))/10.23;  // 
      I note if there is current on the bulb. I use a 220v led with a photoresistor.
            if(luce < soglia) {
           
              send(msg.set(value==HIGH ? 1 : 0)); //voltage yes
              }
            else {
              
              send(msg.set(value==LOW ? 1 : 0)); // voltage no
              }
          
           
            delay (1000);
      
      }
      
      
      
      void receive(const MyMessage &message) {
        //  SECTION ENTER POWER RELAY WITH REVERSE
      
           if (message.getBool()== 1, statorelay ==0)  {    // POWER ON MESSAGE WITH BULB OFF
                    Serial.print("ACCENDI RELAY - Lampanida accesa ");
                    digitalWrite(RELAY_PIN, RELAY_ON);
                    statorelay=1; // salvo in memoria stato relay
                    return; // blocco script
              }
           if (message.getBool()== 0, statorelay ==1)  {   //  SHUTDOWN WITH MESSAGE ON BULB
                     Serial.print("SPEGNI RELAY - Lampanida spenta");
                     digitalWrite(RELAY_PIN, RELAY_OFF);
                     statorelay=0;
                     return;
             }
           if (message.getBool()== 0, statorelay ==0)  {   // SHUTDOWN MESSAGE WITH BULB OFF - REVERSE
                       Serial.print("ACCENDI RELAY - Lampanida spenta ");
                       digitalWrite(RELAY_PIN, RELAY_ON);
                       statorelay=1;
                       return;
              }
           if (message.getBool()== 1, statorelay ==1)  {   //POWER ON MESSAGE WITH BULB ON - REVERSED
                         Serial.print("SPEGNI RELAY - Lampanida accesa ");
                         digitalWrite(RELAY_PIN, RELAY_OFF);
                         statorelay=1;
                         return;
              }
      }
      

      This script works, and allows me to see if the bulb is actually on or off, and turn it off or turn it on indipendetemente the state of the relay.

      The problem is the script:

      1. I would like to add more relays with detectors.
      2. I would like to send the status of the bulb to the gateway only when actually changes.

      Can you help me? I'VE BEEN CLEAR?

      THANK YOU!!!

      posted in Development
      Marco Avallone
      Marco Avallone
    • HELP!! NODE WITH RELAY VOLTAGE AND DETECTOR

      Hi I'm trying to make a script of Arduino to create a node with home automation: relay, light sensor, and sensor noise.

      The problem is that the only solution for the installation of the coupling relay with a switch.

      The script should be divided into 2 sections:

      1. asynchronous control with photoresistor
      2. Turn off relay asynchronously, following a first draft to be modified:

      int stato = statorelay[message.getBool()]; //leggo stato da array
      Serial.print("stato:");
      Serial.println(stato);
      Serial.print("getbboolo:");
      Serial.println(message.getBool());
      Serial.print("messaggio sensore:");
      Serial.println(message.sensor);
      if (message.getBool()== 1, stato ==0) { // MESSAGGIO DI ACCENSIONE CON LAMPADINA SPENTA
      Serial.print("ACCENDI RELAY - Lampanida accesa ");
      digitalWrite(message.sensor-1+RELAY_3, RELAY_ON);
      statorelay[message.getBool()] = 1; // salvo in memoria stato relay
      return; // blocco script
      }
      if (message.getBool()== 0, stato ==1) { // MESSAGGIO DI SPEGNIMENTO CON LAMPADINA ACCESA
      Serial.print("SPEGNI RELAY - Lampanida spenta");
      digitalWrite(message.sensor-1+RELAY_3, RELAY_OFF);
      statorelay[message.getBool()] = 0; // salvo in memoria stato relay
      return;
      }
      if (message.getBool()== 0, stato ==0) { //MESSAGGIO DI SPEGNIMENTO CON LAMPADINA SPENTA
      Serial.print("ACCENDI RELAY - Lampanida spenta ");
      digitalWrite(message.sensor-1+RELAY_3, RELAY_ON);
      statorelay[message.getBool()] = 1; // salvo in memoria stato relay
      return;
      }
      if (message.getBool()== 1, stato ==1) { //MESSAGGIO DI ACCENSIONE CON LAMPADINA ACCESA
      Serial.print("SPEGNI RELAY - Lampanida accesa ");
      digitalWrite(message.sensor-1+RELAY_3, RELAY_OFF);
      statorelay[message.getBool()] = 0; // salvo in memoria stato relay
      return;
      }

      I NEED HELP!!! THANK YOU!

      If I was not clear please ask, sorry for my english

      posted in Development
      Marco Avallone
      Marco Avallone