Close

Final ESP32 code

A project log for Haptic Sleeve

Sleeve worn on the arm to provide haptic feedback while performing handwriting exercises.

grant-stankaitisGrant Stankaitis 06/26/2020 at 20:200 Comments

Firmware and Github update

I have updated the Github repository with the finalized code for the ESP32.

I was having major issues with the BLE Generic Attribute Profile being duplicated. This was a problem because it was causing issues when I was trying to connect programmatically using Python from my PC. For some reason, the service was being duplicated when BLE was initializing, and I tried to track down where the issue came from. Ultimately, I came to the conclusion that it was a firmware issue, and I tried flashing different versions of the Micropython firmware with no luck. Then, "esp32-idf4-20200617-unstable-v1.12-550-g4b5dd012e.bin" firmware was released, so I flashed the ESP32 with this firmware and it fixed the issue! I have uploaded this firmware file to the Github repository so that others can flash the same firmware.

Final code

Once the duplicate service issue was solved, I decided to consolidate my code into one file. The file "main.py," under the "ESP32 Code" folder on Github, is the main code running on the ESP32. This code contains the setup for the Nordic UART Service and handles activating the motors when commands are received. The file "boot.py" runs at every boot-up, importing the necessary Micropython modules and configuring/activating BLE.

"boot.py" and "main.py" can be uploaded to the ESP32, and now you have the fully-functional Haptic Sleeve running!

NOTES

In the final "main.py" code, the pin numbers for the motors are different from those used when testing. The pins were changed because they were closer to route on the PCB. Additionally, the pins for the motors were accidentally routed to pins on the ESP that cannot output PWM, so I cut the traces and soldered jumper wires to the nearest PWM-ready pins. Make sure these pin numbers are correct, and if needed you can change them for future revisions.

Discussions