The PCA9685 is quite a practical IC. This is connected to the microcontroller (e.g. ESP8266) via I2C and can then control up to 16 individual PWM channels.
You can control up to 16 LEDs, servos or motors with additional circuitry with just two (I2C) pins on the microcontroller.
Especially when you want to control servos, this IC or the breakout board makes your work a lot easier.
Thanks to ESPEasy and the appropriate plug-in, the PCA9685 is very easy to control and can ultimately also controlled via WiFi.
How to connect and configure the PCA9685 to your microcontroller is described in the following article.
I know the following hints are always a bit annoying and seem unnecessary. But unfortunately, many people who knew it "better" from carelessness lost their eyes, fingers or other things or hurt themselves. In comparison, a loss of data is almost not worth mentioning, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Even the coolest project is worth no injury or other annoyance. https://www.nerdiy.de/en/sicherheitshinweise/
The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and shop via this link, Nerdiy.de receives a commission from the online shop or provider concerned. The price doesn't change for you. If you do your purchases via these links, you will support Nerdiy.de in being able to offer further useful projects in the future. 🙂
You can find additional tips on ESPEasy in the following articles.
- ESPEasy – Execute commands and actions via HTTP, MQTT, UDP and directly
- ESPEasy – Compile firmware, flash it and configure WiFi access data
- ESPEasy/Wemos D1 Mini – Adapt ADC to a different maximum voltage
Connect the PCA9685 PWM port expander
The PC9685 breakout board must be connected to the Wemos D1 Mini via the I2C bus. To do this, you can connect the PCA9685 breakout board to a Wemos D1 Mini using the circuit diagram below, for example.
The connection pin “V+” defines the voltage with which the connected “consumers” are operated. For example, If you want to control a servo, you should supply this pin with 5-6V.
Configuration of the PCA9685 in ESPEasy
The configuration of the PCA9685 is done quickly thanks to the matching plug-in.
First open the web configuration view of your ESPeasy installation.
Information on how you can open this view can also be found in the article ESPEasy – Execute commands and actions via HTTP, MQTT, UDP and directly
From there click on the “Devices” tab.
In the “Devices” tab you now have to click the “Add” button in one of the empty lines.
You will then be automatically forwarded to the view shown and can now select which device you want to create.
Select the entry “Extra IO – PCA9685” here.
You will then be forwarded to the configuration page of the plugin.
Here you can assign any name (in this case “PWM”), check the box for “Enabled” and set the correct I2C address.
The I2C address often corresponds to the standard address shown. If not, you can find information on this in the data sheet of the PCA9685.
With the setting “MODE2” you can configure the mode 2 register of the PCA9685. This allows to specify the behavior of the PWM pins. You can find information about this in the data sheet of the PCA9685.
If you want to use the PCA9685 to control servos, you should set the option “MODE2” to the value “0x6 6”. You can find more information about this in the article ESPEasy – Using a PCA9685 to control servos.
As soon as you have correctly set all options of the plugin, you only have to click on “Submit” to save the settings.
Send PWM value to PCA9685
After you have finished configuring the PCA9685, you can test it.
To do this, switch to the “Tools” tab.
There you can enter the following command in the “Command” section
This command sets the first (counting starts at 0) pin of the PCA9685 to the PWM value 300. The adjustable value ranges from 0 to 4095.
For example, if you wanted to set the third pin of the PCA9685 to 1337, the command would look like this:
You can also find more articles on the configuration of sensors and actuators using ESPEasy in the category
Have fun with the project
I hope everything worked as described. If not or you have any other questions or suggestions, please let me know in the comments. Also, ideas for new projects are always welcome. 🙂
P.S. Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you appreciate it that I share these information with you, I would be happy about a small donation to the coffee box. 🙂