프로젝트

온도센서를 활용한 체온측정 웨어러블 기기

페이지 정보

작성자 임진환 작성일16-08-12 00:05 조회7,675회 댓글4건

본문

 

안녕하세요 임진환입니다. 메일 mpmedical1985@gmail.com

팀원은 임진환 장희은 입니다.

저희팀은 온도센서를 활용한 체온체크 웨어러블 기기을 제작하려고 합니다.

 

아두이노에 온도센서를 연결하고 각부분의 온도를 LCD모니터에 나타내고, 네오픽셀을 활용한 색상으로 체크하고 일정온도이상 올라가면 경고음과 온도를 낮추는 기능을 구현하려고 합니다.

 

사용할 센서는 DS18B20을 사용하여 여러 개의 온도센서를 하나의 와이어를 통해 준비할 계획이며, 준비물은 다음과 같습니다. 

 

준비물

1. DS18B20 온도센서 10개(10cm당 1개씩 연결하여 총 길이 100cm(조끼둘레))

2. 조끼

3. 5V 건전지

4. 아두이노

5. 버저(경고음 발생)

6. 네오픽셀 디스플레이 (10개, 온도센서 하나당 네오픽셀 한개씩)

7.태양광페널

994f92f3c587667885536ffc82423f3f_1470958


 

댓글목록

메카님의 댓글

메카 작성일

1. 메인코드 / 2. 주소값 얻는 코드


[1.메인코드]
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Wire.h>

/*-----( Declare Constants and Pin Numbers )-----*/
// Data wire is plugged into port 2 on the Arduino (can be changed)
#define ONE_WIRE_BUS 2    // NOTE: No ";" on #define 

/*-----( Declare objects )-----*/
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass address of our oneWire instance to Dallas Temperature.
DallasTemperature sensors(&oneWire);

/*-----( Declare Variables )-----*/
// Assign the addresses of your 1-Wire temp sensors.
// See the tutorial on how to obtain these addresses:
// http://arduino-info.wikispaces.com/Brick-Temperature-DS18B20#Read%20individual


 // WP 1
//DeviceAddress Probe01 = { 0x28, 0xFF, 0x86, 0x7E, 0x57, 0x16, 0x04, 0x84 };
//DeviceAddress Probe02 = { 0x28, 0xFF, 0x45, 0xB4, 0x57, 0x16, 0x04, 0xCA };
//DeviceAddress Probe03 = { 0x28, 0xFF, 0x8D, 0x37, 0x58, 0x16, 0x04, 0xD8 };

DeviceAddress Probe01 = {
0x28, 0xFF, 0x22, 0xDD, 0x56, 0x16, 0x04, 0x22};
DeviceAddress Probe02 = {
0x28, 0xFF, 0xE1, 0xEA, 0x57, 0x16, 0x04, 0x2B};
DeviceAddress Probe03 = {
0x28, 0xFF, 0xDD, 0xF7, 0x56, 0x16, 0x04, 0x80
};

void setup()  /****** SETUP: RUNS ONCE ******/
{
//------- Initialize the Temperature measurement library--------------
  Serial.begin(9600);
  sensors.begin();
  // set the resolution to 10 bit (Can be 9 to 12 bits .. lower is faster)
  sensors.setResolution(Probe01, 10);
  sensors.setResolution(Probe02, 10);
  sensors.setResolution(Probe03, 10);
}//--(end setup )---


void loop() 
{
  sensors.requestTemperatures();
  float temp1 = sensors.getTempC(Probe01);
  float temp2 = sensors.getTempC(Probe02);
  float temp3 = sensors.getTempC(Probe03);
  Serial.print(temp1);
  Serial.print(" ");
  Serial.print(temp2);
  Serial.print(" ");
  Serial.println(temp3);
}


[2.주소값 얻는 코드]

/* YourDuino Example: Find Address of a DS18B20 Temperature Sensor
 Cut and paste the address to a text file for later use.
 V1.1 01/17/2013
 Questions: terry@yourduino.com
 
 Connections:
 DS18B20 Pinout (Left to Right, pins down, flat side toward you)
 - Left  = Ground
 - Center = Signal (Pin 2):  (with 3.3K to 4.7K resistor to +5 or 3.3 )
 - Right  = +5 or +3.3 V 
 This sketch looks for 1-wire devices and  prints their addresses (serial number)
 to the Serial Monitor in a format that is useful in Arduino sketches.
 Based on example at:
 http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html
 */

/*-----( Import needed libraries )-----*/
#include <OneWire.h>

/*-----( Declare Constants and Pin Numbers )-----*/
#define SENSOR_PIN 2  // Any pin 2 to 12 (not 13) and A0 to A5

/*-----( Declare objects )-----*/
OneWire  ourBus(SENSOR_PIN);  // Create a 1-wire object

void setup()  /****** SETUP: RUNS ONCE ******/
{
  Serial.begin(9600);
 
  discoverOneWireDevices();  // Everything happens here!
}//--(end setup )---

void loop()  /****** LOOP: RUNS CONSTANTLY ******/
{
  // Nothing happening here
}

/*-----( Declare User-written Functions )-----*/
void discoverOneWireDevices(void) {
  byte i;
  byte present = 0;
  byte data[12];
  byte addr[8];

  Serial.print("Looking for 1-Wire devices...\n\r");// "\n\r" is NewLine
  while(ourBus.search(addr)) {
    Serial.print("\n\r\n\rFound '1-Wire' device with address:\n\r");
    for( i = 0; i < 8; i++) {
      Serial.print("0x");
      if (addr[i] < 16) {
        Serial.print('0');
      }
      Serial.print(addr[i], HEX);
      if (i < 7) {
        Serial.print(", ");
      }
    }
    if ( OneWire::crc8( addr, 7) != addr[7]) {
      Serial.print("CRC is not valid!\n\r");
      return;
    }
  }
  Serial.println();
  Serial.print("Done");
  ourBus.reset_search();
  return;
}

//*********( THE END )***********


--
+-----------------------------------------------------------------------+
Donghwa (David) Jeong, Ph.D
President and CEO
Mechasolution
Address: 62, Seongseogongdan-ro 11-gil, Dalseo-gu, Daegu, Korea
Daegu Technopark Venture 2 Plant, #323, 42714
Tel: +82-70-4042-5499  FAX: +82-53-289-5499
E-mail: roboholic84@gmail.com
+-----------------------------------------------------------------------+

메카님의 댓글

메카 작성일

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

#define PIN 6

// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//  NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//  NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//  NEO_GRB    Pixels are wired for GRB bitstream (most NeoPixel products)
//  NEO_RGB    Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//  NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(10, PIN, NEO_GRB + NEO_KHZ800);

// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel.  Avoid connecting
// on a live circuit...if you must, connect GND first.
int probe01 = 0;
int probe02 = 1;
int probe03 = 2;
int probe04 = 3;
int probe05 = 4;
int probe06 = 5;
int probe07 = 6;
int probe08 = 7;
int probe09 = 8;
int probe10 = 9;


void setup() {
  // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
  #if defined (__AVR_ATtiny85__)
    if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
  #endif
  // End of trinket special code


  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {

float temp1 = 20.5;
float temp2 = 35.5;
float temp3 = 36.5;
float temp4 = 40.0;
float temp5 = 20.5;
float temp6 = 35.5;
float temp7 = 36.5;
float temp8 = 40.0;
float temp9 = 36.5;
float temp10 = 90.0;

if (temp10 > 40) temp10 = 40;

strip.setPixelColor(probe01,(temp1-20)*255/20,0,(40-temp1)*255/20);
strip.setPixelColor(probe02,(temp2-20)*255/20,0,(40-temp2)*255/20);
strip.setPixelColor(probe03,(temp3-20)*255/20,0,(40-temp3)*255/20);
strip.setPixelColor(probe04,(temp4-20)*255/20,0,(40-temp4)*255/20);
strip.setPixelColor(probe05,(temp5-20)*255/20,0,(40-temp5)*255/20);
strip.setPixelColor(probe06,(temp6-20)*255/20,0,(40-temp6)*255/20);
strip.setPixelColor(probe07,(temp7-20)*255/20,0,(40-temp7)*255/20);
strip.setPixelColor(probe08,(temp8-20)*255/20,0,(40-temp8)*255/20);
strip.setPixelColor(probe09,(temp9-20)*255/20,0,(40-temp9)*255/20);
strip.setPixelColor(probe10,(temp10-20)*255/20,0,(40-temp10)*255/20);

strip.show();
 

}

메카님의 댓글

메카 작성일

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

#define PIN 6

// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//  NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//  NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//  NEO_GRB    Pixels are wired for GRB bitstream (most NeoPixel products)
//  NEO_RGB    Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//  NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(10, PIN, NEO_GRB + NEO_KHZ800);

// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel.  Avoid connecting
// on a live circuit...if you must, connect GND first.
int probe01 = 0;
int probe02 = 1;
int probe03 = 2;
int probe04 = 3;
int probe05 = 4;
int probe06 = 5;
int probe07 = 6;
int probe08 = 7;
int probe09 = 8;
int probe10 = 9;


void setup() {
  // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
  #if defined (__AVR_ATtiny85__)
    if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
  #endif
  // End of trinket special code

  pinMode(5,OUTPUT);
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {

float temp1 = 20.5;
float temp2 = 35.5;
float temp3 = 36.5;
float temp4 = 40.0;
float temp5 = 20.5;
float temp6 = 35.5;
float temp7 = 36.5;
float temp8 = 40.0;
float temp9 = 36.5;
float temp10 = 90.0;

if (temp10 > 40) {
  temp10 = 40;
  digitalWrite(5,HIGH);
  delay(1000);
  digitalWrite(5,LOW);
  delay(1000);
}

strip.setPixelColor(probe01,(temp1-20)*255/20,0,(40-temp1)*255/20);
strip.setPixelColor(probe02,(temp2-20)*255/20,0,(40-temp2)*255/20);
strip.setPixelColor(probe03,(temp3-20)*255/20,0,(40-temp3)*255/20);
strip.setPixelColor(probe04,(temp4-20)*255/20,0,(40-temp4)*255/20);
strip.setPixelColor(probe05,(temp5-20)*255/20,0,(40-temp5)*255/20);
strip.setPixelColor(probe06,(temp6-20)*255/20,0,(40-temp6)*255/20);
strip.setPixelColor(probe07,(temp7-20)*255/20,0,(40-temp7)*255/20);
strip.setPixelColor(probe08,(temp8-20)*255/20,0,(40-temp8)*255/20);
strip.setPixelColor(probe09,(temp9-20)*255/20,0,(40-temp9)*255/20);
strip.setPixelColor(probe10,(temp10-20)*255/20,0,(40-temp10)*255/20);

strip.show();
 

}

메카님의 댓글

메카 작성일

#include <OneWire.h>
#include <DallasTemperature.h>
#include <Wire.h>

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

#define PIN 6

// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//  NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//  NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//  NEO_GRB    Pixels are wired for GRB bitstream (most NeoPixel products)
//  NEO_RGB    Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//  NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(10, PIN, NEO_GRB + NEO_KHZ800);

// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel.  Avoid connecting
// on a live circuit...if you must, connect GND first.
int probe01 = 0;
int probe02 = 1;
int probe03 = 2;
int probe04 = 3;
int probe05 = 4;
int probe06 = 5;
int probe07 = 6;
int probe08 = 7;
int probe09 = 8;
int probe10 = 9;

/*-----( Declare Constants and Pin Numbers )-----*/
// Data wire is plugged into port 2 on the Arduino (can be changed)
#define ONE_WIRE_BUS 2    // NOTE: No ";" on #define 

/*-----( Declare objects )-----*/
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass address of our oneWire instance to Dallas Temperature.
DallasTemperature sensors(&oneWire);

/*-----( Declare Variables )-----*/
// Assign the addresses of your 1-Wire temp sensors.
// See the tutorial on how to obtain these addresses:
// http://arduino-info.wikispaces.com/Brick-Temperature-DS18B20#Read%20individual


 // WP 1
DeviceAddress Probe06 = {0x28, 0xFF, 0x40, 0xE0, 0x56, 0x16, 0x04, 0x65 };//
DeviceAddress Probe05 = {0x28, 0xFF, 0xCC, 0x45, 0x57, 0x16, 0x04, 0x0C };//
DeviceAddress Probe09 = {0x28, 0xFF, 0xA2, 0x4E, 0x58, 0x16, 0x04, 0x74};//
DeviceAddress Probe02 = {0x28, 0xFF, 0x61, 0x08, 0x55, 0x16, 0x03, 0x62};//
DeviceAddress Probe03 = {0x28, 0xFF, 0x51, 0x43, 0x57, 0x16, 0x04, 0x5E};//
DeviceAddress Probe10 = {0x28, 0xFF, 0x05, 0x2F, 0x54, 0x16, 0x03, 0x31};//
DeviceAddress Probe01 = {0x28, 0xFF, 0x4D, 0xA3, 0x57, 0x16, 0x04, 0x4A};//
DeviceAddress Probe07 = {0x28, 0xFF, 0xCB, 0x19, 0x54, 0x16, 0x03, 0xF0};//
DeviceAddress Probe08 = {0x28, 0xFF, 0x6B, 0xAF, 0x53, 0x16, 0x03, 0x21};//
DeviceAddress Probe04 = {0x28, 0xFF, 0x9B, 0x4C, 0x58, 0x16, 0x04, 0x04};//


void setup()  /****** SETUP: RUNS ONCE ******/
{
  // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
  #if defined (__AVR_ATtiny85__)
    if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
  #endif
  // End of trinket special code


  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
 
//------- Initialize the Temperature measurement library--------------
  Serial.begin(9600);
  sensors.begin();
  // set the resolution to 10 bit (Can be 9 to 12 bits .. lower is faster)
  sensors.setResolution(Probe01, 10);
  sensors.setResolution(Probe02, 10);
  sensors.setResolution(Probe03, 10);
}//--(end setup )---


void loop() 
{
  sensors.requestTemperatures();
  float temp1 = sensors.getTempC(Probe01);
  float temp2 = sensors.getTempC(Probe02);
  float temp3 = sensors.getTempC(Probe03);
  float temp4 = sensors.getTempC(Probe04);
  float temp5 = sensors.getTempC(Probe05);
  float temp6 = sensors.getTempC(Probe06);
  float temp7 = sensors.getTempC(Probe07);
  float temp8 = sensors.getTempC(Probe08);
  float temp9 = sensors.getTempC(Probe09);
  float temp10 = sensors.getTempC(Probe10);

  Serial.print(temp1);
  Serial.print(" ");
  Serial.print(temp2);
  Serial.print(" ");
  Serial.print(temp3);
  Serial.print(" ");
  Serial.print(temp4);
  Serial.print(" ");
  Serial.print(temp5);
  Serial.print(" ");
  Serial.print(temp6);
  Serial.print(" ");
  Serial.print(temp7);
  Serial.print(" ");
  Serial.print(temp8);
  Serial.print(" ");
  Serial.print(temp9);
  Serial.print(" ");
  Serial.println(temp10);


  strip.setPixelColor(probe01,(temp1-20)*255/20,0,(40-temp1)*255/20);
  strip.setPixelColor(probe02,(temp2-20)*255/20,0,(40-temp2)*255/20);
  strip.setPixelColor(probe03,(temp3-20)*255/20,0,(40-temp3)*255/20);
  strip.setPixelColor(probe04,(temp4-20)*255/20,0,(40-temp4)*255/20);
  strip.setPixelColor(probe05,(temp5-20)*255/20,0,(40-temp5)*255/20);
  strip.setPixelColor(probe06,(temp6-20)*255/20,0,(40-temp6)*255/20);
  strip.setPixelColor(probe07,(temp7-20)*255/20,0,(40-temp7)*255/20);
  strip.setPixelColor(probe08,(temp8-20)*255/20,0,(40-temp8)*255/20);
  strip.setPixelColor(probe09,(temp9-20)*255/20,0,(40-temp9)*255/20);
  strip.setPixelColor(probe10,(temp10-20)*255/20,0,(40-temp10)*255/20);

  strip.show();
}


모바일 버전으로 보기