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.
Inhalte
Safety instructions
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/
Affiliate links / advertising links
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. 🙂
Requirements
Helpful Articles:
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
Required tools:
Required material:
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.

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
PCAPWM,0,300,
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:
PCAPWM,2,1337,
More sensors
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. 🙂
Hallo, sehr interessante Anleitung … mich würde der “zusätzliche Schaltungsaufwand” für eine Motoransteuerung (Schrittmotor 28BYJ-48 o.ä.), z.B. um ein Rollo o.ä. zu betätigen, interessieren.
Hey Kruse,
der ist eigentlich gar nicht so groß. Zur Ansteuerung eines 28BYJ-48 reicht schon ein ULN2003 der an die Ausgänge des PCA angeschlossen wird. Ich kann bei Gelegenheit mal einen Artikel dazu anfertigen. 🙂
Beste Grüße
Fabian
Danke für die Antwort … freue mich auf den Artikel.
Ich “bastele” gerade an diesem Antrieb: https://www.instructables.com/Motorized-WiFi-IKEA-Roller-Blind/ aber der ist etwas “unübersichtlich”.
Ich bin auch nicht DER Fachmann und hoffe immer auf “Kochrezepte” bei denen das Ergebnis auch relativ einfach paßt. Und man lernt ja immer was dazu ….
Gruß
Ja sowas ist auch noch auf meiner (langen) Liste. 😀 Ich werde den Artikel dazu mal auf meine ToDo Liste schreiben. 🙂
Beste Grüße
Fabian
Servus,
super Anleitung! Danke, würde gerne die Servos per mqtt die Datenpunkte über iobroker ansteuern. In iobroker wird nur der Status angezeigt!
Liebe Grüße
Benno
Hi Benno,
danke. 🙂
Du kannst den gezeigten Befehl auch per MQTT an ESPEasy senden. Ein einfaches Beispiel habe ich zum Beispiel hier beschrieben: https://nerdiy.de/howto-espeasy-befehle-ausfuehren/#Befehle_ueber_MQTT_ausfuehren
Beste Grüße
Fabian
Guten Morgen Fab,
vielen Dank für deine Antwort.
sorry , dass ich mich erst jetzt melde. habe es jetzt mit Http verarbeiten können, klappt super!
Noch mal vielen Dank
Liebe Grüße
Benno