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
R

rodaman

@rodaman
About
Posts
9
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • My experiences with MySensors
    R rodaman

    You are right. Mysensors based on NRF is dead. I started my adventure with home automation based on mysensors but gradually I replaced all my sensor with Wemos. Now everything work fine. Sorry mysensors...

    My Project

  • 💬 Building a Serial Gateway
    R rodaman

    After 3 years of using RADIO_RF24 i replaced my all sensors with espeasy. It was just big battle with lost transmissions, disconnections, every day problems. Now for many days silence...Everything works.I still use mysensors in diferrent setup but NRF Radio is asking for trouble.

    Announcements

  • 💬 Door, Window and Push-button Sensor
    R rodaman

    @rodaman
    Hi,
    Here is a sketch for multi buttons (no relays, no repeated parts of code for each buttons) just enter number of buttons and first digital pin where buttons are attached.
    Thanks to @hek for help...

    /**
       The MySensors Arduino library handles the wireless radio link and protocol
       between your home built sensors/actuators and HA controller of choice.
       The sensors forms a self healing radio network with optional repeaters. Each
       repeater and gateway builds a routing tables in EEPROM which keeps track of the
       network topology allowing messages to be routed to nodes.
    
       Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       Copyright (C) 2013-2015 Sensnology AB
       Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
    
       Documentation: http://www.mysensors.org
       Support Forum: http://forum.mysensors.org
    
       This program is free software; you can redistribute it and/or
       modify it under the terms of the GNU General Public License
       version 2 as published by the Free Software Foundation.
    
     *******************************
    
       DESCRIPTION
    
       Simple binary switch example updated  for multi switches
       Connect buttons or door/window reed switches between
       digitial I/O choosen pin  (FIRST_PIN below) and GND.
       http://www.mysensors.org/build/binary
    */
    
    
    // Enable debug prints to serial monitor
    //#define MY_DEBUG
    
    // Enable and select radio type attached
    //#define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    #define MY_GATEWAY_SERIAL
    
    //#include <SPI.h>
    #include <MySensors.h>
    #include <Bounce2.h>
    
    #define FIRST_PIN  2  // Arduino Digital I/O pin for button/reed switch
    #define noButtons 6
    
    
    Bounce debouncer[noButtons] = Bounce();
    
    int oldValue[noButtons];
    int value;
    MyMessage msg[noButtons];
    
    void setup() {
    
      for (int i = 0; i < noButtons; i++) {
    
        oldValue[i] = -1;
        
        msg[i].sensor = i;                                   // initialize messages
        msg[i].type = V_TRIPPED; //
        pinMode(i + FIRST_PIN, INPUT_PULLUP);
        digitalWrite(i + FIRST_PIN, HIGH);
      
        debouncer[i] = Bounce();                        // initialize debouncer
        debouncer[i].attach(i + FIRST_PIN);
        debouncer[i].interval(3);
      }
    }
    
    void presentation() {
      sendSketchInfo("Doors", "1.0");
      for (int i = 0; i < noButtons; i++)
        present(i, S_DOOR);                               // present sensor to gateway
    }
    
    
    //  Check if digital input has changed and send in new value
    void loop()
    {
      for (int i = 0; i < noButtons; i++) {
        debouncer[i].update();
    
        value = debouncer[i].read();
        if (value != oldValue[i]) {
        // Send in the new value
          send(msg[i].set(value == HIGH ? 1 : 0));
          oldValue[i] = value;
        }
     }
    }
    
    
    Announcements

  • 💬 Door, Window and Push-button Sensor
    R rodaman

    @hek said in 💬 Door, Window and Push-button Sensor:

    pinMode(i + FIRST_PIN, INPUT_PULLUP);

    Big Thanks!
    I have changed all array parts in setup in the same manner like above and it works :-)

    Announcements

  • 💬 Door, Window and Push-button Sensor
    R rodaman

    @hek
    I have changed

    pinMode(buttonPin[i + FIRST_PIN], INPUT_PULLUP);
    

    to

    pinMode(buttonPin[i + FIRST_PIN], INPUT);
    

    thanks, but sadlly still does not work...

    Announcements

  • 💬 Door, Window and Push-button Sensor
    R rodaman

    @hek
    That part was in original sketch for establish internal pullup as I understand. I used array to do it for each pins.

    Announcements

  • 💬 Door, Window and Push-button Sensor
    R rodaman

    @mfalkvidd
    thank you, i hope will be good soul who fix my sketch itself to work... :-)

    Announcements

  • 💬 Door, Window and Push-button Sensor
    R rodaman

    Hi,
    I rewrite sketch for doors/window/buttons to work with multiple buttons (no rellays) .It shows up in Domoticz but it did not change status buttons if pressed.
    Can someone look for the skech what I am doing wrong

    /**
      The MySensors Arduino library handles the wireless radio link and protocol
      between your home built sensors/actuators and HA controller of choice.
      The sensors forms a self healing radio network with optional repeaters. Each
      repeater and gateway builds a routing tables in EEPROM which keeps track of the
      network topology allowing messages to be routed to nodes.
    
      Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
      Copyright (C) 2013-2015 Sensnology AB
      Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
    
      Documentation: http://www.mysensors.org
      Support Forum: http://forum.mysensors.org
    
      This program is free software; you can redistribute it and/or
      modify it under the terms of the GNU General Public License
      version 2 as published by the Free Software Foundation.
    
    *******************************
    
      DESCRIPTION
    
      Simple binary switch example updated  for 2 switches
      Connect button or door/window reed switch between
      digitial I/O pin 3 (BUTTON_PIN below) and GND.
      http://www.mysensors.org/build/binary
    */
    
    
    // Enable debug prints to serial monitor
    //#define MY_DEBUG
    
    // Enable and select radio type attached
    //#define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    #define MY_GATEWAY_SERIAL
    
    //#include <SPI.h>
    #include <MySensors.h>
    #include <Bounce2.h>
    
    #define FIRST_PIN  8  // Arduino Digital I/O pin for button/reed switch
    #define noButtons 4
    const int buttonPin[noButtons];
    
    Bounce debouncer[noButtons] = Bounce();
    
    int oldValue[noButtons];
    
    MyMessage msg[noButtons];
    
    void setup() {
    
     for (int i = 0; i < noButtons; i++) {
    
       msg[i].sensor = i;                                   // initialize messages
       msg[i].type = V_TRIPPED; //
    
       pinMode(buttonPin[i + FIRST_PIN], INPUT_PULLUP);
       digitalWrite(buttonPin[i + FIRST_PIN], HIGH);
       debouncer[i] = Bounce();                        // initialize debouncer
       debouncer[i].attach(buttonPin[i + FIRST_PIN]);
       debouncer[i].interval(30);
     }
    }
    
    void presentation() {
     sendSketchInfo("Doors", "1.0");
     for (int i = 0; i < noButtons; i++)
       present(i, S_DOOR);                               // present sensor to gateway
    
    
    }
    
    
    //  Check if digital input has changed and send in new value
    void loop()
    {
     for (int i = 0; i < noButtons; i++) {
       debouncer[i].update();
    
       int value = debouncer[i].read();
       if (value != oldValue[i]) {
    
         // Send in the new value
         send(msg[i].set(value == HIGH ? 1 : 0));
         oldValue[i] = value;
       }
    
     }
    }
    
    Announcements

  • DS18B20 ans SHT31-D show up as combined sensors on Domoticz
    R rodaman

    @palande-vaibhav
    Sorry for the dumb question. How do you achieved different #numbering in Values? I have all my Ds18b20 sensors with #1 number.

    Troubleshooting
  • Login

  • Don't have an account? Register

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