PCA9685 12-bit PWM controller~
This feature is not included in precompiled binaries
When compiling your build add the following to
#ifndef USE_PCA9685 #define USE_PCA9685 // [I2cDriver1] Enable PCA9685 I2C HW PWM Driver - Must define I2C Address in #define USE_PCA9685_ADDR below - range 0x40 - 0x47 (+1k4 code) #define USE_PCA9685_ADDR 0x40 // Enable PCA9685 I2C Address to use (Must be within range 0x40 through 0x47 - set according to your wired setup) #define USE_PCA9685_FREQ 50 // Define default PWM frequency in Hz to be used (must be within 24 to 1526) - If other value is used, it will revert to 50Hz #endif
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)
For information on how to set up a development environment please check the wiki on 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
I2CScan from Tasmota console to scan for devices on the I2C bus 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.
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)