【Hardware】【HTS221笔记】

HTS221简介:

HTS221 是ST生产的紧凑型(HLGA-6L:2x2x0.9mm)数字温、湿度传感器。基本参数如下:

工作电压:1.7~3.6V
低功耗:2μA@1Hz ODR
数据输出频率(ODR)可设:1Hz ~ 12.5Hz
内置16-bit ADC
16bit温湿度数据
主机接口:I2C或3-wire SPI
封装:2 x 2 x 0.9mm HLGA-6L封装
片上集成加热器(heater)

管脚定义如下:

主机通信模式:

I2C模式(常用): CS悬空(内部上拉)或连接至VDD。HTS221 I2C slave地址:BEh(write)、BFh(read)
SPI模式: CS连接至GND。


参考设计:

HTS221的硬件设计可以参考如下:

为了保证测量的温湿度准确性,PCB和外壳的设计尤其重要,一些设计规则建议如下:

1.Maximize sensor’s exposure to the environment where humidity and temperature are measured
2.Place sensor at the correct distance from heat sources(recommend to adopt thermal insulation)
3.Adopt thin metal lines around the sensor
4.Avoid any mechanical force applied to the sensor
5.Avoid direct exposure of the sensor to light


软件测试:

HTS221的寄存器列表地址如下:

  • Reserved寄存器是不允许改变的,强行改变可能会对芯片造成永久性损坏
  • CALIB_0…F的内容(用于温湿度矫正/计算)上电后从芯片内部非遗失存储处加载,不允许改变

我们使用 Espressif - i2c tools 进行简单的测试如下。

i2c_tools 代码的编译、测试可以参考README.md文档的介绍,执行 make -j4 flash monitor 时可能会遇到以下问题:

$ make -j4 flash monitor
Toolchain path: /opt/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc
Toolchain version: crosstool-ng-1.22.0-80-g6c4433a5
Compiler version: 5.2.0
CXX build/asio/asio/asio/src/asio.o
The following Python requirements are not satisfied:
cryptography>=2.1.4
pyparsing>=2.0.3
The recommended way to install a packages is via "pacman". Please run "pacman -Ss <package_name>" for searching the package database and if found then "pacman -S mingw-w64-i686-python2-<package_name>" for installing it.
NOTE: You may need to run "pacman -Syu" if your package database is older and run twice if the previous run updated "pacman" itself.
Please read https://github.com/msys2/msys2/wiki/Using-packages for further information about using "pacman"
WARNING: The cryptography package have dependencies on system packages so please make sure you run "pacman -Syu" followed by "pacman -S mingw-w64-i686-python2-cryptography".
Alternatively, you can run "C:/msys32/mingw32/bin/python.exe -m pip install --user -r C:/msys32/home/esp/esp-idf/requirements.txt" for resolving the issue.
make: *** [/home/esp/esp-idf//make/project.mk:500:check_python_dependencies] 错误 1
make: *** 正在等待未完成的任务....
App "i2c-tools" version: v3.3-beta2-60-g86c9b6354
AR build/asio/libasio.a

按照提示操作即可,执行命令如下:

$pacman -Syu
$pacman -S mingw-w64-i686-python2-cryptography
$pacman -S mingw-w64-i686-python2-pyparsing

下载完成后,执行 make monitor或者使用串口工具:

I (233) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.

 ==============================================================
 |       Steps to Use i2c-tools on ESP32                      |
 |                                                            |
 |  1. Try 'help', check all supported commands               |
 |  2. Try 'i2cconfig' to configure your I2C bus              |
 |  3. Try 'i2cdetect' to scan devices on the bus             |
 |  4. Try 'i2cget' to get the content of specific register   |
 |  5. Try 'i2cset' to set the value of specific register     |
 |  6. Try 'i2cdump' to dump all the register (Experiment)    |
 |                                                            |
 ==============================================================

esp32>  i2cconfig --port=0 --sda=14 --scl=13 --freq=100000
esp32> i2cdetect
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 5f 
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- 
70: -- -- -- -- 74 -- -- -- -- -- -- -- -- -- -- -- 
esp32> i2cget -c 0x5f -r 0x0f -l 1
0xbc 
esp32> 

参考资料
HTS221 参考资料
github:stm32duino - HTS221

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值