NGHỆ THUẬT
LÀM ĐẸP VÀ SỨC KHỎE
THỦ CÔNG
VĂN HÓA VÀ LỊCH SỬ
GIẢI TRÍ
MÔI TRƯỜNG
THỰC PHẨM VÀ ĐỒ UỐNG
KỸ THUẬT NGƯỢC
KHOA HỌC
THỂ THAO
CÔNG NGHỆ
THIẾT BỊ ĐEO
Data-Logging Thermometer
Ed

Tạo bởi

Ed

14. tháng Tám 2026FI
107
0
0
0
0

Data-Logging Thermometer

A thermometer that writes every reading to a microSD card as CSV, so the record survives after the power goes. A waterproof DS18B20 probe on the 1-Wire bus, a microSD shield on SPI, an Arduino Uno in between. The probe is sealed in a stainless tube, so it can go into soil, a fermenter, a fridge or a stream with no further packaging. Accuracy is the sensor's own: plus or minus 0.5 degrees Celsius between -10 and +85 degrees Celsius, over a full range of -55 to +125.
Cơ bản
2 hours

Hướng dẫn

1

Solder headers to the microSD shield

Solder the stacking headers to the microSD shield.

  1. Seat the headers in the shield from the top.
  2. Tack one pin at each end first, then check the header sits square before doing the rest.
  3. Give each joint about two seconds of heat.
A dull, blobbed joint on an SPI line reads cards intermittently — which looks like a bad card, not a bad joint.

Vật liệu cho bước này:

microSD ShieldmicroSD Shield1 cái

Công cụ cần thiết:

Ryobi ONE+ RSI18-0 Cordless Soldering IronRyobi ONE+ RSI18-0 Cordless Soldering Iron
2

Wire the probe — pin by pin

Stack the shield on the Uno, then wire the probe on the breadboard.

  1. Probe red → Arduino 5V
  2. Probe black → Arduino GND
  3. Probe yellow (data) → Arduino D2
  4. 4.7 kΩ resistor between D2 and 5V

The shield already uses D11 MOSI, D12 MISO, D13 SCK and D8 as card select. Leave those four alone.

The 4.7 kΩ pull-up is not optional. The 1-Wire bus is open-drain: without it the bus never rises and every reading comes back -127.

Vật liệu cho bước này:

Cảm biến nhiệt độCảm biến nhiệt độ1 cái
Arduino Uno R3Arduino Uno R31 cái
Bộ điện trở 1/4 WBộ điện trở 1/4 W1 bộ
Bảng cắm mạchBảng cắm mạch1 cái
Dây nốiDây nối1 gói
3

Power it, and decide how it will run

For setup and for reading the serial monitor, the USB-B cable from the computer both powers the board and carries the upload.

To leave it logging away from a computer, feed 7–12 V into the Uno's barrel jack instead, or a regulated 5 V into the 5V pin. Do not do both at once.

The card only receives what was written and closed. Pulling power mid-write loses at most the sample in flight, because the sketch closes the file after every line.

Công cụ cần thiết:

Cáp USB-BCáp USB-B
4

Format the card

Format the microSD card as FAT32.

The Arduino SD library cannot read exFAT, which is what cards larger than 32 GB are formatted with from the factory. A card that 'does not work' is nearly always this.
5

Upload the logging sketch

Install OneWire and DallasTemperature via Library Manager. SD and SPI ship with the IDE. Select Tools → Board → Arduino Uno, then Upload.

temp_logger.inoarduino
// Data-Logging Thermometer
// DS18B20 (1-Wire, D2) -> Arduino Uno -> microSD Shield (SPI, CS on D8)
// Appends one CSV line per reading: millis,celsius

#include <OneWire.h>
#include <DallasTemperature.h>
#include <SPI.h>
#include <SD.h>

const int  ONE_WIRE_PIN = 2;      // DS18B20 data. Needs a 4.7k pull-up to 5V.
const int  SD_CS_PIN    = 8;      // Card select on the SparkFun microSD Shield
const unsigned long INTERVAL_MS = 10000;   // one sample every 10 s
const char LOG_FILE[]   = "templog.csv";

OneWire oneWire(ONE_WIRE_PIN);
DallasTemperature sensors(&oneWire);

void setup() {
  Serial.begin(9600);
  sensors.begin();

  if (!SD.begin(SD_CS_PIN)) {
    // Card absent, not FAT32, or CS on the wrong pin. Stop rather than
    // pretend to log -- a logger that silently writes nothing is worse
    // than one that refuses to start.
    Serial.println(F("SD init failed: card absent, not FAT32, or wrong CS pin"));
    while (true) { }
  }

  // Write the header once, only if the file does not exist yet.
  if (!SD.exists(LOG_FILE)) {
    File f = SD.open(LOG_FILE, FILE_WRITE);
    if (f) { f.println(F("millis,celsius")); f.close(); }
  }
  Serial.println(F("logging to templog.csv"));
}

void loop() {
  sensors.requestTemperatures();
  float c = sensors.getTempCByIndex(0);

  if (c == DEVICE_DISCONNECTED_C) {
    // -127 means the bus never went high: almost always the missing pull-up.
    Serial.println(F("no sensor -- check the 4.7k pull-up between D2 and 5V"));
  } else {
    File f = SD.open(LOG_FILE, FILE_WRITE);   // FILE_WRITE appends
    if (f) {
      f.print(millis());
      f.print(',');
      f.println(c, 2);
      f.close();          // close == flush; a power cut loses at most this sample
    } else {
      Serial.println(F("could not open log file"));
    }
    Serial.println(c, 2);
  }

  delay(INTERVAL_MS);
}
6

Verify against a known point

Put the probe in a stirred ice-water bath — ice and water together, not ice alone.

  1. A correct DS18B20 settles at 0.0 °C ± 0.5.
  2. A constant -127 means no sensor on the bus: pull-up missing or data on the wrong pin.
  3. A constant 85.0 is the sensor's power-on default — it was read before its first conversion finished.
Calibrate against a known point before trusting any logged series. An uncalibrated log is a graph of nothing.

Vật liệu

6
  • microSD ShieldHoa hồng 10%
    1 cái
    $14.53
  • 1 cái
    6 vendors sell this, none ship to you yet
    Tạm thời
  • 1 cái
    1 vendor sell this, none ship to you yet
    Tạm thời
  • Tạm thời
  • 1 cái
    1 vendor sell this, none ship to you yet
    Tạm thời
  • 1 gói
    3 vendors sell this, none ship to you yet
    Tạm thời

Công cụ yêu cầu

2
Tổng ước tính
Những gì người làm đã mua. Vật liệu không hiện giá thì bạn mua ở đâu tuỳ bạn.
$14.53

Bản thiết kế này làm ra

CC0 Phạm vi công cộng

Bản thiết kế này được phát hành theo CC0. Bạn tự do sao chép, sửa đổi, phân phối và sử dụng cho bất kỳ mục đích nào mà không cần xin phép.

Hỗ trợ nhà sáng tạo bằng cách mua sản phẩm qua bản thiết kế, nơi họ nhận Hoa hồng nhà sáng tạo do nhà bán hàng đặt, hoặc tạo phiên bản mới và kết nối trong bản thiết kế riêng để chia sẻ doanh thu.

Thảo luận

(0)

Đăng nhập để tham gia thảo luận

Đang tải bình luận...