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.
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.
- Download or clone this repository to your local machine.
- Unzip (if downloaded as a zip) and rename the folder to
TPS23861
(remove any-master
postfix). - Move the
TPS23861
folder to your Arduino'slibraries
folder. - Restart the Arduino IDE.
- Include the library in your sketch as shown below:
#include <tps23861.h>
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
}
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.
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);
}