Skip to content

shiroichiheisen/TPS23861-Arduino-Library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

TPS23861 Library for Arduino

This is an Arduino library for interfacing with the TPS23861 PoE (Power over Ethernet) PSE (Power Sourcing Equipment) controller. It provides an easy-to-use interface for communicating with the TPS23861 IC over I2C.

Dependencies

Before using this library, you need to install the SoftWire library, which is a software I2C implementation for Arduino and other microcontroller platforms. You can find the SoftWire library here.

Installation

  1. Download or clone this repository to your local machine.
  2. Unzip (if downloaded as a zip) and rename the folder to TPS23861 (remove any -master postfix).
  3. Move the TPS23861 folder to your Arduino's libraries folder.
  4. Restart the Arduino IDE.
  5. Include the library in your sketch as shown below:
#include <tps23861.h>

Usage

To use the library, you will need to create an instance of the tps23861 class and initialize it with the SDA and SCL pins you are using for I2C communication. Optionally, you can specify the clock speed (default is 400kHz).

tps23861 tps;
uint8_t sdaPin = A4;
uint8_t sclPin = A5;

void setup() {
   tps.begin(sdaPin, sclPin);
   // Your setup code here
}

void loop() {
   // Your looping code here
}

API Reference

  • begin(uint8_t sdaPin, uint8_t sclPin, int clockSpeed) : Initialize the library with the given SDA and SCL pins and, optionally, the I2C clock speed.
  • readInterrupt(uint8_t tps23861HexId) : Read interrupt status.
  • writeOperatingMode(uint8_t tps23861HexId, uint8_t data) : Write operating mode data.
  • readPowerStatus(uint8_t tps23861HexId) : Read the power status.
  • ... : Other functions follow the similar pattern of reading from or writing to the TPS23861 registers.

Refer to the header file tps23861.h for a detailed list of all available functions.

Example

Here's a simple example that shows how to use the library to read the power status:

#include <tps23861.h>

tps23861 tps;
uint8_t tps23861HexId = 0x30; // Assuming single device connected with default address

void setup() {
   Serial.begin(9600);
   tps.begin(A4, A5); // SDA, SCL on standard Arduino Uno pins
}

void loop() {
   uint8_t powerStatus = tps.readPowerStatus(tps23861HexId);
   Serial.print("Power Status: ");
   Serial.println(powerStatus, HEX);
   delay(1000);
}

About

A library of the Texas Instruments TPS23861 for Arduino

Topics

Resources

License

Stars

Watchers

Forks

Languages