项目概述

这是一个基于Arduino的简易温度监测系统,可实时显示环境温度。适合初学者学习传感器数据读取与LCD显示技术。
👉 点击了解如何将温度数据上传至物联网平台

所需硬件

  • Arduino Uno开发板 📌
  • 温度传感器(如DHT11或DS18B20)🌡️
  • 1602 LCD显示屏 🖥️
  • 电阻(4.7kΩ)🔌
  • 杜邦线若干 📦

实现步骤

  1. 电路连接

    • 将传感器VCC接Arduino 5V,GND接GND
    • 数据引脚连接到Arduino数字引脚(如D2)
    • LCD的VSS、VDD接GND和5V,V0通过电位器调节对比度
    • LCD的RS、E、D4-D7分别连接到Arduino的D7/D8/D9/D10/D11/D12
  2. 代码编写

    #include <DHT.h>
    #include <LiquidCrystal.h>
    
    define DHT_PIN 2
    define LCD_RS 7
    define LCD_E 8
    define LCD_D4 9
    define LCD_D5 10
    define LCD_D6 11
    define LCD_D7 12
    
    DHT dht(DHT_PIN, DHT11);
    LiquidCrystal lcd(LCD_RS, LCD_E, LCD_D4, LCD_D5, LCD_D6, LCD_D7);
    
    void setup() {
      lcd.begin(16, 2);
      dht.begin();
    }
    
    void loop() {
      float temperature = dht.readTemperature();
      lcd.print("温度: ");
      lcd.print(temperature);
      lcd.print("°C");
      delay(1000);
    }
    
  3. 测试与调试

    • 确保传感器数据稳定,避免读数异常
    • 检查LCD显示是否清晰,调整电位器位置

扩展建议

  • 尝试添加蜂鸣器报警功能 🔊
  • 使用WiFi模块实现远程数据传输 🌐
  • 替换为数字温度传感器(如DS18B20)提升精度 ❄️
Arduino_Uno
DHT11
LCD1602