HowTo: ESPEasy – Connect and control the PCA9685 PWM port extension to the ESP8266

The PCA9685 is a quite practical IC. This is connected to the microcontroller (for example ESP8266) via I2C and can then control up to 16 individual PWM channels.

With just two (I2C) pins on the microcontroller, you can control up to 16 LEDs, servos or, with additional circuitry, motors.

Especially if you want to control servos, this IC or breakout board makes the work much easier.

Thanks to ESPEasy and the appropriate plugin, the PCA9685 can be controlled very easily and ultimately controlled via WiFi.

How you need to connect and configure the PCA9685 to your microcontroller is described in the following article.


Safety instructions

I know the following notes are always kind of annoying and seem unnecessary. Unfortunately, many people who knew "better" have lost eyes, fingers or other things due to carelessness or injured themselves. Data loss is almost negligible in comparison, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Because even the coolest project is not worth injury or other trouble.
https://www.nerdiy.de/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 make a purchase via this link, Nerdiy.de will receive a commission from the relevant online shop or provider. The price does not change for you. If you make your purchases via these links, you support Nerdiy.de in being able to offer other useful projects in the future. 🙂 


Requirements

Helpful articles:
Additional tips on ESPEasy can be found in the following articles.

Required tool:

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.

Circuit diagram PCA9685 connected to an ESP8266 via I2C.

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 PCA9685 can be configured quickly thanks to the appropriate plugin.

First open the web configuration view of your ESPeasy installation.

You can also find information about how you can open this view 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, click on the "Add" button in one of the empty rows.

You will then be automatically redirected 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 redirected to the plugin’s configuration page.

Here you should assign any name (here “PWM”), check “Enabled” and set the correct I2C address.

The I2C address often corresponds to the standard address shown. If not, you will find information about this in the PCA9685 data sheet.

With the setting “MODE2” you can configure the Mode 2 register of the PCA9685. This allows the behavior of the PWM pins to be configured. You can also find information about this in the PCA9685 data sheet.

If you want to use the PCA9685 to control servos, you should set the “MODE2” option to the value “0x6 6”. You can also find further information about this in the article ESPEasy - Using a PCA9685 to control servos.

Once you have set all the plugin options correctly, all you have to do is 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 command in the “Command” section

PCAPWM,0,300,

input. This command sets the first (counting starts at 0) pin of the PCA9685 to the PWM value 300. The adjustable value here 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 further articles on configuring sensors and actuators using ESPEasy in the category


Have fun with the project

I hope everything worked as described for you. If not or you have questions or suggestions please let me know in the comments. I will then add this to the article if necessary.
Ideas for new projects are always welcome. 🙂

PS 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 think it's cool that I share the information with you, I would be happy about a small donation to the coffee fund. 🙂

Buy Me a Coffee at ko-fi.com       

7 comments

  1. Hello, very interesting instructions... I would be interested in the “additional circuitry” for a motor control (stepper motor 28BYJ-48 or similar), for example to operate a roller blind or similar.

    1. Hey Kruse,
      it's actually not that big. A ULN2003 connected to the outputs of the PCA is sufficient to control a 28BYJ-48. I can do an article about it when I get a chance. 🙂
      Best regards
      Fabian

    1. Yes something like that is also on my (long) list. 😀 I will put the article on my ToDo list. 🙂
      Best regards
      Fabian

  2. Good bye,
    great guide! Thanks, would like to control the servos via mqtt the data points via iobroker. Only the status is displayed in iobroker!
    Best regards
    Benno

  3. good morning Fab,
    many thanks for your response.
    sorry that I'm just getting in touch now. I can now process it with Http, works great!

    Thank you again
    Best regards
    Benno

Kommentar hinterlassen

Your email address will not be published. Erforderliche Felder sind mit * markiert

This site uses Akismet to reduce spam. Learn how your comment data is processed.