We're going to use a combination of the Adafruit IO Client Library and Adafruit's CircuitPython to control a Raspberry Pi over Adafruit IO.
If you're following along with a Raspberry Pi, we're going to use a T-Cobbler Plus for the IO Basics Projects. This add-on prototyping board lets you easily connect a Raspberry Pi (Raspberry Pi Model Zero, A+, B+, Pi 2, Pi 3) to a solderless breadboard:
Want to create an automatic fish-feeder, a door-lock system with vibration-feedback, or maybe you want to just chain a bunch of lights and motors together and control them with Adafruit IO?
You'll need a few PWM outputs. This guide requires only one for the servo.
The Raspberry Pi is limited to one PWM output. While we could use this PWM output for the servo, we're going to use the Adafruit 16-Channel 12-bit PWM/Servo driver. This board can be used to control up to 16 PWM outputs. This means you can have a bunch of servos, DC motors, LED lights, or even a combination of both.
We are powering the servo from an external 5V 2A switching power supply connected to the terminal block on the breakout board via a DC adapter.
Why wouldn't we use the +5V supply on the Raspberry Pi instead?
Switching directions on the servo can cause a lot of noise on the supply, and the servo(s) will cause the voltage to fluctuate significantly, which is a bad situation for the Pi. It's highly recommended to use an external 5V supply with servo motors to avoid problems caused by voltage drops on the Pi's 5V line.
Make the following connections between the Raspberry Pi and the PCA9685:
- Pi 3.3V to Power Rail
- Pi GND to Ground Rail
- 3.3V to PCA9685 VCC
- GND to PCA9685 GND
- Pi SDA to PCA9685 SDA
- Pi SCL to PCA9685 SCL
Make the following connections between the servo and the PCA9685's Channel 0:
- Servo Black/Brown to PCA9685 GND
- Servo Red to PCA9685 V+
- Servo Yellow to PCA9685 PWM
Finally, connect the PCA9685's screw terminal to the external power supply:
- PCA9685 V+ to the Power Supply + (positive)
- PCA9685 GND to the Power Supply - (negative)