IZU2020 / PQINA226

Dependents:   IZU2020_AVIONICS IZU2020_AVIONICS

Embed: (wiki syntax)

« Back to documentation index

INA226 Class Reference

INA226 Class Reference

電圧電流センサINA226のライブラリ More...

#include <PQINA226.h>

Public Member Functions

 INA226 (I2C &i2c, A0_t A0, A1_t A1)
void begin ()
 センサ動作開始
bool test ()
 センサ通信テスト
void read (float *voltage, float *current, float *power)
 測定値読み取り
void read_voltage (float *voltage)
 電圧測定値読み取り
void read_current (float *current)
 電流測定値読み取り
void read_power (float *power)
 電力測定値読み取り

Detailed Description

電圧電流センサINA226のライブラリ

#include "mbed.h"
#include "PQINA226.h"

Serial pc(USBTX, USBRX, 115200);
I2C i2c(p9, p10);

INA226 ina(i2c, A0_GND, A1_GND);

float voltage;
float current;
float power;

int main() {
    ina.begin();
    while(true){
        if(ina.test()){
            ina.read(&voltage, &current, &power);
            pc.printf("%f\t%f\t%f\r\n", voltage, current, power);
        }
        else {
            pc.printf("[  FAIL  ] INA226 cannot be reached.\r\n");
        }
    }
}

Definition at line 40 of file PQINA226.h.


Constructor & Destructor Documentation

INA226 ( I2C &  i2c,
A0_t  A0,
A1_t  A1 
)
Parameters:
i2cI2Cのインスタンスへの参照
A0A0のジャンパ
A1A1のジャンパ

Definition at line 4 of file PQINA226.cpp.


Member Function Documentation

void begin (  )

センサ動作開始

Definition at line 11 of file PQINA226.cpp.

void read ( float *  voltage,
float *  current,
float *  power 
)

測定値読み取り

Parameters:
voltage電圧を格納する変数へのポインタ
current電流を格納する変数へのポインタ
power電力を格納する変数へのポインタ

Definition at line 31 of file PQINA226.cpp.

void read_current ( float *  current )

電流測定値読み取り

Parameters:
current電流を格納する変数へのポインタ

Definition at line 46 of file PQINA226.cpp.

void read_power ( float *  power )

電力測定値読み取り

Parameters:
power電力を格納する変数へのポインタ

Definition at line 54 of file PQINA226.cpp.

void read_voltage ( float *  voltage )

電圧測定値読み取り

Parameters:
voltage電圧を格納する変数へのポインタ

Definition at line 38 of file PQINA226.cpp.

bool test (  )

センサ通信テスト

Return values:
true通信成功
false通信失敗

Definition at line 19 of file PQINA226.cpp.