Skip to content

Commit

Permalink
Add Wire1 support for ESP32 (#7)
Browse files Browse the repository at this point in the history
- Add Wire1 support for ESP32
- update readme.md
  • Loading branch information
RobTillaart authored Sep 24, 2023
1 parent 7e9220a commit d41d271
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 15 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [0.1.5] - 2023-09-24
- Add Wire1 support for ESP32
- update readme.md


## [0.1.4] - 2023-06-12
- improve RP2040 support
- add address test in isConnected()
- update readme.md
- add array example


## [0.1.3] - 2023-03-31
- fix setBusADC() range check
- fix setShuntADC() range check
Expand Down
7 changes: 2 additions & 5 deletions INA219.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// FILE: INA219.h
// AUTHOR: Rob Tillaart
// VERSION: 0.1.4
// VERSION: 0.1.5
// DATE: 2021-05-18
// PURPOSE: Arduino library for INA219 voltage, current and power sensor
// URL: https://github.com/RobTillaart/INA219
Expand Down Expand Up @@ -40,7 +40,7 @@ INA219::INA219(const uint8_t address, TwoWire *wire)
{
_address = address;
_wire = wire;
// not calibrated values by default.
// not calibrated values by default.
_current_LSB = 0;
_maxCurrent = 0;
_shunt = 0;
Expand All @@ -50,7 +50,6 @@ INA219::INA219(const uint8_t address, TwoWire *wire)
#if defined (ESP8266) || defined(ESP32)
bool INA219::begin(const uint8_t sda, const uint8_t scl)
{
_wire = &Wire;
_wire->begin(sda, scl);
if (! isConnected()) return false;
return true;
Expand Down Expand Up @@ -307,8 +306,6 @@ bool INA219::setMaxCurrentShunt(float maxCurrent, float shunt)
}




////////////////////////////////////////////////////////
//
// PRIVATE
Expand Down
12 changes: 6 additions & 6 deletions INA219.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
// FILE: INA219.h
// AUTHOR: Rob Tillaart
// VERSION: 0.1.4
// VERSION: 0.1.5
// DATE: 2021-05-18
// PURPOSE: Arduino library for INA219 voltage, current and power sensor
// URL: https://github.com/RobTillaart/INA219
Expand All @@ -14,7 +14,7 @@
#include "Wire.h"


#define INA219_LIB_VERSION (F("0.1.4"))
#define INA219_LIB_VERSION (F("0.1.5"))


class INA219
Expand Down Expand Up @@ -63,7 +63,7 @@ class INA219
// factor = 1, 2, 4, 8
bool setGain(uint8_t factor = 1);
uint8_t getGain();
// mask
// mask
bool setBusADC(uint8_t mask = 0x03);
uint8_t getBusADC();
bool setShuntADC(uint8_t mask = 0x03);
Expand All @@ -81,12 +81,12 @@ class INA219
bool setModeBusContinuous() { return setMode(6); };
bool setModeShuntBusContinuous() { return setMode(7); }; // default.


// CALIBRATION
// mandatory to set these! read datasheet.
// maxCurrent >= 0.001
// shunt >= 0.001
bool setMaxCurrentShunt(float maxCurrent = 3.4,
bool setMaxCurrentShunt(float maxCurrent = 3.4,
float shunt = 0.002);

bool isCalibrated() { return _current_LSB != 0.0; };
Expand All @@ -104,7 +104,7 @@ class INA219


private:

uint16_t _readRegister(uint8_t reg);
uint16_t _writeRegister(uint8_t reg, uint16_t value);
float _current_LSB;
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
[![Arduino CI](https://github.com/RobTillaart/INA219/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/INA219/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/INA219/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/INA219/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/INA219/actions/workflows/jsoncheck.yml)
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/INA219.svg)](https://github.com/RobTillaart/INA219/issues)

[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/INA219/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/INA219.svg?maxAge=3600)](https://github.com/RobTillaart/INA219/releases)
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/INA219.svg)](https://registry.platformio.org/libraries/robtillaart/INA219)


# INA219
Expand Down Expand Up @@ -257,3 +260,12 @@ to get the values in scientific notation like "3.5e-6"
- can't be sure so user is responsible


## Support

If you appreciate my libraries, you can support the development and maintenance.
Improve the quality of the libraries by providing issues and Pull Requests, or
donate through PayPal or GitHub sponsors.

Thank you,


4 changes: 2 additions & 2 deletions library.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"type": "git",
"url": "https://github.com/RobTillaart/INA219.git"
},
"version": "0.1.4",
"version": "0.1.5",
"license": "MIT",
"frameworks": "arduino",
"frameworks": "*",
"platforms": "*",
"headers": "INA219.h"
}
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=INA219
version=0.1.4
version=0.1.5
author=Rob Tillaart <[email protected]>
maintainer=Rob Tillaart <[email protected]>
sentence=Arduino library for INA219 voltage, current and power sensor.
Expand Down

0 comments on commit d41d271

Please sign in to comment.