孙志敏
Published © MIT

🌡️Wio Terminal Grove Temperature Sensor Project

This project demonstrates how to use the Wio Terminal with a Grove Temperature Sensor to measure and display real-time temperature data.

BeginnerFull instructions provided1 hour100
🌡️Wio Terminal Grove Temperature Sensor Project

Things used in this project

Hardware components

Wio Terminal
Seeed Studio Wio Terminal
×1
Grove - Temperature Sensor
Seeed Studio Grove - Temperature Sensor
×1
USB Cable, USB Type C Plug
USB Cable, USB Type C Plug
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Computer / laptop
USB Type-C Cable

Story

Read more

Schematics

Wiring Diagram

Code

running code

C/C++
#include <math.h>
#include "TFT_eSPI.h"
#include "SPI.h"

const int B = 4275;             // Grove Temp Sensor V1.2 官方 B 值
const int R0 = 100000;          // R0 = 100k
const int pinTempSensor = A0;   // Grove - Temperature Sensor 接 A0

TFT_eSPI tft = TFT_eSPI();      // TFT 对象

// 自动检测 ADC 分辨率
int adcMax = 1023; // 默认 10 位 ADC
bool checked = false;

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

    // 初始化屏幕
    tft.begin();
    tft.setRotation(3);
    tft.fillScreen(TFT_BLACK);
    tft.setTextColor(TFT_GREEN, TFT_BLACK);
    tft.setTextSize(2);

    tft.setCursor(20, 20);
    tft.println("Grove Temp Sensor");
}

void loop() {
    int a = analogRead(pinTempSensor);

    // 自动检测 ADC 分辨率
    if (!checked) {
        if (a > 1023) adcMax = 4095; // 说明是 12 位 ADC
        checked = true;
        Serial.print("Detected ADC Max = ");
        Serial.println(adcMax);
    }

    float R = (float)adcMax / a - 1.0;
    R = R0 * R;

    float temperature = 1.0 / (log(R / R0) / B + 1 / 298.15) - 273.15; // 摄氏度

    // 串口输出
    Serial.print("temperature = ");
    Serial.print(temperature, 1);
    Serial.println(" C");

    // 屏幕显示
    tft.fillRect(20, 80, 200, 40, TFT_BLACK); // 清除旧数据显示区域
    tft.setCursor(20, 80);
    tft.print("Temp: ");
    tft.print(temperature, 1); // 保留 1 位小数
    tft.println(" C");

    delay(1000);
}

Credits

孙志敏
1 project • 1 follower

Comments