Navigation

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

    Posts made by punter9

    • RE: Solar Powered Soil Moisture Sensor

      @flopp

      guys seriously this is just yet another reason to write your reporting interval based on battery voltage and time and not on time alone.

      You are using extremely cheap systems with cheap batteries of unknown age that are likely very prone to incur reduced capacity over shorter times and memory from discharge cycles.

      See the posts above. This really is one of the greatest ideas I have seen for monitoring, just needs a tweak

      With these findings I would set a floor voltage around 1-1.1 V for the arduino to go into sleep mode (find your own floor voltage by looking at your sleep discharge rate and length of night time).

      posted in My Project
      punter9
      punter9
    • RE: Solar Powered Soil Moisture Sensor

      I have a couple soil sensors running with simple bolts in the ground. No two sensors will read the same in the same soil, but that is because they are just a relative setup not an accurate setup. Doing what is recommended above is necessary. Determine what % correlates to watering time on the plants. Once this is done it is set and forget.

      Also, on your batteries
      "The phenomenon itself is very real. If a NiCd battery is repeatedly charged after it has only been partially discharged it will develop a lower voltage and a lower capacity. Fortunately, this effect is reversible by conditioning NiCds."

      So I vote to help your poor cheap lamp batteries out by writing logic into your arduino that varies by battery voltage. You can write it in ranges

      battery > X volts report every Y minutes
      battery > Z volts report every P minutes
      battery > .....etc

      also to keep your battery in good shape you may consider every so many days ( 2 - 5 ) writing logic that says
      every Q days report every 20 seconds (or another interval that will drain battery) until battery voltage = min
      then
      sleep until battery voltage = max

      posted in My Project
      punter9
      punter9
    • RE: Solar Powered Soil Moisture Sensor

      ha you are on it! caught me editing!

      anyways I love your idea, I can guarantee I am looking for these little lights to be on sale every time I go out. This maxes out the clever scale.

      posted in My Project
      punter9
      punter9
    • RE: Solar Powered Soil Moisture Sensor

      @flopp
      sure is, It looks like this sketch already has already picked a set single point sleep time that achieved the discharge gradient being less than the charge gradient looking at the angles on the 7 day graph.

      My question is why wouldn't you write an algorithm for your sleep setting so you don't have to mess with it if you get a cloudy week etc? You have variable charge gradients depending on weather so why not have a simple variable discharge gradient?

      A simple one would be case A - sunny day discharge gradient B- very cloudy day discharge gradient C- emergency charge/top off battery

      you could write an equation based off your existing data but honestly you probably wouldn't get much out of it past the simple set listed above that cover 99% of conditions you will see.

      posted in My Project
      punter9
      punter9
    • RE: Solar Powered Soil Moisture Sensor

      side thought

      why not write your sleep setting as a variable on the arduino side that is dependent on battery voltage?

      if v>(full charge) sleep x hours
      if v>(half charge) sleep for y hours
      if v<(close to terminal voltage) sleep for z hours/days

      posted in My Project
      punter9
      punter9
    • RE: Solar Powered Soil Moisture Sensor

      this is genious

      posted in My Project
      punter9
      punter9
    • Monitor if an outlet has power - send email

      I have a co-worker who wants to monitor the status of their GFCI outlet that the sump pump is hooked to. Occasionally it will trip when they use their smoker or something and they won't notice until water backs up. What they would like is a simple monitor that would send them an email when there is no power. So I am tossing around some ideas

      • current meter and a light bulb - battery pack for node power (expensive)
      • LED on all the time and light meter taped together (blocking outside light). If value goes to 0 email is sent (cheap but I wonder how reliable)

      They do not currently have a domoticz setup so I would have to get a pi to get this going, adding expense. If anyone has some very simple suggestions I am missing I would really appreciate it!

      posted in General Discussion
      punter9
      punter9
    • RE: Raspberry Pi Zero $5

      @Zeph

      that has nothing to do with the hardware at all, just a shoddy supply and demand scenario. If they had called me I would have said it is a specialty product for a niche more advanced user than typical and said small quantity too.

      link text

      I am personally very excited because we know that the quality of these products will be very high and consistent, which is very unlike some of my purchases for components on ebay

      posted in General Discussion
      punter9
      punter9
    • RE: Raspberry Pi Zero $5

      actually the more I look at this the more this really needs to be considered, cost wise it is right there with arduinos by the time you add in ancillary stuff. Reliability would be top notch too

      posted in General Discussion
      punter9
      punter9
    • RE: Raspberry Pi Zero $5

      this would be all kinds of awesome

      posted in General Discussion
      punter9
      punter9
    • RE: 110v-230v AC to Mysensors PCB board

      thanks for the update on the resettable fuses! Another rookie ?. I ordered 0.4A fuses since the 0.3A are sold out. Is this a classic dumb move thinking that 0.1A is no big deal?

      posted in Hardware
      punter9
      punter9
    • RE: 110v-230v AC to Mysensors PCB board

      thanks! one more question. I am really striking out finding resettable fuses for 120v US application. Anybody conquer this mole hill?

      posted in Hardware
      punter9
      punter9
    • RE: Safe In-Wall AC to DC Transformers??

      this doesn't mention specifically but a good read

      http://lygte-info.dk/review/Power Mains to 5V 0.6A Hi-Link HLK-PM01 UK.html

      posted in Hardware
      punter9
      punter9
    • RE: 💬 In Wall AC/DC Pcb for MySensors

      hey any suggestions for US spec hardware?

      posted in OpenHardware.io
      punter9
      punter9
    • RE: 110v-230v AC to Mysensors PCB board

      I really like that this uses the hlk power supply. Any versions of this floating around that instead of a relay do a digital/analog pinout for you to connect sensors to? That would be like a plain vanilla do anything board with safe power

      posted in Hardware
      punter9
      punter9
    • RE: ioBroker = Home automation/Node ALL in ONE/ for noobs https +Let's encrypt/MQTT/Node Red/

      you know call me crazy but I have been thinking it is a bit surprising a simple windows/linux/etc GUI has not been made for mysensors. I know I have enjoyed learning to code but it would be nice at times to have a drop down

      select board type
      select devices (dht22, relay,etc)
      select pin device is on
      add option for repeater
      add option for sleep
      add option for wake every xxx minutes and take reading
      hit send

      posted in My Project
      punter9
      punter9
    • RE: "Error sending switch command, check device/hardware !"

      Adding a capacitor to the radio is what I needed to do! Made all the difference in the world!

      posted in Troubleshooting
      punter9
      punter9
    • "Error sending switch command, check device/hardware !"

      I have a mysensors relay node that I have been using acting very oddly. If I unplug the node and plug it back it it will work as it should a few times (on/off). After I cycle it about 3 times it stops working and instead I get the following error "Error sending switch command, check device/hardware !"

      If I unplug it, it works again about 3 times then right back into this pattern of behavior. Any ideas what to do with this?

      The sketch is unmodified from mysensors. I thought it may be a range issue so I took the gateway close to the lamp and I have the same issue.

      Domoticz V2.3530
      Raspbery PI model B
      Arduino Nano usb gateway with NRF24L01+
      Mysensors V1.5

      posted in Troubleshooting
      punter9
      punter9
    • RE: This should be a simple one! Water level test (not on constantly)

      @mfalkvidd said:

      thanks! That makes a ton of sense. These forums are awesome, I really appreciate everybody

      posted in Troubleshooting
      punter9
      punter9
    • RE: This should be a simple one! Water level test (not on constantly)

      Thanks for the help!

      I may be wrong but I believe that only sleeps the radio but wouldn't shut down the digital pins in the water (the electrolysis). I'm also a noob so that may be way off lol.

      I have a relay attached to it as well so I really need it to be running. With the help from this forum I am using digital pins to power my moisture sensors and turning them on and off to prevent electrolysis (take a reading on analog pin). Works great, I'd like a similar setup here if possible

      posted in Troubleshooting
      punter9
      punter9
    • This should be a simple one! Water level test (not on constantly)

      Ok I am working away steadily at my automatic garden. I could use some help figuring out how to power up, read, and then power down my water level sensors.

      Currently I have 4 bolts in a 5 gallon bucket for water (and a pump). The bottom bolt is ground and the top 3 are for various water level indications. Currently I have it set up to read from digital pins but these are on all the time and this will cause significant amounts of electrolysis. What I would like to do is utilize millis and pin settings to turn the pins on, take a reading, and turn them off. Due to the nature of my operation I only need to do this about 4 times a day.

      If anyone could help me out with my code I would really appreciate it!

      
      #include <MySensor.h>
      #include <SPI.h>
      #include <Bounce2.h>
      
      #define CHILD_ID3 3
      #define BUTTON_PIN1  3  // Arduino Digital I/O pin for button/reed switch
      #define CHILD_ID4 4
      #define BUTTON_PIN2  4  // Arduino Digital I/O pin for button/reed switch
      #define CHILD_ID5 5
      #define BUTTON_PIN3  5  // Arduino Digital I/O pin for button/reed switch
      
      long previousMillis = 0;
      long interval = (10000); //delay betweein readings - 1000 is 1 second
      
      MySensor gw;
      Bounce debouncer = Bounce(); 
      int oldValue1=-1;
      int oldValue2=-1;
      int oldValue3=-1;
      
      MyMessage msg1(CHILD_ID3,V_TRIPPED), msg2(CHILD_ID4,V_TRIPPED),msg3(CHILD_ID5,V_TRIPPED); // Change to V_LIGHT if you use S_LIGHT in presentation below
      
      void setup()  
      {  
        gw.begin();
      
       gw.sendSketchInfo("3 Binary Switches", "1.0");
        pinMode(BUTTON_PIN1,INPUT);
        pinMode(BUTTON_PIN2,INPUT);
        pinMode(BUTTON_PIN3,INPUT);
        
        // Activate internal pull-up
        digitalWrite(BUTTON_PIN1,HIGH);
        digitalWrite(BUTTON_PIN2,HIGH);
        digitalWrite(BUTTON_PIN3,HIGH);
      
        gw.present(CHILD_ID3, S_DOOR);// Register binary input sensor to gw (they will be created as child devices)
        gw.present(CHILD_ID4, S_DOOR); // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage.
        gw.present(CHILD_ID5, S_DOOR);  // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.  
      }
      
      void loop() 
      {
        unsigned long currentMillis = millis();     
      
        if (currentMillis - previousMillis > interval) {
        debouncer.update();
        int value1 = debouncer.read();
        int value2 = debouncer.read();
        int value3 = debouncer.read();
        value1 = digitalRead(BUTTON_PIN1);
        value2 = digitalRead(BUTTON_PIN2);
        value3 = digitalRead(BUTTON_PIN3);
        gw.send(msg1.set(value1==HIGH ? 1 : 0));// Send in the new value
        oldValue1 = value1;
        gw.send(msg2.set(value2==HIGH ? 1 : 0));// Send in the new value
        oldValue2 = value2;
        gw.send(msg3.set(value3==HIGH ? 1 : 0));// Send in the new value
        oldValue3 = value3; 
      } 
      }
      
      posted in Troubleshooting
      punter9
      punter9
    • RE: Mysensors Thermostat

      seems as easy as a temp sensor and a couple relays.......now making a neat looking virtual display to use.....

      posted in Development
      punter9
      punter9
    • RE: Question about code and electrolysis

      Ok, I decided for my needs all I really need to do is be able to turn power on and off so I have written code to utilize the digital pins as a power source, and continue with the analog read. This should extend the life of my sensors since I only need to get a reading about 4 times a day.

      Would anyone mind looking over this code and make sure it is actually limiting electrolysis as I intend? I am still learning here. Thanks for all the help so far!

      The way I have it set up at the moment is to have the power(vcc) come from the digital pin and then tie the ground to the common ground so as to not tie up more digital pins. Will this work as intended or do I need to also have a dedicated digital pin written low for each sensor?

      #include <SPI.h>
      #include <MySensor.h>
      
      #define ANALOG_INPUT_SOIL_SENSOR1 A0
      #define CHILD_ID1 0 // Id of the sensor child
      #define ANALOG_INPUT_SOIL_SENSOR2 A1
      #define CHILD_ID2 1 // Id of the sensor child
      
      
      long previousMillis = 0;
      long interval = (10000); //delay betweein readings - 1000 is 1 second 
      
      MySensor gw;
      MyMessage msg1(CHILD_ID1, V_HUM),msg2(CHILD_ID2, V_HUM);
      int soilPower1 = 1; //digital pin to get power from
      int soilPower2 = 2; //digital pin to get power from
      
      void setup()
      
      {
        gw.begin();
        gw.sendSketchInfo("Soil Moisture Sensor - analog", "1.0"); // Send the sketch version information to the gateway and Controller
        pinMode(ANALOG_INPUT_SOIL_SENSOR1, INPUT);// sets the soil sensor analog pin as input
        pinMode(ANALOG_INPUT_SOIL_SENSOR2, INPUT);
        gw.present(CHILD_ID1, S_HUM);// Register all sensors to gw (they will be created as child devices)
        gw.present(CHILD_ID2, S_HUM);
        pinMode(soilPower1,OUTPUT);
        pinMode(soilPower2,OUTPUT); 
      }
      
      void loop()
      
      {
        unsigned long currentMillis = millis();
        digitalWrite(soilPower1,LOW);
        digitalWrite(soilPower2,LOW);
        
        if (currentMillis - previousMillis + 500 > interval) {
          digitalWrite(soilPower1,HIGH);
          digitalWrite(soilPower2,HIGH);
        }
      
        if (currentMillis - previousMillis > interval) {  
          int soilValue1 = analogRead(ANALOG_INPUT_SOIL_SENSOR1);// Read analog soil value
          int soilValue2 = analogRead(ANALOG_INPUT_SOIL_SENSOR2);
          previousMillis = currentMillis;  
          Serial.println(soilValue1);
          Serial.println(soilValue2);
          gw.send(msg1.set(constrain(map(soilValue1, 1023, 250, 0, 100), 0, 100)));
          gw.send(msg2.set(constrain(map(soilValue2, 1023, 250, 0, 100), 0, 100)));
          digitalWrite(soilPower1,LOW);
          digitalWrite(soilPower2,LOW);
        }
      }
      
      posted in Troubleshooting
      punter9
      punter9
    • RE: Question about code and electrolysis

      ah this makes sense. As long as these are connected to my voltage supply there will be this issue. I need to hook it to a controllable source such as a digital pin to get controlled voltage.

      I am learning here, but this seems to me the steps to the most electrolysis resistance.

      Base - 2 bolts in soil with an analog reading going to arduino, power and ground to power supply. Very high electrolysis

      1.) implement a digital pin as the power source - write high, wait, take analog reading, write low

      2.) implement a voltage dividing circuit. add resistor to one side of circuit, use sensor as other side, take analog reading between the two

      3.) reverse polarity each reading - write digital pin 1 high, digital pin 2 low, take analog reading. Next time do the inverse.

      Does this all seem correct? I really appreciate your help and references on this, I am really learning a ton here.

      posted in Troubleshooting
      punter9
      punter9
    • RE: Question about code and electrolysis

      well I just moved it inside the if statement to make sure. If this doesn't do what I am hoping it does please chime in! Thanks.

      #include <SPI.h>
      #include <MySensor.h>
      
      #define ANALOG_INPUT_SOIL_SENSOR1 A0
      #define CHILD_ID1 0 // Id of the sensor child
      #define ANALOG_INPUT_SOIL_SENSOR2 A1
      #define CHILD_ID2 1 // Id of the sensor child
      
      
      long previousMillis = 0;
      long interval = (10000); //1000 is 1 second 
      
      MySensor gw;
      MyMessage msg1(CHILD_ID1, V_HUM),msg2(CHILD_ID2, V_HUM);
      int lastSoilValue1 = -1;
      int lastSoilValue2 = -1;
      
      void setup()
      
      {
        gw.begin();
        gw.sendSketchInfo("Soil Moisture Sensor - analog", "1.0"); // Send the sketch version information to the gateway and Controller
        pinMode(ANALOG_INPUT_SOIL_SENSOR1, INPUT);// sets the soil sensor analog pin as input
        pinMode(ANALOG_INPUT_SOIL_SENSOR2, INPUT);
        gw.present(CHILD_ID1, S_HUM);// Register all sensors to gw (they will be created as child devices)
        gw.present(CHILD_ID2, S_HUM);
      }
      
      void loop()
      
      {
        unsigned long currentMillis = millis();
        
        if (currentMillis - previousMillis > interval) {
          int soilValue1 = analogRead(ANALOG_INPUT_SOIL_SENSOR1);// Read analog soil value
          int soilValue2 = analogRead(ANALOG_INPUT_SOIL_SENSOR2);
          previousMillis = currentMillis;  
          Serial.println(soilValue1);
          Serial.println(soilValue2);
          gw.send(msg1.set(constrain(map(soilValue1, 1023, 250, 0, 100), 0, 100)));
          gw.send(msg2.set(constrain(map(soilValue2, 1023, 250, 0, 100), 0, 100)));
          lastSoilValue1 = soilValue1;
          lastSoilValue2 = soilValue2;
        }
      }
      
      posted in Troubleshooting
      punter9
      punter9
    • Question about code and electrolysis

      I am writing code to read 2 analog moisture sensors that are subject to electrolysis. I am using millis as a timer to have it only read on set intervals. I currently have this code outside the millis function.

      unsigned long currentMillis = millis();
        int soilValue1 = analogRead(ANALOG_INPUT_SOIL_SENSOR1);// Read analog soil value
        int soilValue2 = analogRead(ANALOG_INPUT_SOIL_SENSOR2);
      

      my question is will this code still read the soil probes constantly and therefore erode them or will it only read on the intervals I have defined. I know it reports only on the intervals I have outlined but that really defeats the purpose or trying to prevent electrolysis if it is still reading them constantly and just not reporting the values. Thanks for any help!

      #include <SPI.h>
      #include <MySensor.h>
      
      #define ANALOG_INPUT_SOIL_SENSOR1 A0
      #define CHILD_ID1 0 // Id of the sensor child
      #define ANALOG_INPUT_SOIL_SENSOR2 A1
      #define CHILD_ID2 1 // Id of the sensor child
      
      
      long previousMillis = 0;
      long interval = (1000); //1000 is 1 second 
      
      MySensor gw;
      MyMessage msg1(CHILD_ID1, V_HUM),msg2(CHILD_ID2, V_HUM);
      int lastSoilValue1 = -1;
      int lastSoilValue2 = -1;
      
      void setup()
      
      {
        gw.begin();
        gw.sendSketchInfo("Soil Moisture Sensor - analog", "1.0"); // Send the sketch version information to the gateway and Controller
        pinMode(ANALOG_INPUT_SOIL_SENSOR1, INPUT);// sets the soil sensor analog pin as input
        pinMode(ANALOG_INPUT_SOIL_SENSOR2, INPUT);
        gw.present(CHILD_ID1, S_HUM);// Register all sensors to gw (they will be created as child devices)
        gw.present(CHILD_ID2, S_HUM);
      }
      
      void loop()
      
      {
        unsigned long currentMillis = millis();
        int soilValue1 = analogRead(ANALOG_INPUT_SOIL_SENSOR1);// Read analog soil value
        int soilValue2 = analogRead(ANALOG_INPUT_SOIL_SENSOR2);
        
        if (currentMillis - previousMillis > interval) {
          previousMillis = currentMillis;  
          Serial.println(soilValue1);
          Serial.println(soilValue2);
          gw.send(msg1.set(constrain(map(soilValue1, 1023, 250, 0, 100), 0, 100)));
          gw.send(msg2.set(constrain(map(soilValue2, 1023, 250, 0, 100), 0, 100)));
          lastSoilValue1 = soilValue1;
          lastSoilValue2 = soilValue2;
        }
      }```
      posted in Troubleshooting
      punter9
      punter9
    • RE: relay with delay feature

      yea this code is messy, I am reworking it today. Any insight on the best way to delay those commands without impacting the relay?

      posted in Troubleshooting
      punter9
      punter9
    • relay with delay feature

      Hi everyone I have been reading and am struggling getting a grip with this situation.

      I have
      3 Binary switches - need to be read 2-4 times daily
      2 Soil Moisture sensors - need to be read 4 times daily
      1 relay - needs to work on demand

      The issue I have right now is that my 3 binary switches and 2 moisture sensors are susceptible to electrolysis and the current read settings erode my terminals in less than 2 weeks.

      I would like to put a wait/delay/whatever command to only cue those reading to happen 2-4 times a day, this should really extend the life of my cheap sensors!

      What would be the best way to implement this in my code? Currently I have zero gateway sleep commands/delay/etc.

      Below is the void loop and incoming message commands

      void loop() 
      {
        debouncer.update();
        // Get the update value
        int value1 = debouncer.read();
        int value2 = debouncer.read();
        int value3 = debouncer.read();
        int soilValue1 = analogRead(ANALOG_INPUT_SOIL_SENSOR1);
        int soilValue2 = analogRead(ANALOG_INPUT_SOIL_SENSOR2);
      
        value1 = digitalRead(BUTTON_PIN1);
        value2 = digitalRead(BUTTON_PIN2);
        value3 = digitalRead(BUTTON_PIN3);
       
        if (value1 != oldValue1) {
           // Send in the new value
           gw.send(msg1.set(value1==HIGH ? 1 : 0));
           oldValue1 = value1;
        }
        if (value2 != oldValue2) {
           // Send in the new value
           gw.send(msg2.set(value2==HIGH ? 1 : 0));
           oldValue2 = value2;
        }
        if (value3 != oldValue3) {
           // Send in the new value
           gw.send(msg3.set(value3==HIGH ? 1 : 0));
           oldValue3 = value3;
        }
        if (soilValue1 != lastSoilValue1) {
          Serial.println(soilValue1);
          gw.send(msg4.set(constrain(map(soilValue1, 1023, 250, 0, 100),0,100)));
          lastSoilValue1 = soilValue1;
        }
        if (soilValue2 != lastSoilValue2) {
          Serial.println(soilValue2);
          gw.send(msg5.set(constrain(map(soilValue2, 1023, 250, 0, 100),0,100)));
          lastSoilValue2 = soilValue2;
        }
        // Alway process incoming messages whenever possible
        gw.process();
      } 
      
      void incomingMessage(const MyMessage &message) {
        // We only expect one type of message from controller. But we better check anyway.
        if (message.type==V_LIGHT) {
           // Change relay state
           digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
           // Store state in eeprom
           gw.saveState(message.sensor, message.getBool());
           // Write some debug info
           Serial.print("Incoming change for sensor:");
           Serial.print(message.sensor);
           Serial.print(", New status: ");
           Serial.println(message.getBool());
         } 
      }```
      posted in Troubleshooting
      punter9
      punter9
    • RE: Multiple Binary Switch Help

      did this, works! on to adding a couple soil moisture sensors and a relay

      /**
       * 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 
       * Connect button or door/window reed switch between 
       * digitial I/O pin 3 (BUTTON_PIN below) and GND.
       * http://www.mysensors.org/build/binary
       */
      
      
      #include <MySensor.h>
      #include <SPI.h>
      #include <Bounce2.h>
      
      #define CHILD_ID1 3
      #define BUTTON_PIN1  3  // Arduino Digital I/O pin for button/reed switch
      #define CHILD_ID2 4
      #define BUTTON_PIN2  4  // Arduino Digital I/O pin for button/reed switch
      #define CHILD_ID3 5
      #define BUTTON_PIN3  5  // Arduino Digital I/O pin for button/reed switch
      
      
      
      MySensor gw;
      Bounce debouncer = Bounce(); 
      int oldValue1=-1;
      int oldValue2=-1;
      int oldValue3=-1;
      
      // Change to V_LIGHT if you use S_LIGHT in presentation below
      MyMessage msg1(CHILD_ID1,V_TRIPPED), msg2(CHILD_ID2,V_TRIPPED),msg3(CHILD_ID3,V_TRIPPED);
      
      
      
      void setup()  
      {  
        gw.begin();
      
       // Setup the button
        pinMode(BUTTON_PIN1,INPUT);
        pinMode(BUTTON_PIN2,INPUT);
        pinMode(BUTTON_PIN3,INPUT);
        
        // Activate internal pull-up
        digitalWrite(BUTTON_PIN1,HIGH);
        digitalWrite(BUTTON_PIN2,HIGH);
        digitalWrite(BUTTON_PIN3,HIGH);
        
        // After setting up the button, setup debouncer
        debouncer.attach(BUTTON_PIN1);
        debouncer.interval(5);
        debouncer.attach(BUTTON_PIN2);
        debouncer.interval(5);
        debouncer.attach(BUTTON_PIN3);
        debouncer.interval(5);
      
        // 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. See "msg" above.
        gw.present(CHILD_ID1, S_DOOR);
        gw.present(CHILD_ID2, S_DOOR);
        gw.present(CHILD_ID3, S_DOOR);  
      }
      
      
      //  Check if digital input has changed and send in new value
      void loop() 
      {
        debouncer.update();
        // Get the update value
        int value1 = debouncer.read();
        int value2 = debouncer.read();
        int value3 = debouncer.read();
      
        value1 = digitalRead(BUTTON_PIN1);
        value2 = digitalRead(BUTTON_PIN2);
        value3 = digitalRead(BUTTON_PIN3);
       
        if (value1 != oldValue1) {
           // Send in the new value
           gw.send(msg1.set(value1==HIGH ? 1 : 0));
           oldValue1 = value1;
        }
        if (value2 != oldValue2) {
           // Send in the new value
           gw.send(msg2.set(value2==HIGH ? 1 : 0));
           oldValue2 = value2;
        }
        if (value3 != oldValue3) {
           // Send in the new value
           gw.send(msg3.set(value3==HIGH ? 1 : 0));
           oldValue3 = value3;
        }
      } 
      
      
      posted in Troubleshooting
      punter9
      punter9
    • RE: Water level code

      I am using straight bolts. I am still working through issues however combining multiple binary switches (bolts), 2 moisture sensors, and a relay.

      posted in Development
      punter9
      punter9
    • Multiple Binary Switch Help

      Hey all I am learning here and running into some issues. I have 3 binary switches I would like to have read for me. I have written code and they all show up as I would like. The issues I am having is only pin D5 seems to do anything and it turns ON/OFF all 3 switches. Any help as to why this is would really be appreciated.

      #include <MySensor.h>
      #include <SPI.h>
      #include <Bounce2.h>
      
      #define CHILD_ID1 3
      #define BUTTON_PIN1  3  // Arduino Digital I/O pin for button/reed switch
      #define CHILD_ID2 4
      #define BUTTON_PIN2  4  // Arduino Digital I/O pin for button/reed switch
      #define CHILD_ID3 5
      #define BUTTON_PIN3  5  // Arduino Digital I/O pin for button/reed switch
      
      
      
      MySensor gw;
      Bounce debouncer = Bounce(); 
      int oldValue=-1;
      
      // Change to V_LIGHT if you use S_LIGHT in presentation below
      MyMessage msg1(CHILD_ID1,V_TRIPPED), msg2(CHILD_ID2,V_TRIPPED),msg3(CHILD_ID3,V_TRIPPED);
      
      
      
      void setup()  
      {  
        gw.begin();
      
       // Setup the button
        pinMode(BUTTON_PIN1,INPUT);
        pinMode(BUTTON_PIN2,INPUT);
        pinMode(BUTTON_PIN3,INPUT);
        
        // Activate internal pull-up
        digitalWrite(BUTTON_PIN1,HIGH);
        digitalWrite(BUTTON_PIN2,HIGH);
        digitalWrite(BUTTON_PIN3,HIGH);
        
        // After setting up the button, setup debouncer
        debouncer.attach(BUTTON_PIN1);
        debouncer.interval(5);
        debouncer.attach(BUTTON_PIN2);
        debouncer.interval(5);
        debouncer.attach(BUTTON_PIN3);
        debouncer.interval(5);
      
        // 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. See "msg" above.
        gw.present(CHILD_ID1, S_DOOR);
        gw.present(CHILD_ID2, S_DOOR);
        gw.present(CHILD_ID3, S_DOOR);  
      }
      
      
      //  Check if digital input has changed and send in new value
      void loop() 
      {
        debouncer.update();
        // Get the update value
        int value = debouncer.read();
       
        if (value != oldValue) {
           // Send in the new value
           gw.send(msg1.set(value==HIGH ? 1 : 0));
           gw.send(msg2.set(value==HIGH ? 1 : 0));
           gw.send(msg3.set(value==HIGH ? 1 : 0));
           oldValue = value;
        }
      } 
      
      
      posted in Troubleshooting
      punter9
      punter9
    • RE: Arduino Nano power related issue

      link text

      I switched the relay power to come off the 5v pin on the board and replaced the nano board with another and it is working. The old one seems to have died.

      posted in Hardware
      punter9
      punter9
    • RE: Arduino Nano power related issue

      I have a 9v power supply with a + and - wire. I have wired the nano pin 30 and the relay vcc to the + wire of the power supply. Same goes with the negative, wiring the ground nearest to pin 30 on the nano to the - wire on the power supply and the gnd on the relay to the - wire on the power supply.

      the mysensors radio is on the 3.3v pin and ground on the board

      posted in Hardware
      punter9
      punter9
    • RE: Arduino Nano power related issue

      it is powered seperately, should have mentioned that. regardless it works with usb and not with pin 30. Power supply is 9V 2A

      posted in Hardware
      punter9
      punter9
    • Arduino Nano power related issue

      I'm betting somebody on here knows the answer. I am powering my nano via pin 30 with a 9v input. My node is a relay. It powers up and registers on domoticz. It won't however switch the relay.

      Neat part is if I plug in the usb cable it will switch the relay with all the same code etc.....what is the deal here?

      posted in Hardware
      punter9
      punter9
    • RE: Water level code

      I'm seeing possibly using an s_door setup to be just like a door open closed switch. This could be useful. I would like for it to not show up as a door however in domoticz

      edit: just saw s_binary

      posted in Development
      punter9
      punter9
    • Water level code

      I wanted to pick your brains on this issue.

      What I have is a domoticz/mysensors setup. I have a garden with the moisture sensor and relay node combined. What this does is measure soil moisture and trigger a small pump in a tank to run. On the side of this tank I have put 4 bolts through it into the water. One at 25% down from top, one at 50% down from top, one right above top of pump (submerged pump), and one at very bottom.

      The bolt at the bottom is the ground and I apply power to the top 3 bolts 1 at a time to check for water levels. This way I can be alerted of needed tank refill and write logic to not run the pump if the water level is too low.

      Could anyone help me form some code to make these bolts into a useful mysensor node? I don't need the combo relay/soil sensor I have already combined those sketches. I would simply like tto add the bolts to register on or off and transmit as a recognizable sensor to domoticz.

      I am betting this is really simple, but I am learning everyday. I am working towards being able to build my own custom mysensor node.

      posted in Development
      punter9
      punter9
    • Relay and Repeater - Just learning stuff

      So I have several nodes going in the house. I love mysensors and really appreciate all who have made this possible.

      Today I am looking into repeaters and learning how to make my custom multi sensor nodes into repeaters. Specifically any with a relay since they process incoming messages. From what I can tell they already are. Could someone fact check me to make sure I am thinking about this correctly?

      1.) To make a repeater node you first off cannot have any sort of sleep function

      2.) You need this code to enable repeater mode, specifically I think you only need the true part.

      gw.begin(NULL, AUTO, true);
      

      this would also work i am thinking

      gw.begin(incomingMessage, AUTO, true);
      

      3.) This is what makes a repeater do repeater things.

      gw.process();
      
      posted in General Discussion
      punter9
      punter9
    • RE: Help with combination DHT and Relay

      Thanks for checking in @TheoL . My intent for this sketch was to learn how to combine sketches and make a useful project. Got that done and working! It would be cool if there was an easy way to help newbies like myself out doing this. I can tell you without this awesome forum I would have not figured out some pretty basic stuff! Thanks for all the help, this is an awesome site

      posted in Troubleshooting
      punter9
      punter9
    • RE: Combining DHT and Relay issues

      oh this is a great call. trying

      posted in Troubleshooting
      punter9
      punter9
    • Combining DHT and Relay issues

      I am having some troubles combining two sets of code. I am getting it to be recognized in domoticz and read the temp of the DHT and it sees the relay and I can add it. The issue is I cannot trigger the relay on and off. It works fine with just the relay code, but as soon as I inject the DHT code this issues arises. Any ideas?

      /**
       * 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.
       *
       *******************************
       *
       * REVISION HISTORY
       * Version 1.0 - Henrik Ekblad
       * 
       * DESCRIPTION
       * Example sketch showing how to control physical relays. 
       * This example will remember relay state after power failure.
       * http://www.mysensors.org/build/relay
       */ 
      
      #include <MySigningNone.h>
      #include <MyTransportNRF24.h>
      #include <MyTransportRFM69.h>
      #include <MyHwATMega328.h>
      #include <MySensor.h>
      #include <SPI.h>
      #include <DHT.h>
      
      #define RELAY_1  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_HUM 0
      #define CHILD_ID_TEMP 1
      #define HUMIDITY_SENSOR_DIGITAL_PIN 4
      unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
      
      
      // NRFRF24L01 radio driver (set low transmit power by default) 
      MyTransportNRF24 radio(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW);  
      //MyTransportRFM69 radio;
      // Message signing driver (none default)
      //MySigningNone signer;
      // Select AtMega328 hardware profile
      MyHwATMega328 hw;
      // Construct MySensors library
      MySensor gw(radio, hw);
      
      DHT dht;
      float lastTemp;
      float lastHum;
      boolean metric = true; 
      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      
      
      
      
      void setup()  
      {   
        // Initialize library and add callback for incoming messages
        gw.begin(incomingMessage, AUTO, true);
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("Relay & DHT", "1.0");
      
        // Fetch relay status
        for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
          // Register all sensors to gw (they will be created as child devices)
          gw.present(sensor, S_LIGHT);
          // Then set relay pins in output mode
          pinMode(pin, OUTPUT);   
          // Set relay to last known state (using eeprom storage) 
          digitalWrite(pin, gw.loadState(sensor)?RELAY_ON:RELAY_OFF);
        }
        
        dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 
      
        // Send the Sketch Version Information to the Gateway
        gw.sendSketchInfo("Humidity", "1.0");
      
        // Register all sensors to gw (they will be created as child devices)
        gw.present(CHILD_ID_HUM, S_HUM);
        gw.present(CHILD_ID_TEMP, S_TEMP);
        
        metric = gw.getConfig().isMetric;
        
        
        
      }
      
      
      void loop() 
      {
        // Alway process incoming messages whenever possible
        gw.process();
        
        delay(dht.getMinimumSamplingPeriod());
      
        float temperature = dht.getTemperature();
        if (isnan(temperature)) {
            Serial.println("Failed reading temperature from DHT");
        } else if (temperature != lastTemp) {
          lastTemp = temperature;
          if (!metric) {
            temperature = dht.toFahrenheit(temperature);
          }
          gw.send(msgTemp.set(temperature, 1));
          Serial.print("T: ");
          Serial.println(temperature);
        }
        
        float humidity = dht.getHumidity();
        if (isnan(humidity)) {
            Serial.println("Failed reading humidity from DHT");
        } else if (humidity != lastHum) {
            lastHum = humidity;
            gw.send(msgHum.set(humidity, 1));
            Serial.print("H: ");
            Serial.println(humidity);
        }
      
        gw.sleep(SLEEP_TIME); //sleep a bit
        
        
      }
      
      void incomingMessage(const MyMessage &message) {
        // We only expect one type of message from controller. But we better check anyway.
        if (message.type==V_LIGHT) {
           // Change relay state
           digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
           // Store state in eeprom
           gw.saveState(message.sensor, message.getBool());
           // Write some debug info
           Serial.print("Incoming change for sensor:");
           Serial.print(message.sensor);
           Serial.print(", New status: ");
           Serial.println(message.getBool());
         } 
      }
      
      posted in Troubleshooting
      punter9
      punter9
    • RE: Help with combination DHT and Relay

      okay got it working and both sensors have been found in domoticz. Only issue is relay doesn't turn on or off with control. But it has been found. I have it plugged into pin 4, checked that it worked by manually jumping the pins, and I can see the tx/rx light blink when I click the button in domoticz (but no relay click).

      posted in Troubleshooting
      punter9
      punter9
    • RE: Help with combination DHT and Relay

      ha! you are awesome. Thank you so much

      posted in Troubleshooting
      punter9
      punter9
    • RE: Help with combination DHT and Relay

      Thanks! right off the bat I am seeing this being added

      gw.present(CHILD_ID_RELAY, S_LIGHT);

      and this instead of each sketch called out this being in there

      gw.sendSketchInfo("Combo", "1.0");

      will this still work with domoticz?

      posted in Troubleshooting
      punter9
      punter9
    • Help with combination DHT and Relay

      Hey I am building up a useful mysensors network around my apartment and could use a helping hand. I have several single purpose setups going (relay, dht, moisture, etc) but I would really like to learn to roll them together. My first attempt is for a DHT and relay. I have combined the code but I am getting radio init error in the serial monitor. Could someone lend an eye to help me learn this? Thanks in advance!

      /** combo mysensors - DHT11/22 and Single Relay
       *  
       *   * 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.  
       */
      
      /** 
       *  Humidity
       *   * REVISION HISTORY
       * Version 1.0 - Henrik EKblad
       * 
       * DESCRIPTION
       * This sketch provides an example how to implement a humidity/temperature
       * sensor using DHT11/DHT-22 
       * http://www.mysensors.org/build/humidity
       *  
       */
      
      /**
       * Relay
       * * REVISION HISTORY
       * Version 1.0 - Henrik Ekblad
       * 
       * DESCRIPTION
       * Example sketch showing how to control physical relays. 
       * This example will remember relay state after power failure.
       * http://www.mysensors.org/build/relay
       */
      
      
      /**-------------------------------------------------------------------------------------------------------------
       * INCLUSIONS
       */
      
      /**
       * Humidity
       */
      #include <SPI.h>
      #include <MySensor.h>  
      #include <DHT.h>  
      /**
       * Relay
       */
      #include <MySigningNone.h>
      #include <MyTransportNRF24.h>
      #include <MyTransportRFM69.h>
      #include <MyHwATMega328.h>
      
      /**-------------------------------------------------------------------------------------------------------------
       * DEFINE
       */
      
      /**
       * Humidity
       */
      #define CHILD_ID_HUM 0
      #define CHILD_ID_TEMP 1
      #define HUMIDITY_SENSOR_DIGITAL_PIN 3
      unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
      
      /**
       * Relay
       */
      #define RELAY_1  4  // 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
      
      /**-------------------------------------------------------------------------------------------------------------
       * RADIO - I THINK
       */
      
      /**
       * Relay
       */
      
      // NRFRF24L01 radio driver (set low transmit power by default) 
      MyTransportNRF24 radio(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW);  
      //MyTransportRFM69 radio;
      // Message signing driver (none default)
      //MySigningNone signer;
      // Select AtMega328 hardware profile
      MyHwATMega328 hw;
      // Construct MySensors library
      MySensor gw(radio, hw);
      
      
      /**
       * Humidity
       */
      
      DHT dht;
      float lastTemp;
      float lastHum;
      boolean metric = true; 
      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      
      
      
      /**-------------------------------------------------------------------------------------------------------------
       * VOID SETUP
       */
      
      void setup()  
      { 
      
        /**
       * Humidity
       */
      
      gw.begin();
        dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 
      
        // Send the Sketch Version Information to the Gateway
        gw.sendSketchInfo("Humidity", "1.0");
      
        // Register all sensors to gw (they will be created as child devices)
        gw.present(CHILD_ID_HUM, S_HUM);
        gw.present(CHILD_ID_TEMP, S_TEMP);
        
        metric = gw.getConfig().isMetric;
      
      /**
       * Relay
       */
       
        // Initialize library and add callback for incoming messages
        gw.begin(incomingMessage, AUTO, true);
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("Relay", "1.0");
      
        // Fetch relay status
        for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
          // Register all sensors to gw (they will be created as child devices)
          gw.present(sensor, S_LIGHT);
          // Then set relay pins in output mode
          pinMode(pin, OUTPUT);   
          // Set relay to last known state (using eeprom storage) 
          digitalWrite(pin, gw.loadState(sensor)?RELAY_ON:RELAY_OFF);
        }
      
      }
      
      /**-------------------------------------------------------------------------------------------------------------
       * VOID LOOP
       */
      
      void loop()      
      {  
        /**
       * Humidity
       */
      
      delay(dht.getMinimumSamplingPeriod());
      
        float temperature = dht.getTemperature();
        if (isnan(temperature)) {
            Serial.println("Failed reading temperature from DHT");
        } else if (temperature != lastTemp) {
          lastTemp = temperature;
          if (!metric) {
            temperature = dht.toFahrenheit(temperature);
          }
          gw.send(msgTemp.set(temperature, 1));
          Serial.print("T: ");
          Serial.println(temperature);
        }
        
        float humidity = dht.getHumidity();
        if (isnan(humidity)) {
            Serial.println("Failed reading humidity from DHT");
        } else if (humidity != lastHum) {
            lastHum = humidity;
            gw.send(msgHum.set(humidity, 1));
            Serial.print("H: ");
            Serial.println(humidity);
        }
      
        gw.sleep(SLEEP_TIME); //sleep a bit
      
      /**
       * Relay
       */
      
      // Alway process incoming messages whenever possible
        gw.process();
      
      }
      
      /**-------------------------------------------------------------------------------------------------------------
       * INCOMING MESSAGE RELAY ONLY
       */
      
      void incomingMessage(const MyMessage &message) {
        // We only expect one type of message from controller. But we better check anyway.
        if (message.type==V_LIGHT) {
           // Change relay state
           digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
           // Store state in eeprom
           gw.saveState(message.sensor, message.getBool());
           // Write some debug info
           Serial.print("Incoming change for sensor:");
           Serial.print(message.sensor);
           Serial.print(", New status: ");
           Serial.println(message.getBool());
         } 
      }
      
      
      
       
      
      posted in Troubleshooting
      punter9
      punter9
    • Serial Gateway to Node (gas sensor) communication

      I am running arduino IDE 1.6.4 and mysensors 1.5 libraries on a windows 10 laptop. I am using 2 arduino uno (genuine) and ebay NRF24L01+ radios. I am also using a 135 instead of a 2 on the gas sensor (same hookup - just testing data link for domoticz build)

      I am getting the following.

      I am getting this from the serial gateway.
      0;0;3;0;9;gateway started, id=0, parent=0, distance=0
      0;0;3;0;14;Gateway startup complete.

      I am getting this from the sensor.
      find parent
      send: 105-105-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,st=bc:
      find parent

      nobody is finding anybody! Tips?

      posted in Troubleshooting
      punter9
      punter9