这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » DIY与开源设计 » 电子DIY » 【e起DIY】低功耗蓝牙温湿度计基于​nRF54L15DK官方开发板读取HDC1

共2条 1/1 1 跳转至

【e起DIY】低功耗蓝牙温湿度计基于​nRF54L15DK官方开发板读取HDC1080温湿度

高工
2026-06-10 23:16:14     打赏

  

nRF54L15 DK(PCA10156)是 Nordic 为nRF54L 系列(nRF54L15/L10/L05)推出的官方单板开发平台,主打超低功耗、多协议无线、安全物联网应用,支持 SoC 全功能评估与量产固件开发。

一、核心硬件规格

1. 主控 SoC

 nRF54L15(QFN48),可硬件仿真 nRF54L10/L05

 内核:Arm Cortex‑M33(128 KB RAM),加 RISC‑V 协处理器

 存储:1 MB Flash + 8 MB 外部闪存

 无线:2.4 GHz 收发器,BLE 5.4/LE Audio/Auracast、802.15.4、Thread、Zigbee、NFC、2.4G 私有协议

2. 开发板板载关键外设

 调试:SEGGER J‑Link OB(板载,免外部调试器)

 电源:nPM1300 PMIC,1.8–3.3 V 可编程,支持功耗测量引脚

 天线:2.4 GHz 板载天线 + NFC 天线(PCA64110),带 SWF 射频开关(可直连仪器测 RF)

 人机:4×LED、4×按键、2×UART(虚拟串口)

 时钟:32 MHz HFXO、32.768 kHz LFXO

 扩展:Arduino 兼容引脚、GPIO 排针、电流测量跳线

3.温湿度传感器选型:HDC1080是 TI(德州仪器)推出的低功耗、高精度数字温湿度传感器,集成湿度 + 温度传感单元,出厂校准,适合电池供电、长期监测的 IoT / 嵌入式场景。

4.开发环境搭建:

  4.1 nRF Connect SDK(v3.2+):基于 Zephyr RTOS,含协议栈、驱动、示例

H1.png

 4 .2开发环境:VS Code 插件 + 命令行,支持 C/C++ 开发

 4.3 协议支持:BLE 5.4(含 LE Audio)、Thread 1.3、Zigbee 3.0、NFC‑A/B

 4.4 云服务:nRF Cloud 接入示例,支持设备管理、OTA、位置服务

官方连接:

   1,zephyr project for nRF54L15 DK

  https://docs.zephyrproject.org/latest/boards/nordic/nrf54l15dk/doc/index.html

  2.环境搭建:

   https://jishuzhan.net/article/2002249110053781505

https://nrfconnectdocs.nordicsemi.com/ncs/latest/nrf/installation/install_ncs.html

5.驱动开发:

  

H2.png

关键代码

#include "hdc1080.h"
#include "iic.h"
#include <zephyr/kernel.h>
#include <stdio.h>

#define HDC1080_ADDR_W 0x80
#define HDC1080_ADDR_R 0x81

bool hdc1080_init(void)
{
    i2c_start();
    if (i2c_write_byte(HDC1080_ADDR_W))
        goto fail;
    if (i2c_write_byte(0x02)) // 配置寄存器
        goto fail;
    if (i2c_write_byte(0x10)) // 温湿度均 14bit
        goto fail;
    if (i2c_write_byte(0x00))
        goto fail;
    i2c_stop();
    printf("HDC1080 init OK\n");
    return true;

fail:
    i2c_stop();
    printf("HDC1080 init FAIL\n");
    return false;
}

bool hdc1080_read(int *temp, int *humi)
{
    uint8_t t_msb, t_lsb, h_msb, h_lsb;

    /* 触发测量 */
    i2c_start();
    if (i2c_write_byte(HDC1080_ADDR_W))
        goto fail;
    if (i2c_write_byte(0x00)) // 温度寄存器
        goto fail;
    i2c_stop();

    k_msleep(20); // 等待转换完成

    /* 读取数据 */
    i2c_start();
    if (i2c_write_byte(HDC1080_ADDR_R))
        goto fail;

    t_msb = i2c_read_byte(1); // ACK
    t_lsb = i2c_read_byte(1); // ACK
    h_msb = i2c_read_byte(1); // ACK
    h_lsb = i2c_read_byte(0); // NACK

    i2c_stop();

    uint16_t temp_raw = (t_msb << 8) | t_lsb;
    uint16_t humi_raw = (h_msb << 8) | h_lsb;

    *temp = ((int32_t)temp_raw * 165) / 65536 - 40;
    *humi = ((int32_t)humi_raw * 100) / 65536;

    return true;

fail:
    i2c_stop();
    return false;
}
#ifndef HDC1080_H
#define HDC1080_H

#include <stdbool.h>

/**
 * @brief 初始化 HDC1080,配置 14bit 温湿度测量
 * @return true 成功,false 失败
 */
bool hdc1080_init(void);

/**
 * @brief 读取温湿度
 * @param temp 温度(°C)
 * @param humi 相对湿度(%)
 * @return true 成功,false 失败
 */
bool hdc1080_read(int *temp, int *humi);

#endif /* HDC1080_H */

main.c

#include <zephyr/kernel.h>
#include <stdio.h>
#include "iic.h"
#include "hdc1080.h"

int main(void)
{
        printf("HDC1080 SW I2C Start\n");

        if (i2c_pins_init() != 0)
        {
                printf("I2C pin init failed\n");
                return -1;
        }

        k_msleep(20); // 上电等待

        if (!hdc1080_init())
        {
                printf("Init failed!\n");
                return -1;
        }

        while (1)
        {
                int t, h;
                if (hdc1080_read(&t, &h))
                {
                        printf("Temp: %d C, Humi: %d %%\n", t, h);
                }
                else
                {
                        printf("Read fail (check pull-up!)\n");
                }
                k_msleep(1000);
        }
        return 0;
}

M05.jpg



高工
2026-06-11 08:55:28     打赏
2楼

MD的,作假都不错全套的,真丢工程师的脸!


共2条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]