Jeff Epler Puts a ChatGPT-Powered Text Generator on Your Desk with a Raspberry Pi Pico W

CircuitPython-powered project sends pre-defined prompts to OpenAI's popular large language model interface and prints the response.

Maker Jeff Epler has penned a guide to getting started with OpenAI's popular large language model (LLM) interface ChatGPT on embedded hardware, showing how to generate unique responses from a Raspberry Pi Pico W using CircuitPython.

"At startup, or when the arcade button is pressed, a new, original snippet of text will be generated on OpenAI's servers and shown on the OLED screen connected to your Pico W," Epler writes of the project. "Because of the random factor in the text ChatGPT generates, it's unlikely that two responses would ever be the same. Since ChatGPT generates plausible text rather than making true statements, use this project only for situations where the truth is unimportant."

Possibly the simplest ChatGPT interface around, this box only needs you to press a button to generate a response. (πŸ“Ή: Jeff Epler)

Epler's creation makes use of ChatGPT, an interactive interface to a large language model (LLM) developed by OpenAI. Designed as a chatbot, ChatGPT takes an input β€” including parsing instructions, such as how the output should be formatted or phrased β€” and generates a likely response. Its apparent creativity has spawned a large number of projects, but the model's tendency to "hallucinate" and present nonsense as facts can hamper its broader use.

In Epler's project, a Raspberry Pi Pico W running CircuitPython is connected to an OLED display and an arcade button in a custom housing. When connected to power and the network, the device waits for the button to be pushed β€” then sends a predefined prompt to ChatGPT over OpenAI's application programming interface (API), printing the response on the screen.

"It's easy to customize the prompt using any text editor," Epler says. "This works by writing a sentence or two in natural human language describing what you'd like ChatGPT to generate; no complicated coding is needed to get a description of an imaginary plant instead, or even to generate text in French instead of English!"

"Using ChatGPT on a Raspberry Pi Pico W with a CircuitPython program can be a fun and educational project. It can allow you to experiment with natural language processing, text generation, and other AI applications in a hands-on way," ChatGPT told us in whatever the LLM equivalent of an "interview" would be, when prompted to comment on the project.

"The Raspberry Pi Pico W is a low-cost microcontroller that can run CircuitPython, a beginner-friendly programming language, making it a great platform for learning about AI and machine learning. Jeff Epler's guide can provide helpful insights and tips for getting started with this project."

The full project write-up is now available on the Adafruit Learn portal. "The code in this guide does use a paid API at OpenAI, but based on the pricing in March 2023, the cost to access the API for this project is measured in fractions of a cent, not in dollars," Epler notes. "During the whole development process of this guide, the author's costs on OpenAI were less than $0.25."

Gareth Halfacree
Freelance journalist, technical author, hacker, tinkerer, erstwhile sysadmin. For hire: freelance@halfacree.co.uk.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles