【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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章