跳转到内容

Arduino库

如果您不使用Arduino, 可以看看开发章节

安装

PlatformIO

在PlatformIO中使用本库,在platformio.ini中添加如下内容或者通过UI搜索BULLM_SensorModule添加

ini
[env:myenv]
...
lib_deps = 
  bullm/BULLM_SensorModule
...

Arduino IDE

在Arduino IDE中,直接在库管理器中搜索BULLM_SensorModule并安装即可。

简单示例

c
#include <Arduino.h>
#include <Wire.h>
#include "BULLM_SensorVoltage.h"

BULLM_SensorVoltage sensor(0x48);

void setup() {
    Wire.begin(); // 初始化I2C
    Serial.begin(9600);

    if (!sensor.begin()) {
        Serial.println("BULLM_SensorVoltage not found");
        return;
    }
    Serial.println("BULLM_SensorVoltage found");
}


void loop() {
    Serial.print("Voltage -> ");
    Serial.println(sensor.getVoltage(), 3);
    delay(100);
}

库开源地址