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. My Project
  3. Best sensor for falling alert

Best sensor for falling alert

Scheduled Pinned Locked Moved My Project
29 Posts 9 Posters 1.5k Views 11 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.
  • M Offline
    M Offline
    mrhutchinsonmn
    wrote on last edited by
    #16

    I am starting to ding around with my project, using the following tutorial sketch but getting an error and not finding how to fix it. Is it just a coding error?

    exit status 1
    'D6' was not declared in this scope```

    #include <Wire.h>
    
    // MPU6050 Slave Device Address
    const uint8_t MPU6050SlaveAddress = 0x68;
    
    // Select SDA and SCL pins for I2C communication 
    const uint8_t scl = D6;
    const uint8_t sda = D7;
    
    // sensitivity scale factor respective to full scale setting provided in datasheet 
    const uint16_t AccelScaleFactor = 16384;
    const uint16_t GyroScaleFactor = 131;
    
    // MPU6050 few configuration register addresses
    const uint8_t MPU6050_REGISTER_SMPLRT_DIV   =  0x19;
    const uint8_t MPU6050_REGISTER_USER_CTRL    =  0x6A;
    const uint8_t MPU6050_REGISTER_PWR_MGMT_1   =  0x6B;
    const uint8_t MPU6050_REGISTER_PWR_MGMT_2   =  0x6C;
    const uint8_t MPU6050_REGISTER_CONFIG       =  0x1A;
    const uint8_t MPU6050_REGISTER_GYRO_CONFIG  =  0x1B;
    const uint8_t MPU6050_REGISTER_ACCEL_CONFIG =  0x1C;
    const uint8_t MPU6050_REGISTER_FIFO_EN      =  0x23;
    const uint8_t MPU6050_REGISTER_INT_ENABLE   =  0x38;
    const uint8_t MPU6050_REGISTER_ACCEL_XOUT_H =  0x3B;
    const uint8_t MPU6050_REGISTER_SIGNAL_PATH_RESET  = 0x68;
    
    int16_t AccelX, AccelY, AccelZ, Temperature, GyroX, GyroY, GyroZ;
    
    void setup() {
      Serial.begin(9600);
      Wire.begin(sda, scl);
      MPU6050_Init();
    }
    
    void loop() {
      double Ax, Ay, Az, T, Gx, Gy, Gz;
      
      Read_RawValue(MPU6050SlaveAddress, MPU6050_REGISTER_ACCEL_XOUT_H);
      
      //divide each with their sensitivity scale factor
      Ax = (double)AccelX/AccelScaleFactor;
      Ay = (double)AccelY/AccelScaleFactor;
      Az = (double)AccelZ/AccelScaleFactor;
      T = (double)Temperature/340+36.53; //temperature formula
      Gx = (double)GyroX/GyroScaleFactor;
      Gy = (double)GyroY/GyroScaleFactor;
      Gz = (double)GyroZ/GyroScaleFactor;
    
      Serial.print("Ax: "); Serial.print(Ax);
      Serial.print(" Ay: "); Serial.print(Ay);
      Serial.print(" Az: "); Serial.print(Az);
      Serial.print(" T: "); Serial.print(T);
      Serial.print(" Gx: "); Serial.print(Gx);
      Serial.print(" Gy: "); Serial.print(Gy);
      Serial.print(" Gz: "); Serial.println(Gz);
    
      delay(100);
    }
    
    void I2C_Write(uint8_t deviceAddress, uint8_t regAddress, uint8_t data){
      Wire.beginTransmission(deviceAddress);
      Wire.write(regAddress);
      Wire.write(data);
      Wire.endTransmission();
    }
    
    // read all 14 register
    void Read_RawValue(uint8_t deviceAddress, uint8_t regAddress){
      Wire.beginTransmission(deviceAddress);
      Wire.write(regAddress);
      Wire.endTransmission();
      Wire.requestFrom(deviceAddress, (uint8_t)14);
      AccelX = (((int16_t)Wire.read()<<8) | Wire.read());
      AccelY = (((int16_t)Wire.read()<<8) | Wire.read());
      AccelZ = (((int16_t)Wire.read()<<8) | Wire.read());
      Temperature = (((int16_t)Wire.read()<<8) | Wire.read());
      GyroX = (((int16_t)Wire.read()<<8) | Wire.read());
      GyroY = (((int16_t)Wire.read()<<8) | Wire.read());
      GyroZ = (((int16_t)Wire.read()<<8) | Wire.read());
    }
    
    //configure MPU6050
    void MPU6050_Init(){
      delay(150);
      I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_SMPLRT_DIV, 0x07);
      I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_PWR_MGMT_1, 0x01);
      I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_PWR_MGMT_2, 0x00);
      I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_CONFIG, 0x00);
      I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_GYRO_CONFIG, 0x00);//set +/-250 degree/second full scale
      I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_ACCEL_CONFIG, 0x00);// set +/- 2g full scale
      I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_FIFO_EN, 0x00);
      I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_INT_ENABLE, 0x01);
      I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_SIGNAL_PATH_RESET, 0x00);
      I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_USER_CTRL, 0x00);
    }
    
    
    
    mfalkviddM 1 Reply Last reply
    0
    • M mrhutchinsonmn

      I am starting to ding around with my project, using the following tutorial sketch but getting an error and not finding how to fix it. Is it just a coding error?

      exit status 1
      'D6' was not declared in this scope```

      #include <Wire.h>
      
      // MPU6050 Slave Device Address
      const uint8_t MPU6050SlaveAddress = 0x68;
      
      // Select SDA and SCL pins for I2C communication 
      const uint8_t scl = D6;
      const uint8_t sda = D7;
      
      // sensitivity scale factor respective to full scale setting provided in datasheet 
      const uint16_t AccelScaleFactor = 16384;
      const uint16_t GyroScaleFactor = 131;
      
      // MPU6050 few configuration register addresses
      const uint8_t MPU6050_REGISTER_SMPLRT_DIV   =  0x19;
      const uint8_t MPU6050_REGISTER_USER_CTRL    =  0x6A;
      const uint8_t MPU6050_REGISTER_PWR_MGMT_1   =  0x6B;
      const uint8_t MPU6050_REGISTER_PWR_MGMT_2   =  0x6C;
      const uint8_t MPU6050_REGISTER_CONFIG       =  0x1A;
      const uint8_t MPU6050_REGISTER_GYRO_CONFIG  =  0x1B;
      const uint8_t MPU6050_REGISTER_ACCEL_CONFIG =  0x1C;
      const uint8_t MPU6050_REGISTER_FIFO_EN      =  0x23;
      const uint8_t MPU6050_REGISTER_INT_ENABLE   =  0x38;
      const uint8_t MPU6050_REGISTER_ACCEL_XOUT_H =  0x3B;
      const uint8_t MPU6050_REGISTER_SIGNAL_PATH_RESET  = 0x68;
      
      int16_t AccelX, AccelY, AccelZ, Temperature, GyroX, GyroY, GyroZ;
      
      void setup() {
        Serial.begin(9600);
        Wire.begin(sda, scl);
        MPU6050_Init();
      }
      
      void loop() {
        double Ax, Ay, Az, T, Gx, Gy, Gz;
        
        Read_RawValue(MPU6050SlaveAddress, MPU6050_REGISTER_ACCEL_XOUT_H);
        
        //divide each with their sensitivity scale factor
        Ax = (double)AccelX/AccelScaleFactor;
        Ay = (double)AccelY/AccelScaleFactor;
        Az = (double)AccelZ/AccelScaleFactor;
        T = (double)Temperature/340+36.53; //temperature formula
        Gx = (double)GyroX/GyroScaleFactor;
        Gy = (double)GyroY/GyroScaleFactor;
        Gz = (double)GyroZ/GyroScaleFactor;
      
        Serial.print("Ax: "); Serial.print(Ax);
        Serial.print(" Ay: "); Serial.print(Ay);
        Serial.print(" Az: "); Serial.print(Az);
        Serial.print(" T: "); Serial.print(T);
        Serial.print(" Gx: "); Serial.print(Gx);
        Serial.print(" Gy: "); Serial.print(Gy);
        Serial.print(" Gz: "); Serial.println(Gz);
      
        delay(100);
      }
      
      void I2C_Write(uint8_t deviceAddress, uint8_t regAddress, uint8_t data){
        Wire.beginTransmission(deviceAddress);
        Wire.write(regAddress);
        Wire.write(data);
        Wire.endTransmission();
      }
      
      // read all 14 register
      void Read_RawValue(uint8_t deviceAddress, uint8_t regAddress){
        Wire.beginTransmission(deviceAddress);
        Wire.write(regAddress);
        Wire.endTransmission();
        Wire.requestFrom(deviceAddress, (uint8_t)14);
        AccelX = (((int16_t)Wire.read()<<8) | Wire.read());
        AccelY = (((int16_t)Wire.read()<<8) | Wire.read());
        AccelZ = (((int16_t)Wire.read()<<8) | Wire.read());
        Temperature = (((int16_t)Wire.read()<<8) | Wire.read());
        GyroX = (((int16_t)Wire.read()<<8) | Wire.read());
        GyroY = (((int16_t)Wire.read()<<8) | Wire.read());
        GyroZ = (((int16_t)Wire.read()<<8) | Wire.read());
      }
      
      //configure MPU6050
      void MPU6050_Init(){
        delay(150);
        I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_SMPLRT_DIV, 0x07);
        I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_PWR_MGMT_1, 0x01);
        I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_PWR_MGMT_2, 0x00);
        I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_CONFIG, 0x00);
        I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_GYRO_CONFIG, 0x00);//set +/-250 degree/second full scale
        I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_ACCEL_CONFIG, 0x00);// set +/- 2g full scale
        I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_FIFO_EN, 0x00);
        I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_INT_ENABLE, 0x01);
        I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_SIGNAL_PATH_RESET, 0x00);
        I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_USER_CTRL, 0x00);
      }
      
      
      
      mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by
      #17

      @mrhutchinsonmn what Arduino are you using?

      The sketch says you need to adjust for the right i2c pins.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mrhutchinsonmn
        wrote on last edited by
        #18

        Are you speaking of a comment made on the tutorial? I don't see that instruction in the sketch. I did try to change to numerical values for D1 & D2 but the error followed.

        mfalkviddM 1 Reply Last reply
        0
        • M mrhutchinsonmn

          Are you speaking of a comment made on the tutorial? I don't see that instruction in the sketch. I did try to change to numerical values for D1 & D2 but the error followed.

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

          @mrhutchinsonmn no, in the sketch.

          Select SDA and SCL pins for I2C communication

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mrhutchinsonmn
            wrote on last edited by
            #20

            Isn't that what this is for?

            // Select SDA and SCL pins for I2C communication
            const uint8_t scl = D6;
            const uint8_t sda = D7;

            mfalkviddM 1 Reply Last reply
            0
            • M mrhutchinsonmn

              Isn't that what this is for?

              // Select SDA and SCL pins for I2C communication
              const uint8_t scl = D6;
              const uint8_t sda = D7;

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

              @mrhutchinsonmn yes

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mrhutchinsonmn
                wrote on last edited by
                #22

                I'm confused. That is from my sketch. Do I add another reference?

                mfalkviddM 1 Reply Last reply
                0
                • M mrhutchinsonmn

                  I'm confused. That is from my sketch. Do I add another reference?

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

                  @mrhutchinsonmn you change D6 and D7 to whatever the corresponding pins are for the Arduino you are using.

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    mrhutchinsonmn
                    wrote on last edited by
                    #24

                    Those are the ports I am using on my ESP8266 NodeMCU

                    mfalkviddM 1 Reply Last reply
                    0
                    • M mrhutchinsonmn

                      Those are the ports I am using on my ESP8266 NodeMCU

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

                      @mrhutchinsonmn ok, so you're using an esp8266-based Arduino. ESP8266 does not have hardware i2c. Instead, software i2c is used. Almost any pins on the esp8266 can be used for i2c.

                      What board have you selected in the Arudino IDE? If I select "NodeMCU 1.0 (ESP-12E module)", D6 and D7 are defined. If I select "generic esp8266 module", D6 and D7 are not defined since the pin mappings can be different for different boards.

                      P 1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        mrhutchinsonmn
                        wrote on last edited by
                        #26

                        Apologies!! I kept getting errors when using that board, so used another. I am on a new worksation and it turns out python was not installed. The error ceased after I installed. The sketch works fine now.

                        1 Reply Last reply
                        1
                        • D Offline
                          D Offline
                          danielbruno
                          wrote on last edited by
                          #27

                          Not sure if it helps. I find this drop/tilt/vibration sensor https://bit.ly/2kZrZnV. And my personal advice is that you buy your dad a emergency watch with built-in heart rate detector. It would help a lot i think

                          1 Reply Last reply
                          0
                          • R ristomatti

                            @nca78 said in Best sensor for falling alert:

                            But except if there's an interest in using the gyroscope, IMHO it's a bit of an overkill, while a LIS3DH will use 50-100 times less current for free fall detection (between 6 and 11µA), ADXL345 over 10 times less (40µA)

                            I agree with this also especially due to the low current consumption. I would not go as far as dismissing something as overkill when considering the intended usage though.

                            I don't have experience with free fall detection systems but somehow it sounds more suitable for detecting a direct gravitational falling and not a person falling which likely involves legs slowing down and the fall starting from the person already standing on the ground. But I am definitely interested in hearing how this works out as this is one of those rare projects that isn't just a "nice to have". Great idea!

                            P Offline
                            P Offline
                            pichaty
                            Banned
                            wrote on last edited by
                            #28
                            This post is deleted!
                            1 Reply Last reply
                            0
                            • mfalkviddM mfalkvidd

                              @mrhutchinsonmn ok, so you're using an esp8266-based Arduino. ESP8266 does not have hardware i2c. Instead, software i2c is used. Almost any pins on the esp8266 can be used for i2c.

                              What board have you selected in the Arudino IDE? If I select "NodeMCU 1.0 (ESP-12E module)", D6 and D7 are defined. If I select "generic esp8266 module", D6 and D7 are not defined since the pin mappings can be different for different boards.

                              P Offline
                              P Offline
                              pichaty
                              Banned
                              wrote on last edited by pichaty
                              #29
                              This post is deleted!
                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              18

                              Online

                              11.7k

                              Users

                              11.2k

                              Topics

                              113.1k

                              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