Creating essential libraries to support microcontrollers like Arduino can be a formidable task. However, imagine if ChatGPT could lend a hand in this endeavor. This is what we are going to cover in this article using Arduino with ChatGPT.
Adafruit's Limor "Ladyada" Fried has set ChatGPT to the challenge of writing Arduino drivers in her distinctive style, essentially creating a "mini-Limor" bot to tackle this demanding task.
Adafruit's Innovative Approach:
Adafruit's dedicated efforts in writing Arduino libraries are well-documented, boasting hundreds of libraries to bolster their impressive array of boards, many of which feature prominently on our best Grove and Stemma QT page.
GPT-4 has been meticulously trained using numerous Adafruit drivers from their GitHub repository. These drivers are intricately crafted in the renowned "Ladyada style," referred to as Adafruit_BusIO, serving as a template for generating drivers.
Mastering the Challenge:
The process involves intricate steps such as referencing datasheets, deciphering binary tables, and comprehending complex bit configurations. All of these elements must then be skillfully translated into C or Python code.
It's a formidable task, particularly considering the absence of standardized data formats within datasheets, which can vary significantly.
AI-Powered Workflow:
For "mini-Limor," Fried has devised a workflow that entails instructing ChatGPT to "craft an Arduino library in the style of Ladyada / Limor Fried." As an example, Fried guides ChatGPT in creating a driver for the VCNL4020 ambient light and infrared sensor, a sensor reliant on the I2C protocol.
The workflow is streamlined using an AI-powered PDF parsing plugin, AI PDF, capable of extracting register names, values, generating enum tables, and providing descriptive text for comments.
Automated Progress:
Subsequently, Fried directs ChatGPT to construct a preliminary file structure for the VCNL4020, with partial success. The next step involves instructing ChatGPT to formulate the registers using data directly sourced from the datasheet, eventually culminating in the creation of a fully-fledged library.
Speed vs. Human Oversight:
Is this AI-driven process notably quicker? Not necessarily. As per Adafruit's blog post, "The time it takes for ChatGPT to develop a driver is approximately equivalent to the time Ladyada would require." Furthermore, the resultant driver necessitates human verification due to ChatGPT's occasional tendency to "hallucinate" and introduce inaccuracies.
Transparency and Disclosure:
It's crucial to emphasize that the work generated is built upon Adafruit's prior groundwork, and Adafruit remains committed to disclosing and linking any utilization of Large Language Models (LLMs).
Empowering Developers:
Quality drivers serve as the cornerstone for beginners to embark on their journey without delving into intricate technical intricacies, particularly when working with protocols like I2C and SPI. If this process can be further streamlined and automated, it could greatly assist developers, including Adafruit, in crafting drivers and libraries for a multitude of popular programming languages.
This approach also holds the potential to enhance third-party software support for the Arduino Uno R4 series of boards. Additionally, Fried points out that this process is also applicable to CircuitPython, extending its benefits to the Raspberry Pi Pico range of boards.