---
title: "W55RP20-EVB-Pico: Chat with ChatGPT Example"
url: "https://maker.wiznet.io/Benjamin/projects/w55rp20-evb-pico-chat-with-chatgpt-example/"
markdown_url: "https://maker.wiznet.io/Benjamin/projects/w55rp20-evb-pico-chat-with-chatgpt-example/md"
type: "WCC: WIZnet Created Content"
author: "Benjamin"
author_url: "https://maker.wiznet.io/Benjamin/"
original_author: "Benjamin"
published: "2024-10-08"
language: "en"
tags: ["AI", "Raspberry Pi", "W55RP20", "ionic-contest-ref"]
hardware: ["WIZnet W55RP20-EVB-Pico"]
likes: 0
views: 6489
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# W55RP20-EVB-Pico: Chat with ChatGPT Example

> This project uses the W55RP20-EVB-Pico to implement a simple chat interface that establishes an Ethernet connection and interacts with the OpenAI ChatGPT API

Original author: Benjamin

## Components

- **WIZnet W55RP20-EVB-Pico** x 1 ([docs](https://wiznet.io/products/powered-by-raspberry-pi/w55rp20-evb-pico))
- Software: **MicroPython** ([docs](http://micropython.org/))
- Software: **OpenAI ChatGPT** ([docs](https://chat.openai.com/))

## Documents and links

- [w55rp20_chatgpt_ethernet.py](https://github.com/wiznetmaker/W55RP20-EVB-Pico-Chat-with-ChatGPT-Example/blob/main/w55rp20_chatgpt_ethernet.py) (code)

## Article

This project provides a comprehensive guide on using the **W55RP20-EVB-Pico** evaluation board to establish an Ethernet connection and interact with OpenAI's ChatGPT API. The project demonstrates how to create a simple yet functional chat interface between the user and ChatGPT, leveraging the hardware-based Ethernet capabilities of the module.

## Overview

The **W55RP20-EVB-Pico** is an evaluation board that integrates the **W5500 Ethernet controller** with the **RP2040 microcontroller**, offering both the features of a Raspberry Pi Pico and wired Ethernet connectivity. This board is ideal for projects that require stable and high-speed network communication.

![W55RP20-EVB-Pico Board](https://github.com/user-attachments/assets/93a57464-3edd-40eb-b8f8-b2dba4f42022)

### Key Features of W55RP20-EVB-Pico

- **W55RP20 Microcontroller**: Combines the W5500 Ethernet controller with the RP2040 chip.

- **RP2040 Dual-Core Processor**: 133 MHz Cortex M0+ dual-core processor for robust performance.

- **Built-in Ethernet Support**: Hardwired TCP/IP stack supports up to 8 simultaneous sockets and protocols like TCP, UDP, ICMP, IPv4, and more.

- **GPIO Pin Compatibility**: Pinout similar to Raspberry Pi Pico, ensuring compatibility with Pico-based projects.

- **Built-in RJ45 and Power-over-Ethernet (PoE) Support**: Simplifies network connectivity and power management.

For detailed specifications, please refer to the official documentation.

## Project Description

This project showcases:

- **Ethernet Initialization**: Setting up the Ethernet interface on the W55RP20-EVB-Pico.

- **API Requests**: Communicating with the OpenAI ChatGPT API to send prompts and receive responses.

- **Interactive Chat Interface**: Enabling a command-line interface for users to interact with ChatGPT.

By following this guide, you can communicate with ChatGPT through the device, enabling interactive conversations and opening possibilities for integrating AI into embedded systems.

### MicroPython Firmware

The MicroPython firmware for **W55RP20-EVB-Pico** is available on the WIZnet-ioNIC GitHub repository. This firmware is essential for running MicroPython code on the module and utilizing its Ethernet features.

## Project Setup

### Required Hardware

- **W55RP20-EVB-Pico** module

- **Ethernet cable**

- **USB cable** for power and programming

### Software Requirements

- **MicroPython** support for RP2040

- **WIZNET_PIO_SPI** library for SPI communication

- Python libraries: `json`, `urequests`, `network`, `machine`

### Running the Project

1. **Connect the Ethernet**: Plug an Ethernet cable into the W55RP20-EVB-Pico board.

2. **Download the Code**: Clone or download the project repository to your local development environment.

3. **Configure the API Key**: Replace the `api_key` variable in the code with your OpenAI API key.

4. **Load Firmware**: Flash the appropriate MicroPython firmware onto your W55RP20-EVB-Pico module.

5. **Upload the Code**: Transfer the `main.py` file to the module using a serial terminal or an IDE like Thonny.

6. **Run the Code**: Execute the script to start the chat interface.

### Code Explanation

- **Ethernet Initialization (**`**init_ethernet**`**)**: Establishes a wired network connection using the WIZNET5K library, with retry logic for connection stability.

- **ChatGPT API Interaction (**`**send_prompt_to_chatGPT**`**)**: Handles API calls to OpenAI, sending user prompts and receiving responses, including error handling and retries.

- **Chat Loop (**`**chat_with_chatGPT**`**)**: Provides a command-line interface for continuous conversation with ChatGPT.

## Example Use Case

Once set up, you can have an interactive conversation with ChatGPT directly from the W55RP20-EVB-Pico module via the command line.

![Example Interaction](https://github.com/user-attachments/assets/29fb11bb-64ee-40be-b09d-cbaf962cf849)

## Future Enhancements

This project serves as a foundation for more advanced applications:

- **Additional API Integrations**: Connect with other services like weather data, stock information, or home automation systems.

- **Custom AI Models**: Utilize other AI models for tasks like sentiment analysis, translation, or summarization.

- **Advanced Features**: Implement functionalities such as notifications, data logging, or integration with other IoT devices.

## How to Get Firmware

- **WIZnet-ioNIC MicroPython Firmware**: Available on<https://github.com/WIZnet-ioNIC/WIZnet-ioNIC-micropython>GitHub for the W55RP20-EVB-Pico.

## Contributing

We welcome contributions to enhance this project. Feel free to open issues and submit pull requests on the GitHub repository.

## References

- RP2040 Datasheet

- W55RP20-EVB-Pico Official Documentation

---

Source: https://maker.wiznet.io/Benjamin/projects/w55rp20-evb-pico-chat-with-chatgpt-example/
