نمایش نتایج: از 1 به 10 از 10
Like Tree7 لایک
  • 1 Post By magmagmary
  • 2 Post By magmagmary
  • 1 Post By shobeir90
  • 1 Post By magmagmary
  • 1 Post By magmagmary
  • 1 Post By ARMARMARS@YAHOO.COM

موضوع: ماژول سنجش شدت نور tsl2561

  1. #1
    Junior Member
    تاریخ عضویت
    Oct 2015
    نوشته ها
    24

    ماژول سنجش شدت نور tsl2561

    سلام، لطفاً راهنمایی کنید گرچه فکر میکنم ماژول خراب باشه

    من اینو خریداری کردم اما متاسفانه با کد زیر این اررور رو میگیرم
    کد:
    /* SparkFun TSL2561 library example sketch This sketch shows how to use the SparkFunTSL2561 library to read the AMS/TAOS TSL2561 light sensor. Product page: https://www.sparkfun.com/products/11824 Hook-up guide: https://learn.sparkfun.com/tutorials...inosity-sensor Hardware connections: 3V3 to 3.3V GND to GND (WARNING: do not connect 3V3 to 5V or the sensor will be damaged!) You will also need to connect the I2C pins (SCL and SDA) to your Arduino. The pins are different on different Arduinos: SDA SCL Any Arduino "SDA" "SCL" Uno, Redboard, Pro A4 A5 Mega2560, Due 20 21 Leonardo 2 3 You do not need to connect the INT (interrupt) pin for basic operation. Operation: Upload this sketch to your Arduino, and open the Serial Monitor window to 9600 baud. Have fun! -Your friends at SparkFun. Our example code uses the "beerware" license. You can do anything you like with this code. No really, anything. If you find it useful, buy me a beer someday. V10 Mike Grusin, SparkFun Electronics 12/26/2013 Updated to Arduino 1.6.4 5/2015 */ // Your sketch must #include this library, and the Wire library // (Wire is a standard library included with Arduino): #include <SparkFunTSL2561.h> #include <Wire.h> // Create an SFE_TSL2561 object, here called "light": SFE_TSL2561 light; // Global variables: boolean gain; // Gain setting, 0 = X1, 1 = X16; unsigned int ms; // Integration ("shutter") time in milliseconds void setup() { // Initialize the Serial port: Serial.begin(9600); Serial.println("TSL2561 example sketch"); // Initialize the SFE_TSL2561 library // You can pass nothing to light.begin() for the default I2C address (0x39), // or use one of the following presets if you have changed // the ADDR jumper on the board: // TSL2561_ADDR_0 address with '0' shorted on board (0x29) // TSL2561_ADDR default address (0x39) // TSL2561_ADDR_1 address with '1' shorted on board (0x49) // For more information see the hookup guide at: https://learn.sparkfun.com/tutorials...inosity-sensor light.begin(); // Get factory ID from sensor: // (Just for fun, you don't need to do this to operate the sensor) unsigned char ID; if (light.getID(ID)) { Serial.print("Got factory ID: 0X"); Serial.print(ID,HEX); Serial.println(", should be 0X5X"); } // Most library commands will return true if communications was successful, // and false if there was a problem. You can ignore this returned value, // or check whether a command worked correctly and retrieve an error code: else { byte error = light.getError(); printError(error); } // The light sensor has a default integration time of 402ms, // and a default gain of low (1X). // If you would like to change either of these, you can // do so using the setTiming() command. // If gain = false (0), device is set to low gain (1X) // If gain = high (1), device is set to high gain (16X) gain = 0; // If time = 0, integration will be 13.7ms // If time = 1, integration will be 101ms // If time = 2, integration will be 402ms // If time = 3, use manual start / stop to perform your own integration unsigned char time = 2; // setTiming() will set the third parameter (ms) to the // requested integration time in ms (this will be useful later): Serial.println("Set timing..."); light.setTiming(gain,time,ms); // To start taking measurements, power up the sensor: Serial.println("Powerup..."); light.setPowerUp(); // The sensor will now gather light during the integration time. // After the specified time, you can retrieve the result from the sensor. // Once a measurement occurs, another integration period will start. } void loop() { // Wait between measurements before retrieving the result // (You can also configure the sensor to issue an interrupt // when measurements are complete) // This sketch uses the TSL2561's built-in integration timer. // You can also perform your own manual integration timing // by setting "time" to 3 (manual) in setTiming(), // then performing a manualStart() and a manualStop() as in the below // commented statements: // ms = 1000; // light.manualStart(); delay(ms); // light.manualStop(); // Once integration is complete, we'll retrieve the data. // There are two light sensors on the device, one for visible light // and one for infrared. Both sensors are needed for lux calculations. // Retrieve the data from the device: unsigned int data0, data1; if (light.getData(data0,data1)) { // getData() returned true, communication was successful Serial.print("data0: "); Serial.print(data0); Serial.print(" data1: "); Serial.print(data1); // To calculate lux, pass all your settings and readings // to the getLux() function. // The getLux() function will return 1 if the calculation // was successful, or 0 if one or both of the sensors was // saturated (too much light). If this happens, you can // reduce the integration time and/or gain. // For more information see the hookup guide at: https://learn.sparkfun.com/tutorials...inosity-sensor double lux; // Resulting lux value boolean good; // True if neither sensor is saturated // Perform lux calculation: good = light.getLux(gain,ms,data0,data1,lux); // Print out the results: Serial.print(" lux: "); Serial.print(lux); if (good) Serial.println(" (good)"); else Serial.println(" (BAD)"); } else { // getData() returned false because of an I2C error, inform the user. byte error = light.getError(); printError(error); } } void printError(byte error) // If there's an I2C error, this function will // print out an explanation. { Serial.print("I2C error: "); Serial.print(error,DEC); Serial.print(", "); switch(error) { case 0: Serial.println("success"); break; case 1: Serial.println("data too long for transmit buffer"); break; case 2: Serial.println("received NACK on address (disconnected?)"); break; case 3: Serial.println("received NACK on data"); break; case 4: Serial.println("other error"); break; default: Serial.println("unknown error"); } }
    کد:
    I2C error: 2, received NACK on address (disconnected?) I2C error: 2, received NACK on address (disconnected?) I2C error: 2, received NACK on address (disconnected?) I2C error: 2, received NACK on address (disconnected?) I2C error: 2, received NACK on address (disconnected?) I2C error: 2, received NACK on address (disconnected?) I2C error: 2, received NACK on address (disconnected?)

    همچنین با i2cscanner مشخصه که اتصالات درسته:
    کد:
    I2C Scanner
    Scanning...
    I2C device found at address 0x29  !
    done
    ولتاژ هم 3.3 ولت هست

    لینک خرید:

    ماژول سنسور سنجش نور / تابش - سنسور لوکس متر - TSL2561 Luminosity Sensor
    ویرایش توسط dm800vpr : 11-17-2015 در ساعت 11:19 AM

  2. #2
    مدیر گروه
    تاریخ عضویت
    Nov 2013
    محل سکونت
    ایران
    نوشته ها
    4,041
    سلام
    دوستم از این لینک ها استفاده کن:
    قیافشون فرق میکنه ولی راه اندازی عین همه
    Arduino LED Ambient Mood Light with Light/Luminosity/LUX Sensor | Feiticeir0's Blog

    DIY : Setting and configuration tutorial of the Secret Garden's remote control | Secret Garden's Blog


    مدل کالای سایت رو درکنار آردوینو سرچ کن کلی داده به دست میاری
    لایک کردن

  3. #3
    Junior Member
    تاریخ عضویت
    Oct 2015
    نوشته ها
    24
    نقل قول نوشته اصلی توسط magmagmary نمایش پست ها
    سلام
    دوستم از این لینک ها استفاده کن:
    قیافشون فرق میکنه ولی راه اندازی عین همه
    Arduino LED Ambient Mood Light with Light/Luminosity/LUX Sensor | Feiticeir0's Blog

    DIY : Setting and configuration tutorial of the Secret Garden's remote control | Secret Garden's Blog


    مدل کالای سایت رو درکنار آردوینو سرچ کن کلی داده به دست میاری
    مشکل این نیست دوست عزیز
    بنده مربوط ترین صفحه رو تست کردم
    https://learn.sparkfun.com/tutorials...r-hookup-guide
    احتراماً لینک های ارسالی شما پروژه هست

    مشکل اینجا بود
    برای i2c باید بصورت دستی تعریف میکردم آدرسشو توی کد
    یعنی اضافه کردن
    کد:
    light.begin(0x29)
    درکل کد اصلی بدون مشکل رو میذارم کسی مشکلی داشت با این کد حل بشه انشالله
    کد:
    /* SparkFun TSL2561 library example sketch
    
    This sketch shows how to use the SparkFunTSL2561
    library to read the AMS/TAOS TSL2561
    light sensor.
    
    Product page: https://www.sparkfun.com/products/11824
    Hook-up guide: https://learn.sparkfun.com/tutorials/getting-started-with-the-tsl2561-luminosity-sensor
    
    Hardware connections:
    
    3V3 to 3.3V
    GND to GND
    
    (WARNING: do not connect 3V3 to 5V
    or the sensor will be damaged!)
    
    You will also need to connect the I2C pins (SCL and SDA) to your Arduino.
    The pins are different on different Arduinos:
    
                        SDA    SCL
    Any Arduino         "SDA"  "SCL"
    Uno, Redboard, Pro  A4     A5
    Mega2560, Due       20     21
    Leonardo            2      3
    
    You do not need to connect the INT (interrupt) pin
    for basic operation.
    
    Operation:
    
    Upload this sketch to your Arduino, and open the
    Serial Monitor window to 9600 baud.
    
    Have fun! -Your friends at SparkFun.
    
    Our example code uses the "beerware" license.
    You can do anything you like with this code.
    No really, anything. If you find it useful,
    buy me a beer someday.
    
    V10 Mike Grusin, SparkFun Electronics 12/26/2013
    Updated to Arduino 1.6.4 5/2015
    */
    
    // Your sketch must #include this library, and the Wire library
    // (Wire is a standard library included with Arduino):
    
    #include <SparkFunTSL2561.h>
    #include <Wire.h>
    
    // Create an SFE_TSL2561 object, here called "light":
    
    SFE_TSL2561 light;
    
    
    // Global variables:
    
    boolean gain;     // Gain setting, 0 = X1, 1 = X16;
    unsigned int ms;  // Integration ("shutter") time in milliseconds
    
    
    
    void setup()
    {
    
    
    
      // Initialize the Serial port:
    
      Serial.begin(9600);
      Serial.println("TSL2561 example sketch");
    
      // Initialize the SFE_TSL2561 library
    
      // You can pass nothing to light.begin() for the default I2C address (0x39),
      // or use one of the following presets if you have changed
      // the ADDR jumper on the board:
      
    //   TSL2561_ADDR_0 address with '0' shorted on board (0x29)
      // TSL2561_ADDR   default address (0x39)
      // TSL2561_ADDR_1 address with '1' shorted on board (0x49)
    
      // For more information see the hookup guide at: https://learn.sparkfun.com/tutorials/getting-started-with-the-tsl2561-luminosity-sensor
      light.begin(0x29); // Initialize LightSensor2 to address 0x29
    
    
      // Get factory ID from sensor:
      // (Just for fun, you don't need to do this to operate the sensor)
    
      unsigned char ID;
      
      if (light.getID(ID))
      {
        Serial.print("Got factory ID: 0X");
        Serial.print(ID,HEX);
        Serial.println(", should be 0X5X");
      }
      // Most library commands will return true if communications was successful,
      // and false if there was a problem. You can ignore this returned value,
      // or check whether a command worked correctly and retrieve an error code:
      else
      {
        byte error = light.getError();
        printError(error);
      }
    
      // The light sensor has a default integration time of 402ms,
      // and a default gain of low (1X).
      
      // If you would like to change either of these, you can
      // do so using the setTiming() command.
      
      // If gain = false (0), device is set to low gain (1X)
      // If gain = high (1), device is set to high gain (16X)
    
      gain = 0;
    
      // If time = 0, integration will be 13.7ms
      // If time = 1, integration will be 101ms
      // If time = 2, integration will be 402ms
      // If time = 3, use manual start / stop to perform your own integration
    
      unsigned char time = 2;
    
      // setTiming() will set the third parameter (ms) to the
      // requested integration time in ms (this will be useful later):
      
      Serial.println("Set timing...");
      light.setTiming(gain,time,ms);
    
      // To start taking measurements, power up the sensor:
      
      Serial.println("Powerup...");
      light.setPowerUp();
      
      // The sensor will now gather light during the integration time.
      // After the specified time, you can retrieve the result from the sensor.
      // Once a measurement occurs, another integration period will start.
    }
    
    void loop()
    {
      // Wait between measurements before retrieving the result
      // (You can also configure the sensor to issue an interrupt
      // when measurements are complete)
      
      // This sketch uses the TSL2561's built-in integration timer.
      // You can also perform your own manual integration timing
      // by setting "time" to 3 (manual) in setTiming(),
      // then performing a manualStart() and a manualStop() as in the below
      // commented statements:
      
      // ms = 1000;
      // light.manualStart();
      delay(ms);
      // light.manualStop();
      
      // Once integration is complete, we'll retrieve the data.
      
      // There are two light sensors on the device, one for visible light
      // and one for infrared. Both sensors are needed for lux calculations.
      
      // Retrieve the data from the device:
    
      unsigned int data0, data1;
      
      if (light.getData(data0,data1))
      {
        // getData() returned true, communication was successful
        
        Serial.print("data0: ");
        Serial.print(data0);
        Serial.print(" data1: ");
        Serial.print(data1);
      
        // To calculate lux, pass all your settings and readings
        // to the getLux() function.
        
        // The getLux() function will return 1 if the calculation
        // was successful, or 0 if one or both of the sensors was
        // saturated (too much light). If this happens, you can
        // reduce the integration time and/or gain.
        // For more information see the hookup guide at: https://learn.sparkfun.com/tutorials/getting-started-with-the-tsl2561-luminosity-sensor
      
        double lux;    // Resulting lux value
        boolean good;  // True if neither sensor is saturated
        
        // Perform lux calculation:
    
        good = light.getLux(gain,ms,data0,data1,lux);
        
        // Print out the results:
    	
        Serial.print(" lux: ");
        Serial.print(lux);
        if (good) Serial.println(" (good)"); else Serial.println(" (BAD)");
      }
      else
      {
        // getData() returned false because of an I2C error, inform the user.
    
        byte error = light.getError();
        printError(error);
      }
    }
    
    void printError(byte error)
      // If there's an I2C error, this function will
      // print out an explanation.
    {
      Serial.print("I2C error: ");
      Serial.print(error,DEC);
      Serial.print(", ");
      
      switch(error)
      {
        case 0:
          Serial.println("success");
          break;
        case 1:
          Serial.println("data too long for transmit buffer");
          break;
        case 2:
          Serial.println("received NACK on address (disconnected?)");
          break;
        case 3:
          Serial.println("received NACK on data");
          break;
        case 4:
          Serial.println("other error");
          break;
        default:
          Serial.println("unknown error");
      }
    }


    اینم خروجی برنامه:
    کد:
    data0: 18 data1: 3 lux: 7.30 (good)
    data0: 9 data1: 2 lux: 3.29 (good)
    data0: 4 data1: 1 lux: 1.38 (good)
    data0: 12 data1: 2 lux: 4.87 (good)
    data0: 2 data1: 1 lux: 0.22 (good)
    data0: 58 data1: 8 lux: 24.62 (good)
    data0: 88 data1: 12 lux: 37.44 (good)
    data0: 88 data1: 12 lux: 37.44 (good)
    data0: 82 data1: 12 lux: 34.37 (good)
    data0: 6 data1: 2 lux: 1.64 (good)
    data0: 17 data1: 3 lux: 6.78 (good)


    اطلاعات تکمیلی:
    کد:
    Remember that you will need to inform the software library of the correct part address. This is done when you call the library’s “begin” function. Here’s an example with three light sensors:
    
    SFE_TSL2561 LightSensor1; // Declare a TSL2561 called "LightSensor1"
    SFE_TSL2561 LightSensor2; // Declare a TSL2561 called "LightSensor2"
    SFE_TSL2561 LightSensor3; // Declare a TSL2561 called "LightSensor3"
    
    void setup()
    {
      LightSensor1.begin();     // Initialize LightSensor1 to address 0x39
      LightSensor2.begin(0x29); // Initialize LightSensor2 to address 0x29
      LightSensor3.begin(TSL2561_ADDR_1); // Initialize LightSensor3 to address 0x49
    }
    
    Note that in the begin() function, you can use:
    
        Nothing (empty parenthesis) for the default address (0x39)
        One of the existing address numbers (0x29, 0x39, 0x49)
    
        One of the following predefined address names:
    
        TSL2561_ADDR (0x39)
    
        TSL2561_ADDR_1 (0x49)
    
        TSL2561_ADDR_0 (0x29)
    ویرایش توسط dm800vpr : 11-17-2015 در ساعت 07:37 PM

  4. #4
    مدیر گروه
    تاریخ عضویت
    Nov 2013
    محل سکونت
    ایران
    نوشته ها
    4,041
    ببینید ما تو راه اندازی خیلی از سنسورهامن اول یه راه سریع واسه خوندنi2c پیدا می کنیم بعد از نمون کد های مشابه تابع مورد نظرمون رو روی خروجی خام سنسور میزنیم
    به همین خاطر من بهتون کد معرفی کردم

  5. #5
    مدیر ویژه
    تاریخ عضویت
    Mar 2014
    نوشته ها
    586
    طبق فرموده dm800vpr:
    TSL2561_ADDR (0x39)
    TSL2561_ADDR_1 (0x49)
    TSL2561_ADDR_0 (0x29)
    دقیقا نکته اینجا هست.
    ماژول سه مدل آدرس می گیره برای addr
    که ماژول فروشگاه
    آدرسش 0x29 هست بیت کم ارزش این رجیستر تعیین کننده read , write هست یعنی برای صدا زدن باید کد هگز 52 53 استفاده شه...
    بعد از سه روز با دقت خوبی جواب گرفتم ازش
    لایک کردن

  6. #6
    مدیر گروه
    تاریخ عضویت
    Nov 2013
    محل سکونت
    ایران
    نوشته ها
    4,041
    نقل قول نوشته اصلی توسط shobeir90 نمایش پست ها
    طبق فرموده dm800vpr:
    TSL2561_ADDR (0x39)
    TSL2561_ADDR_1 (0x49)
    TSL2561_ADDR_0 (0x29)
    دقیقا نکته اینجا هست.
    ماژول سه مدل آدرس می گیره برای addr
    که ماژول فروشگاه
    آدرسش 0x29 هست بیت کم ارزش این رجیستر تعیین کننده read , write هست یعنی برای صدا زدن باید کد هگز 52 53 استفاده شه...
    بعد از سه روز با دقت خوبی جواب گرفتم ازش

    دوست گرامی اگر دوست داشتید میتونید به این سنت کمک کنید که کدهای تست شده ماژول ها رو در انجمن قرار بدید
    لایک کردن

  7. #7
    مدیر ویژه
    تاریخ عضویت
    Mar 2014
    نوشته ها
    586
    ویرایش توسط shobeir90 : 05-14-2016 در ساعت 11:25 AM

  8. #8
    مدیر گروه
    تاریخ عضویت
    Nov 2013
    محل سکونت
    ایران
    نوشته ها
    4,041
    نقل قول نوشته اصلی توسط shobeir90 نمایش پست ها
    با شتکر از شما آقای شبیر
    لایک کردن

  9. #9
    مدیر ویژه
    تاریخ عضویت
    Mar 2014
    نوشته ها
    586
    ممنون
    ایشالا مفید باشه ...

  10. #10
    Junior Member
    تاریخ عضویت
    Jan 2014
    نوشته ها
    23

    دانلود کتابخانه tsl2561 با نصب راحت

    سلام. کتابخونه tsl2561 که از سایت sparkfun دانلود میکنید ممکنه موقع نصب و استفاده یه زره ازیت کنه. من یه نسخه از کتابخونه ای که راحت نصب میشه رو اینجا گذاشتم. موفق باشید
    فایل های پیوست شده فایل های پیوست شده
    لایک کردن

مجوز های ارسال و ویرایش

  • شما نمیتوانید موضوع جدیدی ارسال کنید
  • شما امکان ارسال پاسخ را ندارید
  • شما نمیتوانید فایل پیوست کنید.
  • شما نمیتوانید پست های خود را ویرایش کنید
  •  

SEO by vBSEO