The PCA9685 is a PWM port expander. This makes it possible to connect up to 16 LEDs, servos or other components to your ESP8266 and supply them with a PWM signal.
Thanks to ESPEasy (and the matching plug-in), controlling the PCA9685 is particularly easy. With the PCA9685, you can ultimately control up to 16 servos using ESPEasy.
In order for this to work, however, you have to pay attention to a few settings. Everything you need to know 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
How it works
The signal for controlling a servo basically consists of a pulse of 0.5 to 2.5 ms in length. This pulse should be repeated every 20 ms.
This signal can be simulated using the PCA9685. To do this, the PWM frequency only needs to be adjusted so that it corresponds to the period duration of the servo signal.
In this picture you can see the relationship between servo signal (left) and servo position (right).
Configuration in ESPEasy
This section only deals with the configuration of the ESPEasy plug-in. That means you should already have connected the PCA9685 or the breakout board on which it is installed to the ESP8266. For this you should have connected the two according to the following scheme.
|VCC||5V or 3V3|
The ESPEasy firmware should already be installed on your ESP8266. How you can proceed is described in the article ESPEasy – Compile firmware, flash it and configure WiFi access data.
Then you can switch to the “Devices” section and create the “Extra IO – PCA9685” device.
You should then configure the created plugin as shown.
It is important that you set the PWM frequency (“Frequency”) to 50Hz. This corresponds to the period duration of 20 ms (required for the servo).
Once you have made all the configurations, you can control the connected servos with the correct command.
sets the PWM signal of the first (=0) connection of the PCA9685(which is called PCAPWM) to the value 300.
For the servo that I use on connection 0 of my PCA9685, I was able to use the following commands, for example.
- Smallest angle: PCAPWM,0,50,
- Largest angle: PCAPWM,0,300,
How you can send commands to your ESPEasy device is described in the article ESPEasy – Execute commands and actions via HTTP, MQTT, UDP and directly.
Additional general information about this ESPEasy plugin can also be found under the following link:
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. 🙂