熱門文章

2017年8月31日 星期四

油分測量(組裝)

在網路上找到幾個檢測皮膚油度的方法

像Cuderm的sebutape®和courage-khazaka electronic的sebumeter®

但是……╮(╯_╰)╭
Sebutape只能得知皮膚油的程度~沒有一個確切的數據

Sebumeter儀器看起來又有點麻煩、有點複雜而且也不算便宜

所以想說就試著改進這些缺點

來DIY一台簡單、便宜又好用的油度檢測計吧!!!
數據的顯示面板
儀器的偵測孔
內部零件1
內部零件2


----程式碼----
   
#include <wire.h>
#include <TSL2561.h>
#include <liquidcrystal_i2c.h>
// Example for demonstrating the TSL2561 library - public domain!

// connect SCL to analog 5
// connect SDA to analog 4
// connect VDD to 3.3V DC
// connect GROUND to common ground
// ADDR can be connected to ground, or vdd or left floating to change the i2c address

// The address will be different depending on whether you let
// the ADDR pin float (addr 0x39), or tie it to ground or vcc. In those cases
// use TSL2561_ADDR_LOW (0x29) or TSL2561_ADDR_HIGH (0x49) respectively
TSL2561 tsl(TSL2561_ADDR_FLOAT); 
//int ledPinR = 11; // 這裡設定所要閃爍的LED燈腳位
//int ledPinG = 9;
//int ledPinB = 6;
LiquidCrystal_I2C lcd(0x3F,20,4);
void setup(void) {
 // pinMode(ledPinR, OUTPUT); // 這裡設定所要輸出的PIN腳模式
 // pinMode(ledPinG, OUTPUT);
 // pinMode(ledPinB, OUTPUT);
 // digitalWrite(ledPinR, HIGH);
 // digitalWrite(ledPinG, HIGH);
 // digitalWrite(ledPinB, HIGH);
  lcd.init();
  // Print a message to the LCD.
  lcd.backlight();
  lcd.setCursor(3,0);
  lcd.print("Hello, world!");
  lcd.setCursor(2,1);
  lcd.print("ToppyBio.Com.  Hi");
  delay(1500);
  lcd.clear();
  lcd.setCursor(0,0);  
  lcd.print("Fu:");
  lcd.setCursor(8,0);
  lcd.print("Vi:");
  lcd.setCursor(12,1);
  lcd.print("IR:");
  lcd.setCursor(0,1);  
  lcd.print("Lux:");
  Serial.begin(9600);
  
  if (tsl.begin()) {
    Serial.println("Found sensor");
  } else {
    Serial.println("No sensor?");
    while (1);
  }
    
  // You can change the gain on the fly, to adapt to brighter/dimmer light situations
  //tsl.setGain(TSL2561_GAIN_0X);         // set no gain (for bright situtations)
  tsl.setGain(TSL2561_GAIN_16X);      // set 16x gain (for dim situations)
  
  // Changing the integration time gives you a longer time over which to sense light
  // longer timelines are slower, but are good in very low light situtations!
  tsl.setTiming(TSL2561_INTEGRATIONTIME_13MS);  // shortest integration time (bright light)
  //tsl.setTiming(TSL2561_INTEGRATIONTIME_101MS);  // medium integration time (medium light)
  //tsl.setTiming(TSL2561_INTEGRATIONTIME_402MS);  // longest integration time (dim light)
  
  // Now we're ready to get readings!
}

void loop(void) {
  // Simple data read example. Just read the infrared, fullspecrtrum diode 
  // or 'visible' (difference between the two) channels.
  // This can take 13-402 milliseconds! Uncomment whichever of the following you want to read
  uint16_t x = tsl.getLuminosity(TSL2561_VISIBLE);     
  //uint16_t x = tsl.getLuminosity(TSL2561_FULLSPECTRUM);
  //uint16_t x = tsl.getLuminosity(TSL2561_INFRARED);
  
  Serial.println(x, DEC);

  // More advanced data read example. Read 32 bits with top 16 bits IR, bottom 16 bits full spectrum
  // That way you can do whatever math and comparisons you want!
  uint32_t lum = tsl.getFullLuminosity();
  uint16_t ir, full;
  ir = lum >> 16;
  full = lum & 0xFFFF;
 // ir=
  Serial.print("IR: "); Serial.print(ir);   Serial.print("\t\t");
  Serial.print("Full: "); Serial.print(full);   Serial.print("\t");
  Serial.print("Visible: "); Serial.print(full - ir);   Serial.print("\t");
  
  Serial.print("Lux: "); Serial.println(tsl.calculateLux(full, ir));
  lcd.setCursor(2,0);  
  lcd.print(full);  
  lcd.setCursor(8,0);
  lcd.print(full - ir);
  lcd.setCursor(14,0);
  lcd.print(ir);
  lcd.setCursor(5,1);  
  lcd.print(tsl.calculateLux(full, ir));
  delay(1000); 
  lcd.setCursor(3,0);  
  lcd.print("     ");
  lcd.setCursor(11,0);  
  lcd.print("    ");
  lcd.setCursor(14,1);  
  lcd.print("     ");
  lcd.setCursor(3,1);  
  lcd.print("    ");
    
}  

1 則留言:

  1. 請問是否可以承接外銷訂單
    我歐洲客戶對此儀器很有興趣

    回覆刪除