jarzebski / arduino-ina219 Goto Github PK
View Code? Open in Web Editor NEWINA219 Zero-Drift, Bi-directional Current/Power Monitor Arduino Library
License: MIT License
INA219 Zero-Drift, Bi-directional Current/Power Monitor Arduino Library
License: MIT License
When the Wire.requestFrom() returns, the I2C transaction has completely finished and the received data is waiting in a buffer in the Wire library. There is nothing to wait for after the Wire.requestFrom(). The Wire.available() and Wire.read() only use that buffer, they are not involved in the I2C bus transaction.
The while-loop to wait for something can be removed.
The Wire.beginTransmission() and Wire.endTransmission() are only used when writing data. They should not be used with Wire.requestFrom().
The value stored in the Bus Voltage register are unsigned, so the bits should be written into an unsigned uint16_t instead of an int16_t value before doing the scaling math and returning a float. Otherwise it will be treated as two's complement, and any bus voltage over about 16 volts will return a negative number.
This would fix it:
float INA219::readBusVoltage(void)
{
uint16_t voltage;
voltage = readRegister16(INA219_REG_BUSVOLTAGE);
voltage >>= 3;
return (voltage * 0.004);
Please add support for Arduino framework for STM32 chips.
I can confirm that it works for me after minor changes. Maybe I'll even make a pull request later, when I have some spare time.
What would it take to port this over to to work in the Johnny Five environment? (https://github.com/rwaldron/johnny-five) (http://johnny-five.io/)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.