PCA9685 - stodev-com-br/tasmota GitHub Wiki

PCA9685: 16-channel, 12-bit PWM I2C-bus LED controller

Technical Data: Product Information from NXP

IMPLEMENTATION STATUS IN TASMOTA

The PCA9685 driver is implemented in such a way that it may be used as standard individual OUTPUT pins, or as PWM capable OUTPUT pins - The latter offloads the PWM functionality from the ESP8266 insofar that the PCA9685 will continue to perform its configured output PWM/ON/OFF state without direct control or intervention from the Tasmota firmware.

Support was added in line with the datasheet specification insofar that the PWM frequency can be set from 24hz all the way up to 1526hz.

This driver does not currently have any perpetual settings so will revert to a base frequency of 50hz (usually suitable for most applications) and will be set in an OFF state for all pins during power-up and/or reset.

The latter may change as the driver grows in cases where user requirements and development requirements are met.

USAGE OF THE PCA9685 DRIVER IN TASMOTA

The driver needs to be connected to the I2C bus of your Tasmota powered device (note that most Sonoff devices will not have reachable I2C pins so it's applicable to a limited number, so most likely only applicable to bare ESP8266 or WeMos type users.

If you modify a Sonoff or similar device to gain access to the I2C bus please be aware that other problems may persist and that for such use cases support in Tasmota chat or Issues is not guaranteed in any way whatsoever)

The driver is not included during the compilation of the standard released binaries so in order to use this driver you will need to create a development environment for yourself and uncomment these two lines in my_user_config.h

#define USE_PCA9685
#define USE_PCA9685_ADDR 0x40
#define USE_PCA9685_FREQ 50    // Support is for 24 to 1526 Hz

For information on how to set up a development environment please check the wiki on Arduino IDE (the easiest, probably) or PlatformIO

Note that the I2C selection must correspond with how you have wired the module or chip as incorrect addressing will result in the PCA9685 not being detected. The valid I2C address range is 0x40 through 0x47 for the PCA9685 and most off-the-shelf modules would likely default to 0x40.

If you are unsure please use I2Scan from Tasmota console to scan for devices on the I2Cbus and you should find a device within the mentioned range.

You may also get a discovery on 0x70 but please do not use this address as it is a broadcast address and the driver does not currently support its implementation.

Also be aware of other I2C devices you have connected to the same Tasmota driven device in order to avoid I2C address conflicts.

Once connected, correctly flashed, and configured Tasmota will detect the device automatically on startup.

DRIVER USAGE

There is no web interface for this driver. The driver is used via MQTT or console command using the following available commands and their respective parameters

driver15 pwmf,frequency   // where frequency is the PWM frequency from 24 to 1526 in Hz
driver15 pwm,pin,pwmvalue // where pin = LED pin 0 through 15 and pwmvalue is the pulse width between 0 and 4096
driver15 pwm,pin,ON       // Fully turn a specific pin/LED ON
driver15 pwm,pin,OFF      // Fully turn a specific pin/LED OFF
driver15 reset            // Reset to power-up settings - i.e. F=50hz and all pins in OFF state
driver15 status           // Will return a JSON string containing all the current settings / parameters

OTHER IMPORTANT INFORMATION

  • Please remember to consider the voltage and current limitations of the chip and per pin output current limitations as outlined in the datasheet.
  • You may also get a discovery on 0x70 but please do not use this address as it is a broadcast address and the driver does not currently support its implementation.
  • Also be aware of other I2C devices you have connected to the same Tasmota driven device in order to avoid I2C address conflicts.

OUTSTANDING FEATURE REQUESTS

  • Dimming ON / OFF a dimming value in a certain time and fade on "ON / OFF" (Not yet scheduled for implementation)
  • Allow usage of RGBW in pairs of 4 PWM outputs (i.e. drive 4 x 4pin RGBW LED's) (Not yet scheduled for implementation)
⚠️ **GitHub.com Fallback** ⚠️