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.

Der Anschlusspin „V+“ definiert mit welcher Spannung die angeschlossenen „Verbraucher“ betrieben werden. Wenn Ihr zum Beispiel ein Servo ansteuern wollt, solltet Ihr diesen Pin mit 5-6V versorgen.


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 you now have to click on the "Add" button in one of the still empty lines.

You will then be automatically redirected to the view shown and can now select which device you want to create.

Wählt hier den Eintrag „Extra IO – PCA9685“ aus.

You will then be redirected to the plugin’s configuration page.

Hier solltet Ihr einen beliebigen Namen (hier „PWM“) vergeben, den Haken bei „Enabled“ setzen und die korrekte I2C Adresse einstellen.

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

Mit der Einstellung „MODE2“ könnt Ihr das Mode 2 Register des PCA9685 konfigurieren. Dadurch lässt sich das Verhalten der PWM Pins konfigurieren. Infos dazu findet Ihr auch im Datenblatt des PCA9685.

Falls ihr den PCA9685 dazu nutzen wollt Servos anzusteuern, solltet Ihr die Option „MODE2“ auf den Wert „0x6 6“ einstellen. Weitere Infos dazu findet Ihr auch in dem Artikel ESPEasy - Using a PCA9685 to control servos.

Sobald Ihr alle Optionen des Plugins korrekt eingestellt habt, müsst Ihr nun nur noch auf „Submit“ klicken um die Einstellungen zu speichern.


Send PWM value to PCA9685

After you have finished configuring the PCA9685, you can test it.

Wechselt dazu in den Tab „Tools“.

Dort könnt Ihr in der „Command“-Sektion den Befehl

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 circuit effort" for a motor control (stepper motor 28BYJ-48 or similar), e.g. 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.