Week 12: Networking and Communications

Assignment

Group Assignment

Please see this link for my group assignment (Group #2 with Miranda!).

Individual Assignment

For this week’s assignment, I used a board that I laser engraved and populated (designed by Tlyer Jensen Hill!) as part of machine week. The board includes a XIAO-ESP32S3, a PCA9685 (16-Channel 12-bit PWM/Servo Driver - I2C interface) and a couple connectors for output servos. My aim was to control the on-board ESP32 via Bluetooth. But first, I wanted to make sure it behaved as expected, before trying to implement any kind of networking.

To my chagrin, it did not...Upon further inspection I realized that I'd put this board on my shelf after accidentally ripping off the IMU which was originally a part of this circuit as well. Those traces were also the PCA9685's links to 3v3 and the I2C bus. After applying some quick fixes I was able to get it back up and running again (see below).

Board Fix

Next, it was time to code. Having been very limited with my use of chatgpt in this course, I decided to give it a try for this assignment. I don't know if it slept on the wrong side of the bed that night or I'm just a poor prompt engineer. Either way, I wasn't all that satisfied!

Prompt 1: "please write me a simple arduino script for an ESP32S3 which enables me to send either a 1 or a 0 to the device via Bluefruit LE connect on my phone in order to turn on or off the on board led."

Prompt 2: "please auto-send notifications back to the phone and print out incoming traffic to the serial terminal of the arduino ide"

Prompt 3: "are you expecting an EOL character to be sent from the mobile device?"

Now that it was building from a more standardized base code, it seemed to have an easier time generating something funcitonal.

Code snippet

I then prompted it to make this work for a servo. The resulting code did not work. In order to figure out why, I compared the script it genrated with the adafruit example for controlling a servo with this chip (File>Examples>Adafruit PWM Servo Driver Library>servo), and saw that the pwm clock frequency wasn’t being set. Also the delay that should be inserted after sending the command to the servo was missing.

The final change I needed to make: the code chat gpt made sends out a single pwm signal, but the servo did not like this. I implemented the example format (e.g. sweeping through a range of servo values to ramp to the appropriate position) and this worked!

Code snippet 2

Downloads

Schematics and fabrication files for this board can be downloaded here PCA9685_helloWorld_v0.zip.

Code can be found here SERVO_CTRL.ino.

The "Bluefruit LE connect" app can be downloaded from the app store.

Acknowledgements

Return to Home Page