Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
A

arduino_89_89

@arduino_89_89
About
Posts
14
Topics
6
Shares
0
Groups
0
Followers
0
Following
2

Posts

Recent Best Controversial

  • Multiple Sketch
    A arduino_89_89

    Hello everyone, I would need a Sketch with 4 magnetic door sensors, 2 relays and 1 ds18b20.

    Development

  • New Sketch
    A arduino_89_89

    Fit a sketch found on the net, for mysensor

    Development

  • Relay actuator with button and sensor air humidity?
    A arduino_89_89

    Sensor DHT-11

    Hardware

  • Relay actuator with button and sensor air humidity?
    A arduino_89_89

    relay with button and without gateway, and sensor air and humidity.
    How do I insert the temperature sensor skech, within this:

    #define MY_DEBUG                               // Enable debug prints to serial monitor
    
    #define MY_RADIO_NRF24                         // Enable and select radio type attached
    #define MY_NODE_ID 8
    
    
    #define MY_TRANSPORT_WAIT_READY_MS 5000        //set how long to wait for transport ready in milliseconds
    
    #include <MySensors.h>
    #include <Bounce2.h>
    
    #define RELAY_PIN  4      // Arduino Digital I/O pin number for relay 
    #define BUTTON_PIN  3     // 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
    
    Bounce debouncer = Bounce();
    int oldValue = 0;
    bool uplinkAvailable = true;
    bool state = false;
    bool requestState;
    bool firstStart = true;
    unsigned long uplinkCheckTime ;                // holder for uplink checks
    unsigned long uplinkCheckPeriod = 30*1000;     // time between checks for uplink in milliseconds
    unsigned long returnWait = 1500;               // how long to wait for return from controller in milliseconds
    MyMessage msg(CHILD_ID, V_STATUS);
    
    void setup(){
      pinMode(BUTTON_PIN, INPUT_PULLUP);           // Setup the button pin, Activate internal pull-up
      
      debouncer.attach(BUTTON_PIN);                // After setting up the button, setup debouncer
      debouncer.interval(5);
    
      pinMode(RELAY_PIN, OUTPUT);                 // set relay pin in output mode
      digitalWrite(RELAY_PIN, RELAY_OFF);         // Make sure relay is off when starting up
    }
    
    void presentation()  {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Relay & Button", "1.0");
    
      // Register all sensors to gw (they will be created as child devices)
      present(CHILD_ID, S_BINARY);
    }
    
    
    void loop(){
      if (firstStart) {                            // this code is only run once at startup
        Serial.println("First run started");
        if (request( CHILD_ID, V_STATUS)) {       // request the current state of the switch on the controller and check that an ack was received
          Serial.println("uplink available");
          wait (returnWait);                      //wait needed to allow request to return from controller
          Serial.print("controller state --- ");
          Serial.println(requestState);
          if (requestState != state) {           // check that controller is corectly showing the current relay state
            send(msg.set(state), false);         // notify controller of current state
          }
        }
        else {
          Serial.println("uplink not available");
          uplinkAvailable = false;               // no uplink established
          uplinkCheckTime = millis();
        }
        firstStart = false;                     // set firstStart flag false to prevent code from running again
      }
    
      debouncer.update();
      int value = debouncer.read();                               // Get the update value
      if (value != oldValue && value == 0) {                      // check for new button push
        state =  !state;                                          // Toggle the state
        digitalWrite(RELAY_PIN, state ? RELAY_ON : RELAY_OFF);    // switch the relay to the new state
        if (!send(msg.set(state), true)) {                        //Attempt to notify controller of changed state
          Serial.println("uplink not available");
          uplinkAvailable = false;                                // no uplink available
          uplinkCheckTime = millis();                             
        }
      }
     oldValue = value;
    
      if (!uplinkAvailable && (millis() - uplinkCheckTime > uplinkCheckPeriod) ) {       // test to see if function should be called
        uplinkCheck();                                                                  // call uplink checking function
      }
    
    }
    
    /*-------------------start of functions--------------------------*/
    
    void receive(const MyMessage &message) {
      if (message.type == V_STATUS) {                                   // check to see if incoming message is for a switch
        switch (message.getCommand()) {                                 // message.getCommand will give us the command type of the incomming message
          case C_SET:
     //message is a set command  from controller to update relay state
            state = message.getBool();                                  // get the new state
            digitalWrite(RELAY_PIN, state ? RELAY_ON : RELAY_OFF);      // switch relay to new state
            uplinkAvailable = true;                                     //  uplink established
            /*---- Write some debug info----*/
            Serial.print("Incoming change for sensor:");
            Serial.print(message.sensor);
            Serial.print(", New status: ");
            Serial.println(message.getBool());
            break;
          case C_REQ:                                               // message is a returning request from controller
            requestState = message.getBool();                       // update requestState with returning state
            break;
        }
      }
    }
    
    void uplinkCheck() {
      if (request( CHILD_ID, V_STATUS)) {         // request the current state of the switch on the controller and check that the request was succsessful
        Serial.println("uplink re-established");
        wait (returnWait);                        //wait needed to allow request to return from controller
        if (requestState != state) {              // check that controller is corectly showing the current relay state
          send(msg.set(state), false);            // notify controller of current state no ack
          uplinkAvailable = true;                 //  uplink established
        }
      }
      uplinkCheckTime = millis();                // reset the checktime
      Serial.println("uplinkchecktime reset");
    }
    
    Hardware

  • Problem with Domoticz
    A arduino_89_89

    0_1502270247458_Log.txt

    Domoticz

  • Problem with Domoticz
    A arduino_89_89

    0_1502269526374_Log.txt

    Domoticz

  • Problem with Domoticz
    A arduino_89_89

    It's too long.

    Domoticz

  • Problem with Domoticz
    A arduino_89_89

    How do I send it to you? It's too long.

    Domoticz

  • Problem with Domoticz
    A arduino_89_89

    But should I use watchdog? To reset nodes automatically every day?

    Domoticz

  • Problem with Domoticz
    A arduino_89_89

    I understand, but the only sensors that connect are: The temperature sensor and the gas sensor, which send periodic signals. My system is structured on 3 floors. The first floor has the Gateway, and off the first floor has a Node Repeater. Then the second floor has another Node Repeater and has 2 Relay Nodes. And finally the Third Floor with another repeater and 2 sensors, Gas and Temp / Hum.

    Domoticz

  • Problem with Domoticz
    A arduino_89_89

    Hi everyone, I wanted to know how ever whenever the PC reboots, I also change the com port. And why when I break the gateway, are the sensors no longer connected? It's okay to restart them all to let them read.

    Domoticz

  • Sesnsor Door and Relay
    A arduino_89_89

    Hi I combined the sketch of a door sensor to adapt it to a photoresist and added a relay. The relay in question only works once and then freezes everything.

    // Enable debug prints to serial monitor
    #define MY_DEBUG

    #define MY_NODE_ID 2
    #define MY_PARENT_NODE_ID 0
    #define MY_RADIO_NRF24
    #define MY_RF24_CHANNEL 1
    //#define MY_RADIO_RFM69

    #include <SPI.h>
    //#define MY_REPEATER_FEATURE
    #include <MySensors.h>
    #include <Bounce2.h>

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

    #define CHILD_ID_2 1
    #define BUTTON_PIN_2 2 // Arduino Digital I/O pin for button/reed switch
    // Change to V_LIGHT if you use S_LIGHT in presentation below
    MyMessage msg1(CHILD_ID_2, V_LIGHT_LEVEL);

    void before()
    {
    for (int sensor=1, pin=RELAY_3; 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()
    {
    pinMode(BUTTON_PIN_2, INPUT);
    digitalWrite(BUTTON_PIN_2, HIGH);

    }

    void presentation()
    {
    // Send the sketch version information to the gateway and Controller
    sendSketchInfo("Relay", "1.0");

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

    }

    void loop()
    {
    int value = digitalRead(BUTTON_PIN_2);
    send(msg1.set(value == HIGH ? 0 : 1));

    }

    void receive(const MyMessage &message)
    {
    // We only expect one type of message from controller. But we better check anyway.
    if (message.type==V_STATUS) {
    // Change relay state
    digitalWrite(message.sensor-1+RELAY_3, message.getBool()?RELAY_ON:RELAY_OFF);
    // Store state in eeprom
    saveState(message.sensor, message.getBool());
    // Write some debug info

    }
    }

    Can someone help me?

    Troubleshooting

  • New Sensor Domoticz
    A arduino_89_89

    I followed the Mq2 Sensor Tutorial, but I'm only out of the kids and not on devices. Instead, for the rain sensor I did not find anything.

    Development

  • New Sensor Domoticz
    A arduino_89_89

    Hi everyone, I have two sensors I can not configure them in Domoticz.
    Mq2 gpl and rain sensor Mhrd. How can I do?

    Development
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular