ขอออกตัวก่อนนะครับ ว่ามือใหม่มากๆๆ ขอสอบถามดังนี้ ไม่ทราบว่า sht15 ตัวแบบในรูปนี้ สามารถต่อเข้ากับ บอร์ด Arduino Uno R3 แบบ SMD ได้รึปล่าวครับ เพราะที่ผมทดลองต่อดู แล้วได้ค่าออกมาแบบในรูปครับ เลยไม่ทราบว่าเป็นปัญหาที่ส่วนไหน เพราะโค้ดก็คอมไพลผ่านตามปกติ
สายไฟที่ต่อเป็นดังนี้ครับ
สายสีดำ ----กราวด์
สีแดง ------+5โวลต์
สีเหลือง-----data ต่อขา 10
สีขาว ck ต่อขา11
สีแดงขวาสุด------- ไม่ใช้
โค้ดครับ
/**
* ReadSHT1xValues
*
* Read temperature and humidity values from an SHT1x-series (SHT10,
* SHT11, SHT15) sensor.
*
* Copyright 2009 Jonathan Oxer <jon@oxer.com.au>
* www.practicalarduino.com
*/
#include <SHT1x.h>
// Specify data and clock connections and instantiate SHT1x object
#define dataPin 10
#define clockPin 11
SHT1x sht1x(dataPin, clockPin);
void setup()
{
Serial.begin(38400); // Open serial connection to report values to host
Serial.println("Starting up");
}
void loop()
{
float temp_c;
float temp_f;
float humidity;
// Read values from the sensor
temp_c = sht1x.readTemperatureC();
temp_f = sht1x.readTemperatureF();
humidity = sht1x.readHumidity();
// Print the values to the serial port
Serial.print("Temperature: ");
Serial.print(temp_c, DEC);
Serial.print("C / ");
Serial.print(temp_f, DEC);
Serial.print("F. Humidity: ");
Serial.print(humidity);
Serial.println("%");
delay(2000);
}
โค้ดนี้ก้อปมาจากอินเตอร์เน็ตนะครับ
ใช้กับ arduino uno smd ได้แน่นอน ลองดูโคดตัวอย่างนี้ครับ
https://gist.github.com/cannikin/1302409
รันโค้ดตามตัวอย่างแล้ว ไม่ผ่านครับ คล้ายๆกับว่าไม่มีไฟล์ directory รึปล่าว แล้วควรแก้ไขอย่างไรครับ
ลองตัวอย่างโคดนี้ครับ https://gist.github.com/cannikin/1302409