Skip to content

Commit 058999c

Browse files
committed
Initial commit
0 parents  commit 058999c

File tree

8 files changed

+578
-0
lines changed

8 files changed

+578
-0
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 SparkFun Electronics
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# SparkFun MAX1704x Fuel Gauge Arduino Library
2+
3+
The MAX17043/MAX17044 are ultra-compact, low-cost,
4+
host-side fuel-gauge systems for lithium-ion (Li+) batteries
5+
in handheld and portable equipment. The MAX17043
6+
is configured to operate with a single lithium cell and the
7+
MAX17044 is configured for a dual-cell 2S pack.
8+
9+
This Arduino library provides support for both devices.
10+
11+
## Repository Contents
12+
13+
- **/examples** - Example sketches for the library (.ino). Run these from the Arduino IDE.
14+
- **/src** - Source files for the library (.cpp, .h).
15+
- **keywords.txt** - Keywords from this library that will be highlighted in the Arduino IDE.
16+
- **library.properties** - General library properties for the Arduino package manager.
17+
18+
## Products That Use This Library
19+
20+
- [SparkFun LiPo Fuel Gauge (TOL-10617)](https://www.sparkfun.com/products/10617)
21+
22+
## Documentation
23+
24+
- **[Installing an Arduino Library Guide](https://learn.sparkfun.com/tutorials/installing-an-arduino-library)** - Basic information on how to install an Arduino library.
25+
26+
## License Information
27+
28+
Please see [LICENSE.md](./LICENSE.md) for the license information.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/******************************************************************************
2+
Example1_Simple
3+
By: Paul Clark
4+
Date: October 23rd 2020
5+
6+
Based extensively on:
7+
MAX17043_Simple_Serial.cpp
8+
SparkFun MAX17043 Example Code
9+
Jim Lindblom @ SparkFun Electronics
10+
Original Creation Date: June 22, 2015
11+
12+
This file demonstrates the simple API of the SparkFun MAX17043 Arduino library.
13+
14+
This example will print the gauge's voltage and state-of-charge (SOC) readings
15+
to Serial (115200 baud)
16+
17+
This code is released under the MIT license.
18+
19+
Distributed as-is; no warranty is given.
20+
******************************************************************************/
21+
22+
#include <SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library.h> // Click here to get the library: http://librarymanager/All#SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library
23+
24+
SFE_MAX1704X lipo;
25+
26+
double voltage = 0; // Variable to keep track of LiPo voltage
27+
double soc = 0; // Variable to keep track of LiPo state-of-charge (SOC)
28+
bool alert; // Variable to keep track of whether alert has been triggered
29+
30+
void setup()
31+
{
32+
Serial.begin(115200); // Start serial, to output debug data
33+
34+
// Set up the MAX17043 LiPo fuel gauge:
35+
lipo.begin(); // Initialize the MAX17043 LiPo fuel gauge
36+
37+
// Quick start restarts the MAX17043 in hopes of getting a more accurate
38+
// guess for the SOC.
39+
lipo.quickStart();
40+
41+
// We can set an interrupt to alert when the battery SoC gets too low.
42+
// We can alert at anywhere between 1% - 32%:
43+
lipo.setThreshold(20); // Set alert threshold to 20%.
44+
}
45+
46+
void loop()
47+
{
48+
// lipo.getVoltage() returns a voltage value (e.g. 3.93)
49+
voltage = lipo.getVoltage();
50+
// lipo.getSOC() returns the estimated state of charge (e.g. 79%)
51+
soc = lipo.getSOC();
52+
// lipo.getAlert() returns a 0 or 1 (0=alert not triggered)
53+
alert = lipo.getAlert();
54+
55+
// Print the variables:
56+
Serial.print("Voltage: ");
57+
Serial.print(voltage); // Print the battery voltage
58+
Serial.println(" V");
59+
60+
Serial.print("Alert: ");
61+
Serial.println(alert);
62+
63+
Serial.print("Percentage: ");
64+
Serial.print(soc); // Print the battery state of charge
65+
Serial.println(" %");
66+
Serial.println();
67+
68+
delay(500);
69+
}

keywords.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#######################################
2+
# Syntax Coloring Map For MAX1704x
3+
#######################################
4+
5+
#######################################
6+
# Datatypes (KEYWORD1)
7+
#######################################
8+
9+
MAX17043 KEYWORD1
10+
11+
#######################################
12+
# Methods and Functions (KEYWORD2)
13+
#######################################
14+
15+
begin KEYWORD2
16+
isConnected KEYWORD2
17+
enableDebugging KEYWORD2
18+
disableDebugging KEYWORD2
19+
quickStart KEYWORD2
20+
getVoltage KEYWORD2
21+
getSOC KEYWORD2
22+
getVersion KEYWORD2
23+
getThreshold KEYWORD2
24+
setThreshold KEYWORD2
25+
getAlert KEYWORD2
26+
clearAlert KEYWORD2
27+
sleep KEYWORD2
28+
wake KEYWORD2
29+
reset KEYWORD2
30+
getConfigRegister KEYWORD2
31+
getCompensation KEYWORD2
32+
setCompensation KEYWORD2
33+
34+
#######################################
35+
# Constants (LITERAL1)
36+
#######################################

library.properties

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=SparkFun MAX1704x Fuel Gauge Arduino Library
2+
version=1.0.0
3+
author=SparkFun Electronics <techsupport@sparkfun.com>
4+
maintainer=SparkFun Electronics <sparkfun.com>
5+
sentence=Arduino library for the MAX17043 / MAX17044 fuel gauge
6+
paragraph=An Arduino library to let you access all of the features of the MAX17043 and MAX17044 battery fuel gauges
7+
category=Sensors
8+
url=https://github.com/sparkfun/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library
9+
architectures=*

0 commit comments

Comments
 (0)