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
  1. Home
  2. Troubleshooting
  3. Troubleshooting sketch

Troubleshooting sketch

Scheduled Pinned Locked Moved Troubleshooting
4 Posts 3 Posters 1.3k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Cliff KarlssonC Offline
    Cliff KarlssonC Offline
    Cliff Karlsson
    wrote on last edited by
    #1

    I am trying to use two ultrasonic-sensors and one PIR with this sketch but I get this error:

    PIR_dual_ultrasonic_sensor:49: error: 'getConfig' was not declared in this scope
    
       metric = getConfig().isMetric;
    
                          ^
    
    exit status 1
    'getConfig' was not declared in this scope
    

    Can anyone tell me what I am doing wrong?

    
    // Enable debug prints
    #define MY_DEBUG
    #define MY_BAUD_RATE 115200
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    #include <NewPing.h>
    #include <MySensors.h>
    #include <SPI.h>
    
    #define SONAR_A_CHILD_ID 1
    #define SONAR_B_CHILD_ID 2
    #define MOTION_A_CHILD_ID 3
    
    
    #define SONAR_A_TRIGGER_PIN  6  // Arduino pin tied to trigger pin on the ultrasonic sensor.
    #define SONAR_A_ECHO_PIN     5  // Arduino pin tied to echo pin on the ultrasonic sensor.
    #define MOTION_A_TRIGGER_PIN  2
    
    #define SONAR_B_TRIGGER_PIN  8  // Arduino pin tied to trigger pin on the ultrasonic sensor.
    #define SONAR_B_ECHO_PIN     7  // Arduino pin tied to echo pin on the ultrasonic sensor.
    
    #define MAX_DISTANCE 300 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
    unsigned long SLEEP_TIME = 200; // Sleep time between reads (in milliseconds)
    
    unsigned long MOTION_SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
    #define INTERRUPT MOTION_A_TRIGGER_PIN-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
    
    
    
    NewPing sonar_A(SONAR_A_TRIGGER_PIN, SONAR_A_ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
    NewPing sonar_B(SONAR_B_TRIGGER_PIN, SONAR_B_ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
    
    
    MyMessage SONAR_A_msg(SONAR_A_CHILD_ID, V_DISTANCE);
    int SONAR_A_lastDist;
    
    MyMessage SONAR_B_msg(SONAR_B_CHILD_ID, V_DISTANCE);
    int SONAR_B_lastDist;
    
    MyMessage MOTION_A_msg(MOTION_A_CHILD_ID, V_TRIPPED);
    
    boolean metric = true; 
    
    void setup()  
    { 
      metric = getConfig().isMetric;
      pinMode(MOTION_A_TRIGGER_PIN, INPUT);      // sets the motion sensor digital pin as input
    }
    
    void presentation() {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Distance+Motion Sensor", "1.0");
    
      // Register all sensors to gw (they will be created as child devices)
      present(SONAR_A_CHILD_ID, S_DISTANCE);
      present(SONAR_B_CHILD_ID, S_DISTANCE);
      present(MOTION_A_TRIGGER_PIN, S_MOTION);
    }
    
    void loop()      
    {     
      
      boolean tripped = digitalRead(MOTION_A_TRIGGER_PIN) == HIGH; 
      
        
      Serial.println(tripped);
      send(MOTION_A_msg.set(tripped?"1":"0"));  // Send tripped value to gw 
     
     if(tripped)  {
      unsigned long time = millis()+30000;
      while (millis() < time){
          int SONAR_A_dist = metric?sonar_A.ping_cm():sonar_A.ping_in();
          Serial.print("Ping Sonar A: ");
          Serial.print(SONAR_A_dist); // Convert ping time to distance in cm and print result (0 = outside set distance range)
          Serial.println(metric?" cm":" in");
    
      if (SONAR_A_dist != SONAR_A_lastDist) {
          send(SONAR_A_msg.set(SONAR_A_dist));
          SONAR_A_lastDist = SONAR_A_dist;
          }
      
      wait(100);
    
          int SONAR_B_dist = metric?sonar_B.ping_cm():sonar_B.ping_in();
          Serial.print("Ping Sonar B: ");
          Serial.print(SONAR_B_dist); // Convert ping time to distance in cm and print result (0 = outside set distance range)
          Serial.println(metric?" cm":" in");
    
      if (SONAR_B_dist != SONAR_B_lastDist) {
          send(SONAR_B_msg.set(SONAR_B_dist));
          SONAR_B_lastDist = SONAR_B_dist;
          }
      
      }
      sleep(SLEEP_TIME);
    }
                
    //else{
      // Sleep until interrupt comes in on motion sensor. Send update every two minute. 
      sleep(INTERRUPT,CHANGE, MOTION_SLEEP_TIME);
    //}
    }
    
    mfalkviddM 1 Reply Last reply
    0
    • Cliff KarlssonC Cliff Karlsson

      I am trying to use two ultrasonic-sensors and one PIR with this sketch but I get this error:

      PIR_dual_ultrasonic_sensor:49: error: 'getConfig' was not declared in this scope
      
         metric = getConfig().isMetric;
      
                            ^
      
      exit status 1
      'getConfig' was not declared in this scope
      

      Can anyone tell me what I am doing wrong?

      
      // Enable debug prints
      #define MY_DEBUG
      #define MY_BAUD_RATE 115200
      // Enable and select radio type attached
      #define MY_RADIO_NRF24
      //#define MY_RADIO_RFM69
      
      #include <NewPing.h>
      #include <MySensors.h>
      #include <SPI.h>
      
      #define SONAR_A_CHILD_ID 1
      #define SONAR_B_CHILD_ID 2
      #define MOTION_A_CHILD_ID 3
      
      
      #define SONAR_A_TRIGGER_PIN  6  // Arduino pin tied to trigger pin on the ultrasonic sensor.
      #define SONAR_A_ECHO_PIN     5  // Arduino pin tied to echo pin on the ultrasonic sensor.
      #define MOTION_A_TRIGGER_PIN  2
      
      #define SONAR_B_TRIGGER_PIN  8  // Arduino pin tied to trigger pin on the ultrasonic sensor.
      #define SONAR_B_ECHO_PIN     7  // Arduino pin tied to echo pin on the ultrasonic sensor.
      
      #define MAX_DISTANCE 300 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
      unsigned long SLEEP_TIME = 200; // Sleep time between reads (in milliseconds)
      
      unsigned long MOTION_SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
      #define INTERRUPT MOTION_A_TRIGGER_PIN-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
      
      
      
      NewPing sonar_A(SONAR_A_TRIGGER_PIN, SONAR_A_ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
      NewPing sonar_B(SONAR_B_TRIGGER_PIN, SONAR_B_ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
      
      
      MyMessage SONAR_A_msg(SONAR_A_CHILD_ID, V_DISTANCE);
      int SONAR_A_lastDist;
      
      MyMessage SONAR_B_msg(SONAR_B_CHILD_ID, V_DISTANCE);
      int SONAR_B_lastDist;
      
      MyMessage MOTION_A_msg(MOTION_A_CHILD_ID, V_TRIPPED);
      
      boolean metric = true; 
      
      void setup()  
      { 
        metric = getConfig().isMetric;
        pinMode(MOTION_A_TRIGGER_PIN, INPUT);      // sets the motion sensor digital pin as input
      }
      
      void presentation() {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Distance+Motion Sensor", "1.0");
      
        // Register all sensors to gw (they will be created as child devices)
        present(SONAR_A_CHILD_ID, S_DISTANCE);
        present(SONAR_B_CHILD_ID, S_DISTANCE);
        present(MOTION_A_TRIGGER_PIN, S_MOTION);
      }
      
      void loop()      
      {     
        
        boolean tripped = digitalRead(MOTION_A_TRIGGER_PIN) == HIGH; 
        
          
        Serial.println(tripped);
        send(MOTION_A_msg.set(tripped?"1":"0"));  // Send tripped value to gw 
       
       if(tripped)  {
        unsigned long time = millis()+30000;
        while (millis() < time){
            int SONAR_A_dist = metric?sonar_A.ping_cm():sonar_A.ping_in();
            Serial.print("Ping Sonar A: ");
            Serial.print(SONAR_A_dist); // Convert ping time to distance in cm and print result (0 = outside set distance range)
            Serial.println(metric?" cm":" in");
      
        if (SONAR_A_dist != SONAR_A_lastDist) {
            send(SONAR_A_msg.set(SONAR_A_dist));
            SONAR_A_lastDist = SONAR_A_dist;
            }
        
        wait(100);
      
            int SONAR_B_dist = metric?sonar_B.ping_cm():sonar_B.ping_in();
            Serial.print("Ping Sonar B: ");
            Serial.print(SONAR_B_dist); // Convert ping time to distance in cm and print result (0 = outside set distance range)
            Serial.println(metric?" cm":" in");
      
        if (SONAR_B_dist != SONAR_B_lastDist) {
            send(SONAR_B_msg.set(SONAR_B_dist));
            SONAR_B_lastDist = SONAR_B_dist;
            }
        
        }
        sleep(SLEEP_TIME);
      }
                  
      //else{
        // Sleep until interrupt comes in on motion sensor. Send update every two minute. 
        sleep(INTERRUPT,CHANGE, MOTION_SLEEP_TIME);
      //}
      }
      
      mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by
      #2

      @Cliff-Karlsson
      https://forum.mysensors.org/topic/5841/getconfig-was-not-declared-in-this-scope-v2-1-1-fixed/
      https://forum.mysensors.org/post/57843
      https://forum.mysensors.org/post/58390
      https://forum.mysensors.org/post/58182
      https://forum.mysensors.org/post/57669
      https://forum.mysensors.org/post/58305
      https://forum.mysensors.org/post/58880

      You would have gotten a faster answer by searching

      gohanG 1 Reply Last reply
      0
      • mfalkviddM mfalkvidd

        @Cliff-Karlsson
        https://forum.mysensors.org/topic/5841/getconfig-was-not-declared-in-this-scope-v2-1-1-fixed/
        https://forum.mysensors.org/post/57843
        https://forum.mysensors.org/post/58390
        https://forum.mysensors.org/post/58182
        https://forum.mysensors.org/post/57669
        https://forum.mysensors.org/post/58305
        https://forum.mysensors.org/post/58880

        You would have gotten a faster answer by searching

        gohanG Offline
        gohanG Offline
        gohan
        Mod
        wrote on last edited by
        #3

        @mfalkvidd it is a deleted post

        mfalkviddM 1 Reply Last reply
        0
        • gohanG gohan

          @mfalkvidd it is a deleted post

          mfalkviddM Offline
          mfalkviddM Offline
          mfalkvidd
          Mod
          wrote on last edited by
          #4

          @gohan which one?

          1 Reply Last reply
          0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          13

          Online

          12.0k

          Users

          11.2k

          Topics

          113.4k

          Posts


          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
          • Login

          • Don't have an account? Register

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