Navigation

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

    mikeones

    @mikeones

    3
    Reputation
    37
    Posts
    2279
    Profile views
    1
    Followers
    0
    Following
    Joined Last Online

    mikeones Follow

    Best posts made by mikeones

    • RE: Binary sensor expanded help

      I have been using this sketch for about a week now and it is working fine for my needs.

      // Simple binary switch example 
      // Connect button or door/window reed switch between 
      // digitial I/O pin 3 (ZONE_1 below) and GND.
      
      #include <Sensor.h>
      #include <SPI.h>
      #include <EEPROM.h>  
      #include <RF24.h>
      #include <Bounce2.h>
      
      #define ZONE_1  14  // Arduino Digital I/O pin for button/reed switch
      #define NUMBER_OF_ZONES 6
      
      Sensor gw;
      Bounce debouncer_1 = Bounce();
      Bounce debouncer_2 = Bounce();
      Bounce debouncer_3 = Bounce();
      Bounce debouncer_4 = Bounce();
      Bounce debouncer_5 = Bounce();
      Bounce debouncer_6 = Bounce();
      
      int oldValue_1 =-1;
      int oldValue_2 =-1;
      int oldValue_3 =-1;
      int oldValue_4 =-1;
      int oldValue_5 =-1;
      int oldValue_6 =-1;
      
      void setup()  
      {  
        gw.begin();
        for (int i=0; i<NUMBER_OF_ZONES;i++) {
         // Setup the button
      	pinMode(ZONE_1+i,INPUT);
      	// Activate internal pull-up
      	digitalWrite(ZONE_1+i,HIGH);
      	
      	// After setting up the button, setup debouncer
      	switch (1+i) {
      	  case 1:
      		debouncer_1.attach(ZONE_1);
      		debouncer_1.interval(5);
      		break;
      	  case 2:
      		debouncer_2.attach(ZONE_1+i);
      		debouncer_2.interval(5);
      		break;
      	  case 3:
      		debouncer_3.attach(ZONE_1+i);
      		debouncer_3.interval(5);
      		break;
      	  case 4:
      		debouncer_4.attach(ZONE_1+i);
      		debouncer_4.interval(5);
      		break;
      	  case 5:
      		debouncer_5.attach(ZONE_1+i);
      		debouncer_5.interval(5);
      		break;
      	}
      	
      	// 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 below.
      	gw.sendSensorPresentation(ZONE_1+i, S_DOOR);
      	delay(1000);
        }
      }
      
      
      //  Check if digital input has changed and send in new value
      void loop() 
      {
        for (int i=0; i<NUMBER_OF_ZONES;i++) {
      	int num = 1+i;
      	// Get the update value
      	switch (num) {
      	  case 1:
      		{
      		  debouncer_1.update();
      		  int value_1 = debouncer_1.read();
      		  if (value_1 != oldValue_1) {
      		   // Send in the new value
      		   gw.sendVariable(ZONE_1+i, V_TRIPPED, value_1==HIGH ? "1" : "0");  // Change to V_LIGHT if you use S_LIGHT in presentation above
      		   oldValue_1 = value_1;
      		  }
      		  break;
      		}
      	  case 2:
      		{
      		  debouncer_2.update();
      		  int value_2 = debouncer_2.read();
      		  if (value_2 != oldValue_2) {
      		   // Send in the new value
      		   gw.sendVariable(ZONE_1+i, V_TRIPPED, value_2==HIGH ? "1" : "0");  // Change to V_LIGHT if you use S_LIGHT in presentation above
      		   oldValue_2 = value_2;
      		  }
      		  break;
      		}
      	  case 3:
      		{
      		  debouncer_3.update();
      		  int value_3 = debouncer_3.read();
      		  if (value_3 != oldValue_3) {
      		   // Send in the new value
      		   gw.sendVariable(ZONE_1+i, V_TRIPPED, value_3==HIGH ? "1" : "0");  // Change to V_LIGHT if you use S_LIGHT in presentation above
      		   oldValue_3 = value_3;
      		  }
      		  break;
      		}
      	  case 4:
      		{
      		  debouncer_4.update();
      		  int value_4 = debouncer_4.read();
      		  if (value_4 != oldValue_4) {
      		   // Send in the new value
      		   gw.sendVariable(ZONE_1+i, V_TRIPPED, value_4==HIGH ? "1" : "0");  // Change to V_LIGHT if you use S_LIGHT in presentation above
      		   oldValue_4 = value_4;
      		  }
      		  break;
      		}
      	  case 5:
      		{
      		  debouncer_5.update();
      		  int value_5 = debouncer_5.read();
      		  if (value_5 != oldValue_5) {
      		   // Send in the new value
      		   gw.sendVariable(ZONE_1+i, V_TRIPPED, value_5==HIGH ? "1" : "0");  // Change to V_LIGHT if you use S_LIGHT in presentation above
      		   oldValue_5 = value_5;
      		  }
      		  break;
      		}
      	  case 6:
      		{
      		  debouncer_6.update();
      		  int value_6 = debouncer_6.read();
      		  if (value_6 != oldValue_6) {
      		   // Send in the new value
      		   gw.sendVariable(ZONE_1+i, V_TRIPPED, value_6==HIGH ? "1" : "0");  // Change to V_LIGHT if you use S_LIGHT in presentation above
      		   oldValue_6 = value_6;
      		  }
      		break;
      		}
      	}
        }
      }
      posted in Development
      mikeones
      mikeones
    • RE: Data collection

      You may look at the node js controller. It has database support. https://github.com/mysensors/Arduino/tree/master/NodeJsController Also check out the controller section of the form. http://forum.mysensors.org/category/3/controllers

      posted in My Project
      mikeones
      mikeones
    • RE: Open Source Home Automation (Raspberry)

      I have been using agocontrol on my RPI with pretty good results. The few issues I posted about in the agocontrol form are likely user error on my part. I think ago is written in C and runs well on my PI. I am currently running 4 nodes with about 22 child devices. They have implemented just about all the device types which is a plus. I am running temperature, humidity and distance sensors along with relays and reed switches. Communication and stability have been solid so far.

      I recommend agocontrol to anyone wanting to get some sensor nodes up and talking to a control that don't have a vera. They have x86 packages also so you are not limited to only running on a PI.

      posted in Controllers
      mikeones
      mikeones

    Latest posts made by mikeones

    • RE: Automated garage door

      @martinhjelmare

      V_UP and V_DOWN are a great suggestion. I use a distance sensor on my garage door for the state. This will let me know when a button push occurred or a remote open was used.

      posted in My Project
      mikeones
      mikeones
    • RE: Relay Outlet + Button + OpenHab + Tasker + Android Wear = Freaking Awesome!

      I like that you were able to keep all the electronics inside the gang box. I would like to do something similar for my light switches but I not worked out how to power the components via the mains. Stuffing a charger in the box seems like overkill but it is one solution.

      Any other options for powering that node? Any safety issues with having a charge stuffed in a gang box and left inside the drywall?

      Thanks in advance

      posted in My Project
      mikeones
      mikeones
    • RE: smoke/lightlevel/humidty/temp/smoketest

      Is that a hardwired smoke detector? I am looking for a hardwired solution that utilizes/runs off the power from a hardwired connection. Not sure if I would have access to 3.3 volts to run the Pro Mini and radio.

      posted in My Project
      mikeones
      mikeones
    • RE: What is wrong with this node?

      If you have the hardware, hook up a sniffer and see what is happening with wireshark at the network layer. I had similar issues and found with the help of the sniffer, my node was having resend/timeout issues even being a couple of feet away. Playing with the channel and data rate, I was able to get a better signal and those st fail messages have stopped. This node is normally in the garage so the interference I had on the default channel was causing issues. Use the sniffer to see what is happening at the network layer.

      posted in Troubleshooting
      mikeones
      mikeones
    • RE: Multi Binary Switches

      It forces a status update at a predefined interval.

      Alarm.timerRepeat(720, updateState); // update relay status every 2 hrs
      
      posted in My Project
      mikeones
      mikeones
    • RE: Multi Binary Switches

      Here is one example with a few extras.

      // Simple binary switch example 
      // Connect button or door/window reed switch between 
      // digitial I/O pin 3 (BUTTON_PIN below) and GND.
      
      #include <MySensor.h>
      #include <SPI.h>
      #include <Bounce2.h>
      #include <Time.h>        //http://playground.arduino.cc/Code/Time
      #include <TimeAlarms.h>  //http://playground.arduino.cc/Code/Time
      
      MySensor gw;
      
      #define RADIO_ID 12
      #define noReeds 5
      const int BUTTON_PIN[] = {14, 15, 16, 17, 18};            // Arduino Digital I/O pin for button/reed switch, A0 - A4
      boolean reedState[] = {HIGH, HIGH, HIGH, HIGH, HIGH};
      
      
      Bounce debouncer[noReeds];
      MyMessage msg[noReeds];
      
      void setup(){
        Serial.println("Starting setup" );
        gw.begin(NULL, RADIO_ID, true);  //stattc RADIO_ID an enable repeater
        Alarm.delay(250);
        gw.sendSketchInfo("Alarm Pannel", "1.0");
        Alarm.delay(250);
        gw.requestTime(receiveTime);
        // initialize Relays with corresponding buttons
        for (int i = 0; i < noReeds; i++){
          msg[i].sensor = i;			// initialize messages
          msg[i].type = V_TRIPPED;
          debouncer[i] = Bounce();		// initialize debouncer
          debouncer[i].attach(BUTTON_PIN[i]);
          debouncer[i].interval(5);
          // Setup the button
          pinMode(BUTTON_PIN[i],INPUT);
          // Activate internal pull-up
          digitalWrite(BUTTON_PIN[i],HIGH);
          gw.present(i, S_DOOR);		// present sensor to gateway
          Serial.print("setup for switch: ");
          Serial.print(BUTTON_PIN[i]);
          Serial.println(" complete" );
          Alarm.timerRepeat(720, updateState); // update relay status every 2 hrs
          Alarm.delay(250);
        }
        Serial.println("Setup complete" );
      }
      
      
      //  Check if digital input has changed and send in new value
      void loop() 
      {
        gw.process();
        for (int i = 0; i < noReeds; i++){
          debouncer[i].update();
          // Get the update value
          int value = debouncer[i].read();
          if (value != reedState[i]) {
             // Send in the new value
             gw.send(msg[i].set(value==HIGH ? 1 : 0), false);
             reedState[i] = value;
             Serial.print("updating state for swicth: ");
             Serial.print(BUTTON_PIN[i]);
             Serial.print(" state: ");
             Serial.println(reedState[i]);
          }
        }
      }
      
      void updateState(){
        Serial.println("Start state info");
        for (int i = 0; i < noReeds; i++)
        {
            Serial.print("sending update for switch: ");
            Serial.println(BUTTON_PIN[i]);
            gw.present(i, S_DOOR);
            Alarm.delay(250);
            //MyMessage msg(relayPin[pin],V_LIGHT);
            gw.send(msg[i].set(reedState[i]), false); // Send last state from eprom to GW
            Alarm.delay(250);
        }
      }
      
      // This is called when a new time value was received
      void receiveTime(unsigned long time) {
        setTime(time);
      }```
      posted in My Project
      mikeones
      mikeones
    • RE: Motion & Relay Sensor issue

      You should check if the value changed and only send updates when true. Something like this.

      if (lastTripped != tripped ) {
      posted in Troubleshooting
      mikeones
      mikeones
    • RE: Interfacing nasty stuff with MySensors

      That usb housing is pretty sweet. A nice shell for a PIR and Temp sensors.

      posted in General Discussion
      mikeones
      mikeones
    • RE: Data collection

      You may look at the node js controller. It has database support. https://github.com/mysensors/Arduino/tree/master/NodeJsController Also check out the controller section of the form. http://forum.mysensors.org/category/3/controllers

      posted in My Project
      mikeones
      mikeones
    • RE: Can't tell if time is set with TimeAwareSensor Sketch

      Thanks, changing type from 4 to 1 fixed it.

      posted in Troubleshooting
      mikeones
      mikeones