亿迅智能制造网
工业4.0先进制造技术信息网站!
首页 | 制造技术 | 制造设备 | 工业物联网 | 工业材料 | 设备保养维修 | 工业编程 |
home  MfgRobots >> 亿迅智能制造网 >  >> Manufacturing Technology >> 制造工艺

多位置温度传感器系统,助力智能家居集成

元器件与物料

元器件数量备注
DS18B20 温度传感器81-Wire 总线数字温度传感器,价格低廉、易于级联
螺丝1用于固定外壳
Arduino Nano R31主控微控制器
实验用 PCB 板1焊接传感器与上拉电阻
4.7kΩ 电阻11-Wire 总线上拉电阻
两位螺丝接线端子1外部供电/信号接口
SparkFun RS232 电平转换模块 (SMD)1将 Arduino TTL 串口转换为 RS232 电平
3D 打印外壳1含底盖、顶盖、DB9 安装座
导线1内部连线

所需工具与设备

软件与在线服务

项目简介

本项目旨在以低成本实现多点温度采集,并将数据通过 RS232 接口对接 Crestron/AMX 等中控系统。选用 DS18B20 的理由:广泛可得、单价低、支持总线拓扑,一根数据线即可挂载多个传感器。

八个传感器并联在 1-Wire 总线上,由 Arduino Nano 轮询读取,串口以 9600 波特率输出文本格式温度值。为适配工控设备,TTL 电平经 MAX3232 芯片转换为标准 RS232 电平。所有电子元件安装在定制 PCB 上,整体收纳于 3D 打印外壳内,外观整洁、安装便捷。

多位置温度传感器系统,助力智能家居集成
多位置温度传感器系统,助力智能家居集成
多位置温度传感器系统,助力智能家居集成

核心代码

代码基于 OneWire 与 DallasTemperature 库,预存 8 个传感器的 64-bit ROM 地址,分辨率设为 10 位(约 0.25°C),每 10 秒轮询一次,每 360 次循环(约 1 小时)自动扫描总线设备数量,防止传感器脱落未被发现。

/* MultiTempSensor v1.0.0 by WT040 */
#include <OneWire.h>
#include <DallasTemperature.h>

#define SENSOR_PIN 12
#define READ_TIMER 10000

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

// 8 个传感器的固定地址
DeviceAddress Sensor1 = { 0x28, 0xFF, 0x89, 0x0F, 0x61, 0x16, 0x03, 0x40 };
DeviceAddress Sensor2 = { 0x28, 0xFF, 0xE2, 0x0F, 0x61, 0x16, 0x03, 0x21 };
DeviceAddress Sensor3 = { 0x28, 0xFF, 0x38, 0xB3, 0x60, 0x16, 0x03, 0xEA };
DeviceAddress Sensor4 = { 0x28, 0xFF, 0xA4, 0xBE, 0x60, 0x16, 0x03, 0xE1 };
DeviceAddress Sensor5 = { 0x28, 0xFF, 0xFE, 0x13, 0x61, 0x16, 0x03, 0x56 };
DeviceAddress Sensor6 = { 0x28, 0xFF, 0x89, 0xBA, 0x60, 0x16, 0x03, 0xFB };
DeviceAddress Sensor7 = { 0x28, 0xFF, 0xFA, 0xBC, 0x60, 0x16, 0x03, 0xD1 };
DeviceAddress Sensor8 = { 0x28, 0xFF, 0x57, 0xB1, 0x60, 0x16, 0x03, 0x93 };

int amountOfSensors = 8;
int counterCheckBus = 0;

void setup() {
  Serial.begin(9600);
  sensors.begin();
  for (int i = 1; i <= 8; i++) {
    DeviceAddress *addr = (i==1)?&Sensor1:(i==2)?&Sensor2:(i==3)?&Sensor3:(i==4)?&Sensor4:
                          (i==5)?&Sensor5:(i==6)?&Sensor6:(i==7)?&Sensor7:&Sensor8;
    sensors.setResolution(*addr, 10);
  }
  getSensorsOnBus();
  Serial.println(F("System initialized"));
}

void loop() {
  counterCheckBus++;
  delay(READ_TIMER);
  Serial.println();
  if (counterCheckBus == 360) { getSensorsOnBus(); counterCheckBus = 0; }

  sensors.requestTemperatures();
  for (int i = 1; i <= 8; i++) {
    DeviceAddress *addr = (i==1)?&Sensor1:(i==2)?&Sensor2:(i==3)?&Sensor3:(i==4)?&Sensor4:
                          (i==5)?&Sensor5:(i==6)?&Sensor6:(i==7)?&Sensor7:&Sensor8;
    Serial.print(F("Sensor ")); Serial.print(i); Serial.print(F(": "));
    printTemperature(*addr);
    Serial.println();
  }
}

void printTemperature(DeviceAddress deviceAddress) {
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC == -127.00) Serial.print(F("Sensor error!"));
  else { Serial.print(F("C: ")); Serial.print(tempC); }
}

void getSensorsOnBus() {
  Serial.print(F("Number of sensors found on bus: "));
  Serial.println(sensors.getDeviceCount());
}

自定义零件与外壳

提供 3 个 STL 文件:底盖、顶盖、DB9 安装座。建议使用 PETG 材料打印,耐候性更好。

原理图

基本原理图(不含 RS232 模块)见附件。8 个 DS18B20 数据线并联在 D12,上拉 4.7kΩ 至 VCC,供电 5V,地共地。RS232 模块连接 Arduino TX/RX 引脚。

制造工艺

  1. 树莓派+$5 I²C传感器打造温度记录仪
  2. 树莓派与 Python 构建远程温度传感器:分步实战指南
  3. 树莓派多传感器温度光照监测系统:DS18B20 实战构建
  4. 树莓派 + MCP9808 + InfluxDB + Grafana:家庭温度监测系统
  5. DasFilisera 智能温室:高级植物生长监测系统
  6. MotionSense:基于 Arduino 与 ESP8266 的智能入侵检测系统
  7. 3D 打印机防火卫士:智能传感器安全系统
  8. Arduino 简易排斥式磁悬浮:电路与 DIY 指南
  9. 进阶遥控夹爪机器人:精密抓取 DIY 指南
  10. CoroFence 热成像检测器:Panasonic GridEye + PIR + IoT 集成
  11. 高精度轴承温度传感器:原理、安装与SKF PT100选型指南
  12. DS18B20温度传感器:精准1-Wire数字温度计,工业与消费级首选