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
mikeg291M

mikeg291

@mikeg291
About
Posts
16
Topics
6
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Binary switch project
    mikeg291M mikeg291

    Sorry for the lack of clarity . I have used your tips to and update the sketch to no avail . What I am trying to do is use the switch to activate the time and use the time the switch was activated ( lastSwitchTime ) to compare to the (alarmTime ) and send the new (value ). ? . Once I resolve the current issues : I haven't gotten to it yet but , Once the alarmTime alarm is met I would like to have locked in requiring a reset are possible button push to clear it .
    [code]
    #include <MySensor.h>
    #include <SPI.h>
    #include <Bounce2.h>
    #include <Time.h>

    #define CHILD_ID 3
    #define BUTTON_PIN 3 // Arduino Digital I/O pin for button/reed switch
    int alarmTime = 15;
    MySensor gw;
    Bounce debouncer = Bounce();
    int oldValue = -1;

    time_t lastSwitchTime = 0;
    void receiveTime(unsigned long controllerTime);
    bool timeReceived = false;

    // Change to V_LIGHT if you use S_LIGHT in presentation below
    MyMessage msg(CHILD_ID, V_TRIPPED);

    void setup()
    {
    gw.begin();
    // Serial.begin(9600);
    // Setup the button
    pinMode(BUTTON_PIN, INPUT);
    // Activate internal pull-up
    digitalWrite(BUTTON_PIN, HIGH);

    // After setting up the button, setup debouncer
    debouncer.attach(BUTTON_PIN);
    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_ID, S_DOOR);

    // Make sure we get the system time, repeat request every 5 seconds until we have a valid time
    gw.requestTime(receiveTime);
    unsigned long lastRequest = millis();
    if ((millis() - lastRequest) > 5000) {
    gw.wait(100);
    gw.requestTime(receiveTime);
    lastRequest = millis();
    }
    lastSwitchTime = now();
    }

    // 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) {
    Serial.print("Switch was ");
    Serial.print(oldValue ? "ON" : "OFF");
    Serial.print(" for: ");
    Serial.print(now() - lastSwitchTime);
    Serial.println(" seconds");
    lastSwitchTime = now();

    // Send in the new value
    if (alarmTime <= lastSwitchTime );
    

    { gw.send(msg.set(value == HIGH 1));}
    else
    { gw.send(msg.set(value = LOW 0));
    oldValue = value;

    }
    }

    // This is called when a new time value was received
    void receiveTime(unsigned long controllerTime) {
    // OK, set incoming time
    Serial.print(F("Time value received: "));
    Serial.println(controllerTime);
    setTime(controllerTime);
    timeReceived = true;
    }

    Arduino: 1.6.7 (Windows 7), Board: "Arduino Nano, ATmega328"

    C:\Users\repair\AppData\Local\Temp\arduino_9fa690567122ca1856b95eff67fbf9b8\pump_cycle_time_2.5.ino: In function 'void loop()':

    pump_cycle_time_2.5:67: error: expected ')' before numeric constant

    { gw.send(msg.set(value == HIGH 1));}
    
                                    ^
    

    pump_cycle_time_2.5:68: error: expected '}' before 'else'

     else
    
     ^
    

    pump_cycle_time_2.5:69: error: expected ')' before numeric constant

      { gw.send(msg.set(value = LOW 0));
    
                                    ^
    

    exit status 1
    expected ')' before numeric constant

    This report would have more information with
    "Show verbose output during compilation"
    enabled in File > Preferences.

    [/code]

    Troubleshooting

  • Binary switch project
    mikeg291M mikeg291

    I cannot figure out how to correct the errors that I am getting. on this project. I need help

    #include <MySensor.h>
    #include <SPI.h>
    #include <Bounce2.h>
    #include <Time.h>
    
    #define CHILD_ID 3
    #define BUTTON_PIN  3  // Arduino Digital I/O pin for button/reed switch
    int alarmtime = 15;
    MySensor gw;
    Bounce debouncer = Bounce(); 
    int oldValue=-1;
    
    time_t  lastSwitchTime = 0;
    void receiveTime(unsigned long controllerTime);
    bool timeReceived = false;
    
    // Change to V_LIGHT if you use S_LIGHT in presentation below
    MyMessage msg(CHILD_ID,V_TRIPPED);
    
    void setup()  
    {  
      gw.begin();
      // Serial.begin(9600);
     // Setup the button
      pinMode(BUTTON_PIN,INPUT);
      // Activate internal pull-up
      digitalWrite(BUTTON_PIN,HIGH);
      
      // After setting up the button, setup debouncer
      debouncer.attach(BUTTON_PIN);
      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_ID, S_DOOR);  
      
      // Make sure we get the system time, repeat request every 5 seconds until we have a valid time
      gw.requestTime(receiveTime);
      unsigned long lastRequest = millis();
      if ((millis() - lastRequest) >  5000) {
          gw.wait(100);
          gw.requestTime(receiveTime); 
          lastRequest = millis();
       }
       lastSwitchTime = now();
    }
    
    
    //  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) {
         Serial.print("Switch was ");
         Serial.print(oldValue ? "ON" : "OFF");
         Serial.print(" for: ");
         Serial.print(now() - lastSwitchTime);
         Serial.println(" seconds");
         lastSwitchTime = now();
         
         // Send in the new value 
        if (value < == alarmtime );
         gw.send(msg.set(value==HIGH 1));
         else 
         gw.send(msg.set(value=LOW 0));
         oldValue = value;
    
      }
    } 
    
    // This is called when a new time value was received
    void receiveTime(unsigned long controllerTime) {
       // OK, set incoming time
       Serial.print(F("Time value received: "));
       Serial.println(controllerTime);
       setTime(controllerTime); 
       timeReceived = true;
    }
    

    Arduino: 1.6.7 (Windows 7), Board: "Arduino Nano, ATmega328"

    C:\Users\repair\Documents\Arduino\pump_cycle_time_2.5\pump_cycle_time_2.5.ino: In function 'void loop()':

    pump_cycle_time_2.5:66: error: expected primary-expression before '==' token

     if (value < == alarmtime );
    
                 ^
    

    pump_cycle_time_2.5:67: error: expected ')' before numeric constant

      gw.send(msg.set(value==HIGH 1));
    
                                  ^
    

    pump_cycle_time_2.5:68: error: expected '}' before 'else'

      else 
    
      ^
    

    pump_cycle_time_2.5:69: error: expected ')' before numeric constant

      gw.send(msg.set(value=LOW 0));
    
                                ^
    

    C:\Users\repair\Documents\Arduino\pump_cycle_time_2.5\pump_cycle_time_2.5.ino: At global scope:

    pump_cycle_time_2.5:73: error: expected declaration before '}' token

    }

    ^

    C:\Users\repair\Documents\Arduino\pump_cycle_time_2.5\pump_cycle_time_2.5.ino: In function 'void loop()':

    pump_cycle_time_2.5:66: error: expected primary-expression before '==' token

     if (value < == alarmtime );
    
                 ^
    

    pump_cycle_time_2.5:67: error: expected ')' before numeric constant

      gw.send(msg.set(value==HIGH 1));
    
                                  ^
    

    pump_cycle_time_2.5:68: error: expected '}' before 'else'

      else 
    
      ^
    

    pump_cycle_time_2.5:69: error: expected ')' before numeric constant

      gw.send(msg.set(value=LOW 0));
    
                                ^
    

    C:\Users\repair\Documents\Arduino\pump_cycle_time_2.5\pump_cycle_time_2.5.ino: At global scope:

    pump_cycle_time_2.5:73: error: expected declaration before '}' token

    }

    ^

    exit status 1
    exit status 1
    expected primary-expression before '==' token

    expected primary-expression before '==' token

    Troubleshooting

  • Moving a Post
    mikeg291M mikeg291

    How do you move a post from a category to another category to avoid cross posting ?

    General Discussion

  • Binary Switch Timer
    mikeg291M mikeg291

    @mikeg291 Arduino: 1.6.7 (Windows 7), Board: "Arduino Nano, ATmega328"

    C:\Users\repair\AppData\Local\Temp\arduino_9fa690567122ca1856b95eff67fbf9b8\pump_cycle_time_2.5.ino: In function 'void loop()':

    pump_cycle_time_2.5:66: error: expected primary-expression before '==' token

     if (value < == alarmtime );
    
                 ^
    

    pump_cycle_time_2.5:67: error: expected ')' before numeric constant

      gw.send(msg.set(value==HIGH 1));
    
                                  ^
    

    pump_cycle_time_2.5:68: error: expected '}' before 'else'

      else 
    
      ^
    

    pump_cycle_time_2.5:69: error: expected ')' before numeric constant

      gw.send(msg.set(value=LOW 0));
    
                                ^
    

    C:\Users\repair\AppData\Local\Temp\arduino_9fa690567122ca1856b95eff67fbf9b8\pump_cycle_time_2.5.ino: At global scope:

    pump_cycle_time_2.5:73: error: expected declaration before '}' token

    }

    ^

    exit status 1
    expected primary-expression before '==' token

    This report would have more information with
    "Show verbose output during compilation"
    enabled in File > Preferences.

    Development

  • Binary Switch Timer
    mikeg291M mikeg291

    That fixed the issue. It works great. To further enhance the sketch I added an alarm ,however I get an error as shown . Is there a way ; once the sent value of the alarm is set high that it is not changed based on future reading . requiring an acknowledgement or reset .

    #include <MySensor.h>
    #include <SPI.h>
    #include <Bounce2.h>
    #include <Time.h>
    
    #define CHILD_ID 3
    #define BUTTON_PIN  3  // Arduino Digital I/O pin for button/reed switch
    const int alarmtime = 15;
    MySensor gw;
    Bounce debouncer = Bounce(); 
    int oldValue=-1;
    
    time_t  lastSwitchTime = 0;
    void receiveTime(unsigned long controllerTime);
    bool timeReceived = false;
    
    // Change to V_LIGHT if you use S_LIGHT in presentation below
    MyMessage msg(CHILD_ID,V_TRIPPED);
    
    void setup()  
    {  
      gw.begin();
      // Serial.begin(9600);
     // Setup the button
      pinMode(BUTTON_PIN,INPUT);
      // Activate internal pull-up
      digitalWrite(BUTTON_PIN,HIGH);
      
      // After setting up the button, setup debouncer
      debouncer.attach(BUTTON_PIN);
      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_ID, S_DOOR);  
      
      // Make sure we get the system time, repeat request every 5 seconds until we have a valid time
      gw.requestTime(receiveTime);
      unsigned long lastRequest = millis();
      if ((millis() - lastRequest) >  5000) {
          gw.wait(100);
          gw.requestTime(receiveTime); 
          lastRequest = millis();
       }
       lastSwitchTime = now();
    }
    
    
    //  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) {
         Serial.print("Switch was ");
         Serial.print(oldValue ? "ON" : "OFF");
         Serial.print(" for: ");
         Serial.print(now() - lastSwitchTime);
         Serial.println(" seconds");
         lastSwitchTime = now();
         
         // Send in the new value
         if (value < == alarmtime );
         gw.send(msg.set(value==HIGH 1));
         else 
         gw.send(msg.set(value=LOW 0));
         oldValue = value;
      
    } 
    
    // This is called when a new time value was received
    void receiveTime(unsigned long controllerTime) {
       // OK, set incoming time
       Serial.print(F("Time value received: "));
       Serial.println(controllerTime);
       setTime(controllerTime); 
       timeReceived = true;
    }
    
    Development

  • Binary Switch Timer
    mikeg291M mikeg291

    BartE I hope this isn't a test because I just failed . I get the following error when compiling .
    Arduino: 1.6.7 (Windows 7), Board: "Arduino Nano, ATmega328"

    C:\Users\repair\AppData\Local\Temp\arduino_7e89e922452d95ce255568999142a32b\sketch_mar10a.ino: In function 'void setup()':

    sketch_mar10a:43: error: expected primary-expression before ')' token

       if (( millis()- ) {
    
                       ^
    

    sketch_mar10a:43: error: expected ')' before '{' token

       if (( millis()- ) {
    
                         ^
    

    sketch_mar10a:47: error: expected primary-expression before '}' token

    }
    
    ^
    

    sketch_mar10a:47: error: expected ';' before '}' token

    exit status 1
    expected primary-expression before ')' token

    This report would have more information with
    "Show verbose output during compilation"
    enabled in File > Preferences.

    Development

  • Binary Switch Timer
    mikeg291M mikeg291

    I am trying to use the Binary switch example to monitor the state of a Switch .I want to be able to measure the length of time the switch is not in its normal state e.g.. "how long was the door/window open" I have found numerous timer sketch's but they seem to be for timing when something should happen . Anyone have suggestions or example sketch's

    Development

  • Water pressure struggling with sketch
    mikeg291M mikeg291

    @tripy Thanks ; Tripy your solution solve the problem and pointed me in new info . I am slowly learning the solutions are available here .

    Troubleshooting

  • Water pressure struggling with sketch
    mikeg291M mikeg291

    he error that I get is
    Arduino: 1.6.7 (Windows 7), Board: "Arduino Nano, ATmega328"

    C:\Users\repair\Desktop\Ardunio Files\my_pressure_sketch_1\my_pressure_sketch_1.ino: In function 'void loop()':

    my_pressure_sketch_1:34: error: no matching function for call to 'MySensor::send(float&)'

     gw.send (PSI);
    
                 ^
    

    C:\Users\repair\Desktop\Ardunio Files\my_pressure_sketch_1\my_pressure_sketch_1.ino:34:17: note: candidate is:

    In file included from C:\Users\repair\Desktop\Ardunio Files\my_pressure_sketch_1\my_pressure_sketch_1.ino:2:0:

    C:\Program Files (x86)\Arduino\libraries\MySensors/MySensor.h:215:7: note: bool MySensor::send(MyMessage&, bool)

    bool send(MyMessage &msg, bool ack=false);

       ^
    

    C:\Program Files (x86)\Arduino\libraries\MySensors/MySensor.h:215:7: note: no known conversion for argument 1 from 'float' to 'MyMessage&'

    exit status 1
    no matching function for call to 'MySensor::send(float&)'

    This report would have more information with
    "Show verbose output during compilation"
    enabled in File > Preferences.
    @tripy

    Troubleshooting

  • Water pressure struggling with sketch
    mikeg291M mikeg291

    Can some help with this sketch I can't seem to figure it out. I will be so happy when I get past this newbie stage.

    #include <SPI.h>
    #include <MySensor.h>  
    #define BARO_CHILD 0
    MySensor gw;
    MyMessage pressureMsg(BARO_CHILD, V_PRESSURE);
    
    int pSensor=A0; //assigning pressure sensor to pin A0
    int readValue; //declaring our readValue Variable
    float Voltage; // declare  voltage variable
    float PSI; // declare pressure variable
    
    void setup()
    {
      gw.begin();
    
      // Send the sketch version information to the gateway and Controller
      gw.sendSketchInfo("Water Pressure", "1.1");
    
      // Register sensors to gw (they will be created as child devices)
      gw.present(BARO_CHILD, S_BARO);
    
    
     pinMode(pSensor,INPUT); //declare psensor as a input
     Serial.begin(9600); //start serial port
    }
    
    void loop() {
      
      readValue = analogRead(pSensor); // read psensor and put value in read value
      Voltage = (5./1023.)*readValue; //calculating real  world voltage
      PSI = 17.78*Voltage -8; // Calculate pressure PSI
    
      {
        gw.send (PSI);
      }
    
    Serial.println(PSI); //print results to serial monitor
      delay(1000);   // delay one second
    
    }
    
    Troubleshooting

  • Water well pressure moniter developing
    mikeg291M mikeg291

    After ,posting this an doing a lot of research I have managed to totally confuse myself . I am not sure any longer what day it is. There has to be a way to accomplish this . all I want to do now is get the psi reading generate by the above sketch to my vera via a serial gateway . Someone Please remove my blinders and point me in the right direction .

    Development

  • New Sensor type
    mikeg291M mikeg291

    @mfalkvidd
    Once , I realized that their wasn't an S_PRESSURE available . I thought about using S_Baro ,however I decided like "lafleur" in his comment that it would be confusing.
    Hopefully , there will be an S_PRESSURE in the future. I am amazed at this point in time there isn't one .

    Feature Requests

  • New Sensor type
    mikeg291M mikeg291

    I agree this is needed . I got interested in my sensors because I wanted to monitor some pressures not knowing there wasn't a S-PRESSURE available.
    regards

    Feature Requests

  • Water well pressure moniter developing
    mikeg291M mikeg291

    Scope ; I, like many others have a water well to supply our water needs. One of the inherent problems of a water well is a condition that the tank can become "water logged ". This results in the pump cycling rapidly resulting to the demise of the pump motor. I am trying to develop an system to monitor the pressure and the cycle time of the pump and set alarms in my Vera using MySensors . Being new to this I quickly realize the learning curve was steep.
    My plan is the put a relay on the pump the provide a signal when it is running ( and the length of time it is running) ; a pressure transmitter on the tank to monitor current pressure . I want to monitor pressure in case of pump failure .
    One of the problems I have incurred is I cannot find a pressure sensor .ino for this application and the files necessary for the vera.
    I purchased a generic pressure sensor and with the code below tested and refined it to provide accurate reading to serial monitor .

    int pSensor=A0; //assigning pressure sensor to pin A0
    int readValue; //declaring our readValue Variable
    float Voltage; // declare voltage variable
    float PSI; // declare pressure variable

    void setup() {
    pinMode(pSensor,INPUT); //declare psensor as a input
    Serial.begin(9600); //start serial port
    }

    void loop() {

    readValue = analogRead(pSensor); // read psensor and put value in read value
    Voltage = (5./1023.)readValue; //calculating real world voltage
    PSI = 17.78
    Voltage -8; // Calculate pressure PSI
    Serial.println(PSI); //print results to serial monitor
    delay(1000); // delay one second

    Can someone help me with a path forward. I am not asking for someone to develop it only to mentor me down the path .

    Development

  • Parking Sensor problem
    mikeg291M mikeg291

    Problem solved Turned out to be a bad sensor and with mfalkvidd 's suggestion troubleshooting was a lot easier . Thanks

    Troubleshooting

  • Parking Sensor problem
    mikeg291M mikeg291

    Just completed building the parking sensor project and interfaced it to a Vera edge via NRF2501,s and every thing works. The problem I am having is the sensor (monitoring it with serial monitor to confirm ) when a vehicle is parked it changes states ever 5 seconds from car parked to car gone . this does not occur when vehicle is actually gone . It reports correctly. I have verified connections, reloaded the sketch and now I am at a complete loss . Any suggestions .

    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