Giter Site home page Giter Site logo

max17043gu's Introduction

MAX17043GU

MAX17043GU library for Arduino

v1.0.0

Reads LiPo battery level and voltage using MAX17043GU.

Turned into a library from Sparkfun's example code for the SparkFun LiPo Fuel Gauge

Functions

Set up and set the I2C address
MAX17043GU(int address)

Set the percentage [0-32] for the low battery warning
setLowBattery(byte percent)

Restart the calculations
restart()

Get the voltage level (in steps op 1.25 mV)
voltageLevel()

Get the battery level
fuelLevel()

Example

#include <Wire.h>
#include <MAX17043GU.h>

#define MAX17043_ADDRESS 0x36

float voltage;
float percentage;

MAX17043GU battery(MAX17043_ADDRESS);

void setup() 
{
	// Start serial
	Serial.begin(9600);
	// Start I2C
	Wire.begin();
	delay(100);
	// Set battery alarm to 20%
	battery.setLowBattery(20);
	battery.restart();
}

void loop() 
{
	// Get the values
	voltage = battery.voltageLevel();
	percentage = battery.fuelLevel();
	
	// Print
	Serial.print("Battery voltage: ");
	Serial.print(voltage, 2);
	Serial.println("V");
	Serial.print("Battery level");
	Serial.print(percentage, 2);
	Serial.println("%");
	
	// Wait
	delay(3000);
}

Credits

All credits go to Sparkfun.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.