0.3.1 INA219

This commit is contained in:
Rob Tillaart 2024-04-22 18:28:17 +02:00
parent 4bfffcf63f
commit 41f50fe391
5 changed files with 15 additions and 11 deletions

View File

@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.3.1] - 2024-04-22
- Bump version after Fix #17, Kudos to ChrisRed255
## [0.3.0] - 2024-03-15
- Fix #14, change round to truncate.
- update GitHub actions to v4

View File

@ -1,6 +1,6 @@
// FILE: INA219.h
// AUTHOR: Rob Tillaart
// VERSION: 0.3.0
// VERSION: 0.3.1
// DATE: 2021-05-18
// PURPOSE: Arduino library for INA219 voltage, current and power sensor
// URL: https://github.com/RobTillaart/INA219
@ -40,7 +40,7 @@ INA219::INA219(const uint8_t address, TwoWire *wire)
{
_address = address;
_wire = wire;
// not calibrated values by default.
// no calibrated values by default.
_current_LSB = 0;
_maxCurrent = 0;
_shunt = 0;
@ -75,7 +75,7 @@ uint8_t INA219::getAddress()
float INA219::getShuntVoltage()
{
uint16_t value = _readRegister(INA219_SHUNT_VOLTAGE);
return value * 1e-5; // fixed 10 uV
return value * 1e-5; // fixed 10 uV
}
@ -85,8 +85,8 @@ float INA219::getBusVoltage()
uint8_t flags = value & 0x03;
// math overflow handling
if (flags & 0x01) return -100;
// if flags && 0x02 ==> convert flag; not handled
float voltage = (value >> 3) * 4e-3; // fixed 4 mV
// if flags && 0x02 ==> convert flag; not handled
float voltage = (value >> 3) * 4e-3; // fixed 4 mV
return voltage;
}
@ -94,7 +94,7 @@ float INA219::getBusVoltage()
float INA219::getPower()
{
uint16_t value = _readRegister(INA219_POWER);
return value * 20 * _current_LSB;
return value * (_current_LSB * 20); // fixed 20 Watt
}
// TODO CHECK
@ -129,7 +129,7 @@ bool INA219::reset()
uint16_t config = _readRegister(INA219_CONFIGURATION);
config |= 0x8000;
uint16_t wrrv = _writeRegister(INA219_CONFIGURATION, config);
// reset calibration
// reset calibration
_current_LSB = 0;
_maxCurrent = 0;
_shunt = 0;

View File

@ -1,7 +1,7 @@
#pragma once
// FILE: INA219.h
// AUTHOR: Rob Tillaart
// VERSION: 0.3.0
// VERSION: 0.3.1
// DATE: 2021-05-18
// PURPOSE: Arduino library for INA219 voltage, current and power sensor
// URL: https://github.com/RobTillaart/INA219
@ -13,7 +13,7 @@
#include "Wire.h"
#define INA219_LIB_VERSION (F("0.3.0"))
#define INA219_LIB_VERSION (F("0.3.1"))
class INA219

View File

@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/INA219.git"
},
"version": "0.3.0",
"version": "0.3.1",
"license": "MIT",
"frameworks": "*",
"platforms": "*",

View File

@ -1,5 +1,5 @@
name=INA219
version=0.3.0
version=0.3.1
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for INA219 voltage, current and power sensor.