求助:关于UNO系统下HIH61xx温湿度传感器输出问题-Arduino中文社区 - Powered by Discuz!

Arduino中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 2117|回复: 0

[未解决] 求助:关于UNO系统下HIH61xx温湿度传感器输出问题

[复制链接]
发表于 2020-11-4 21:10 | 显示全部楼层 |阅读模式
本人初学arduino,在使用I2C协议连接HIH6120系列的温湿度传感器后运行程序发现只有第一次又正确的响应,后续的响应全是乱码。求大佬指教究竟哪里出现了问题orz
// This example demonstrates how to use the HIH61xx class with the Wire library. A blocking read is made to the
// HIH61xx device. See HIH61xx_Wire_demo for a more sophisticated example which allows other tasks to run
// whilst the HIH61xx takes its measurements.


#include <Wire.h>
#include <HIH61xx.h>
#include <AsyncDelay.h>

// The "hih" object must be created with a reference to the "Wire" object which represents the I2C bus it is using.
// Note that the class for the Wire object is called "TwoWire", and must be included in the templated class name.
HIH61xx<TwoWire> hih(Wire);

AsyncDelay samplingInterval;

void setup(void)
{
#if F_CPU >= 12000000UL
    Serial.begin(115200);
#else
        Serial.begin(9600);

#endif


        Wire.begin();

        hih.initialise();
        samplingInterval.start(3000, AsyncDelay::MILLIS);

}


void loop(void)
{

    // Instruct the HIH61xx to take a measurement. This blocks until the measurement is ready.
    hih.read();

    // Fetch and print the results
    Serial.print("Relative humidity: ");
    Serial.print(hih.getRelHumidity() / 100.0);
    Serial.println(" %");
    Serial.print("Ambient temperature: ");
    Serial.print(hih.getAmbientTemp() / 100.0);
    Serial.println(" deg C");
    Serial.print("Status: ");
    Serial.println(hih.getStatus());



    // Wait a second
    delay(1000);
}

运行的结果

运行的结果
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|Archiver|手机版|Arduino中文社区

GMT+8, 2024-11-29 20:32 , Processed in 0.108740 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表