“温湿度”的版本间的差异

来自Labplus盛思维基百科
跳转至: 导航搜索
技术参数
使用教程
 
(未显示3个用户的15个中间版本)
第25行: 第25行:
  
 
== 使用教程 ==
 
== 使用教程 ==
=== 连接示意图 ===
+
=== <font size="3">掌控板及mPython编程</font> ===
=== Arduino示例 ===
+
 
=== MicroPython示例 ===
 
 
<pre style="color:blue">
 
<pre style="color:blue">
from microbit import *
+
#程序功能:用掌控板OLED显示屏显示温湿度传感器测量的温度和湿度值。
 +
</pre>
 +
{|
 +
|-
 +
| [[文件:温湿度接线图.png |800px|居中|无框]]
 +
|-
 +
|style="text-align:center"|连接示意图
 +
|}
 +
<br/>
  
def getTemp():
+
{|
  i2c.write(0x40,bytearray([0xE3]))
+
|-
  sleep(85)
+
| [[文件:温湿度mPython编程.png |900px|居中|无框]]
  t=i2c.read(0x40,2)
+
|-
  return -46.86+175.72*(t[0]*256+t[1])/65535
+
|style="text-align:center"|图形化及mPython代码
 
+
|}
 
+
<br/>
def getHumi():
+
<br/>
  i2c.write(0x40,bytearray([0xE5]))
+
=== <font size="3">Arduino示例</font> ===
  sleep(40)
+
[http://wiki.labplus.cn/index.php?title=文件:SHT20_test.rar 温湿度库下载]
  t=i2c.read(0x40,2)
+
<pre style="color:blue">
  return -6+125*(t[0]*256+t[1])/65536
+
//程序功能:读取当前的温湿度值//
 
+
#include <Wire.h>
while True:
+
#include "SHT20.h"
     print('TEMP:',getTemp())  #获取温度并打印出来
+
SHT20    sht20;
     print('HUMi:',getHumi())  #获取湿度并打印出来
+
void setup()
     sleep(500)
+
{
 +
    Serial.begin(9600);
 +
    Serial.println("SHT20 Example!");
 +
    sht20.initSHT20();                                  // Init SHT20 Sensor
 +
    delay(100);
 +
    sht20.checkSHT20();                                // Check SHT20 Sensor
 +
}
 +
void loop()
 +
{
 +
    float humd = sht20.readHumidity();                  // Read Humidity
 +
    float temp = sht20.readTemperature();              // Read Temperature
 +
//    Serial.print("Time:");
 +
//    Serial.print(millis());
 +
    Serial.print(" Temperature:");
 +
    Serial.print(temp, 1);
 +
    Serial.print("C");
 +
    Serial.print(" Humidity:");
 +
     Serial.print(humd, 1);
 +
     Serial.print("%");
 +
    Serial.println();
 +
     delay(1000);
 +
}
 
</pre>
 
</pre>
  
=== 图形化示例 ===
+
===<font size="3"> Bluebit主控</font> ===
 +
{|
 +
|-
 +
|实物连接如下图:
 +
|-
 +
|[[文件:温湿度实物连接.png|700px|无框|左]]
 +
|-
 +
|程序功能:利用数码管分别显示温度和湿度的值
 +
|-
 +
|[[文件:温湿度1.png|900px|无框|左]]
 +
|}
 +
 
 +
== 版本历史记录 ==
 +
 
 +
{|  border="1" cellspacing="0" align="left" cellpadding="0" width="60%" style="text-align:center;"
 +
|- style="text-align:center;background-color:#6fa8dc;color:#fffff;"
 +
!width="10%"|Version !!width="15%"| Date !! Note  <small>[+]新增[-]删除[^]修复</small>
 +
|-
 +
| V2.0 || || style="text-align:left"|
 +
|}

2020年4月16日 (四) 14:26的最新版本

黑色传感器最终版12.20-28.png

概述

基于SHT20数字温湿度传感器集成IC。用于检测环境温湿度,具有极高的可靠性和长期稳定性。采用I2C通讯方式,操作简便。

技术参数

  • 工作电压:VCC 3.3-5V
  • I2C数字信号输出
  • 温度测量范围:-40~125℃
  • 温度测量精度:±0.3℃
  • 湿度测量范围:0~100%RH
  • 湿度测量精度:±3%RH
  • 模块尺寸:24x46x7.5mm

引脚定义

VCC 电源
SDA I2C数据
SCL I2C时钟
GND

使用教程

掌控板及mPython编程

#程序功能:用掌控板OLED显示屏显示温湿度传感器测量的温度和湿度值。
温湿度接线图.png
连接示意图


温湿度mPython编程.png
图形化及mPython代码



Arduino示例

温湿度库下载

//程序功能:读取当前的温湿度值//
#include <Wire.h>
#include "SHT20.h"
SHT20    sht20;
void setup()
{
    Serial.begin(9600);
    Serial.println("SHT20 Example!");
    sht20.initSHT20();                                  // Init SHT20 Sensor
    delay(100);
    sht20.checkSHT20();                                 // Check SHT20 Sensor
}
void loop()
{
    float humd = sht20.readHumidity();                  // Read Humidity
    float temp = sht20.readTemperature();               // Read Temperature
//    Serial.print("Time:");
//    Serial.print(millis());
    Serial.print(" Temperature:");
    Serial.print(temp, 1);
    Serial.print("C");
    Serial.print(" Humidity:");
    Serial.print(humd, 1);
    Serial.print("%");
    Serial.println();
    delay(1000);
}

Bluebit主控

实物连接如下图:
温湿度实物连接.png
程序功能:利用数码管分别显示温度和湿度的值
温湿度1.png

版本历史记录

Version Date Note [+]新增[-]删除[^]修复
V2.0