ina219_C_Code

所属分类:嵌入式Linux
开发工具:C/C++
文件大小:21KB
下载次数:4
上传日期:2020-09-02 15:19:23
上 传 者chinoxl
说明:  INA219 I2C Reading code

文件列表:
DFRobot_INA219.cpp (4771, 2019-06-28)
DFRobot_INA219.h (3224, 2019-06-28)
LICENSE (26526, 2019-06-28)
Python (0, 2019-06-28)
Python\RespberryPi (0, 2019-06-28)
Python\RespberryPi\DFRobot_INA219.py (5633, 2019-06-28)
Python\RespberryPi\get_voltage_current_power.py (1418, 2019-06-28)
Python\RespberryPi\set_config.py (2708, 2019-06-28)
example (0, 2019-06-28)
example\getVoltageCurrentPower (0, 2019-06-28)
example\getVoltageCurrentPower\getVoltageCurrentPower.ino (1663, 2019-06-28)
example\setConfig (0, 2019-06-28)
example\setConfig\setConfig.ino (2580, 2019-06-28)
keywords.txt (1558, 2019-06-28)

# INA219 INA219 is a Gravity I2C digital power meter
INA219 can measure current, voltage and power of various electronic modules within 26V 8A with an accuracy higher than 0.2%.
INA219 can be used for power measurement of solar system, battery coulomb counter or electronic module.
## DFRobot_INA219 Library for Arduino --------------------------------------------------------- Provide an Arduino library for the INA219 modules. ## Table of Contents * [Summary](#summary) * [Feature](#feature) * [Installation](#installation) * [Methods](#methods) * [Compatibility](#compatibility) * [Credits](#credits) ## Summary The voltage, current, power and voltage at both ends of the sampling resistance of INA219 can be read through I2C. These data are printed out through the serial port. ## Feature 1. Low standby current 2. Serial input via I2C-bus 3. Configurable sample rate 4. I2C address can be modified by revising the macro definition 5. Maximum measurement range up to 26V 8A ## Installation Download the library ZIP file and unzip it to the Arduino folder of the library.
## Methods ```C++ #include "DFRobot_INA219.h" /*! * @brief Set IIC address by setting the hardware * * @param IIC Address setting * addr = INA219_I2C_ADDRESS1 0x40 * INA219_I2C_ADDRESS2 0x41 * INA219_I2C_ADDRESS3 0x44 * INA219_I2C_ADDRESS4 0x45 */ DFRobot_INA219_IIC(TwoWire *pWire, uint8_t i2cAddr); /* * @brief ina219 begin * * @return begin return true if succeed, otherwise return false */ bool begin(); /* * @brief calibrate the current * * @param ina219Reading_A can not be zero */ void linearCalibrate(float ina219Reading_mA, float extMeterReading_mA); /* * @brief ina219 reset */ void reset(); /* * @brief Get the shunt voltage in volts * * @return The bus voltage converted into volts */ float getBusVoltage_V(); /* * @brief Get the shunt voltage in mV * * @return The shunt voltage converted into millivolts */ float getShuntVoltage_mV(); /* * @brief Get the current value in mA, taking into account the * config settings and current LSB * * @return The current reading convereted to milliamps */ float getCurrent_mA(); /* * @brief Get the power value in mW, taking into account the * config settings and power LSB * * @return Power reading converted to milliwatts */ float getPower_mW(); /* * @brief Bus voltage range setting * * @param typedef enum {eIna219BusVolRange_16V, * eIna219BusVolRange_32V * } eIna219BusVolRange_t; */ void setBRNG(eIna219BusVolRange_t value); /* * @brief PGA gain and range setting * * @param typedef enum {eIna219PGABits_1, * eIna219PGABits_2, * eIna219PGABits_4, * eIna219PGABits_8 * } eIna219PGABits_t; */ void setPGA(eIna219PGABits_t bits); /* * @brief Bus ADC resolution setting * * @param typedef enum {eIna219AdcBits_9, * eIna219AdcBits_10, * eIna219AdcBits_11, * eIna219AdcBits_12 * } eIna219AdcBits_t; * * @param typedef enum {eIna219AdcSample_1, * eIna219AdcSample_2, * eIna219AdcSample_4, * eIna219AdcSample_8, * eIna219AdcSample_16, * eIna219AdcSample_32, * eIna219AdcSample_***, * eIna219AdcSample_128 * } eIna219AdcSample_t; * * if eIna219AdcSample_t >= 1, eIna219AdcBits_t must be "eIna219AdcBits_12" */ void setBADC(eIna219AdcBits_t bits, eIna219AdcSample_t sample); void setSADC(eIna219AdcBits_t bits, eIna219AdcSample_t sample); /* * @brief Operating mode setting * * @param typedef enum{eIna219PowerDown, * eIna219SVolTrig, * eIna219BVolTrig, * eIna219SAndBVolTrig, * eIna219AdcOff, * eIna219SVolCon, * eIna219BVolCon, * eIna219SAndBVolCon * } eInaMode; */ void setMode(eInaMode mode); ``` ## Compatibility MCU | Work Well | Work Wrong | Untested | Remarks ------------------ | :----------: | :----------: | :---------: | ----- Arduino uno | √ | | | RaspberryPi | √ | | | ## Credits ·author [luoyufeng yufeng.luo@dfrobot.com]

近期下载者

相关文件


收藏者