---
title: "How to use OpenAI API with WizFi360-EVB-Pico in Arduino"
url: "https://maker.wiznet.io/austin/projects/how-to-use-openai-api-with-wizfi360-evb-pico-in-arduino/"
markdown_url: "https://maker.wiznet.io/austin/projects/how-to-use-openai-api-with-wizfi360-evb-pico-in-arduino/md"
type: "WCC: WIZnet Created Content"
author: "austin"
original_author: "Austin"
published: "2023-08-21"
language: "en"
tags: ["WizFi360-EVB-Pico", "Arduino", "ChatGPT"]
hardware: ["WIZnet WizFi360-EVB-Pico"]
likes: 4
views: 4329
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# How to use OpenAI API with WizFi360-EVB-Pico in Arduino

> How to use ChatGPT service using OpenAI API with WizFi360-EVB-Pico in Arduino.

Original author: Austin

## Components

- **WIZnet WizFi360-EVB-Pico** x 1

## Documents and links

- [WizFi360_arduino_library](https://github.com/Wiznet/WizFi360_arduino_library/tree/openai) (code): Arduino library and examples for WizFi360
- [WizFi360-EVB-Pico Schematic](https://maker.wiznet.io/_lib/download.asp?path=project/3213&downfile=WizFi360%2DEVB%2DPico%5FSchematic%2Epng) (schematics)

## Article

This document will guide through a series of steps from configuring development environment to running **WizFi360 Arduino library & ChatGPTbasic example using OpenAI API** with the WIZnet's Wi-Fi product - **WizFi360-EVB-Pico**.

I will use '**WizFi360_arduino_library**' provided by WIZnet.

- [WizFi360_arduino_library](https://github.com/Wiznet/WizFi360_arduino_library)

And for the **ChatGPTbasic example using OpenAI API**, the example below was used.

- [WizFi360_arduino_library/examples/OpenAIChatGPTBasic](https://github.com/Wiznet/WizFi360_arduino_library/tree/openai/examples/OpenAIChatGPTBasic)

### **1. Development environment Preparation**

To test the WizFi360 Arduino library & ChatGPT basic example using OpenAI API, the development environment must be configured to use Arduino platform.

Please note that in this guide ChatGPT basic example using OpenAI API was configured and tested using **Arduino IDE** in **Windows** environment.

Before starting, download and install the Arduino IDE from the link below.

- [Arduino IDE](https://www.arduino.cc/en/software)

Additionally, if you are using WizFi360-EVB-Pico, minor settings are required in the Arduino IDE.

WizFi360-EVB-Pico is an development board based on RP2040, and you need to add a package to use the development board based on RP2040.

① Run the **Arduino IDE**

② Open **Preferences**

You can open it through 'File → Preferences' in the menu bar of Arduino IDE.

③ Add next link to **Additional Boards Manager URLs**

```plaintext
https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
```

![Add Boards Manager URLs](https://hackster.imgix.net/uploads/attachments/1631758/image_6Npg4yHfkx.png?auto=compress%2Cformat&w=740&h=555&fit=max)

Add Boards Manager URLs

④ Open **Boards Manager...**

Open it via 'Tool → Board: "" → Boards Manager...'

⑤ Install **board support package**

Search and install **Earle F. Philhower's Raspberry Pico/RP2040** board support package.

![Install board support package](https://hackster.imgix.net/uploads/attachments/1631761/image_A42o4sjspJ.png?auto=compress%2Cformat&w=740&h=555&fit=max)

Install board support package

**2. H/W PreparationWizFi360-EVB-Pico** is a development board that is built on high-performance, low-price MCU **RP2040** and adds Wi-Fi connectivity using **WizFi360**.

More details can be found at below link:

- [WizFi360-EVB-Pico](https://docs.wiznet.io/Product/Open-Source-Hardware/wizfi360-evb-pico)

WizFi360-EVB-Pico is pin compatible to Raspberry Pi Pico. But keep in mind that pins GPIO4 ~ GPIO7 / GPIO20 are used for UART communication / reset between RP2040 and WizFi360.

![WizFi360-EVB-Pico pinout](https://hackster.imgix.net/uploads/attachments/1622615/image_OJKNPIqht4.png?auto=compress%2Cformat&w=740&h=555&fit=max)

WizFi360-EVB-Pico pinout

Follow the steps below to firmware upload and run.

① Connect WizFi360-EVB-Pico to desktop or laptop using 5 pin micro USB cable.

### **3. S/W Preparation**

The following serial terminal program is required for example test, download and install from below link.

- [Tera Term](https://osdn.net/projects/ttssh2/releases/)

### **4. Example Settings**

This section will guide through testing the ChatGPT basic example using OpenAI API with WizFi360-EVB-Pico.

① Setup **Sketchbook location**

Setup the Sketchbook location according to the location of the downloaded 'WizFi360_arduino_library'.

!['WizFi360_arduino_library' location](https://hackster.imgix.net/uploads/attachments/1631783/image_atKwrO5aGC.png?auto=compress%2Cformat&w=740&h=555&fit=max)

'WizFi360_arduino_library' location

![Setup Sketchbook location](https://hackster.imgix.net/uploads/attachments/1631766/image_veatkjbffT.png?auto=compress%2Cformat&w=740&h=555&fit=max)

Setup Sketchbook location

② Open **example**

You can open examples through 'File → Examples → WizFi360'.

![Open example](https://hackster.imgix.net/uploads/attachments/1631770/image_hOiZ2EfIXe.png?auto=compress%2Cformat&w=740&h=555&fit=max)

Open example

③ Select **device**

Select WizFi360-EVB-Pico.

![Select device](https://hackster.imgix.net/uploads/attachments/1631780/image_NdbpHbXMm4.png?auto=compress%2Cformat&w=740&h=555&fit=max)

Select device

④ Select **COM port**

Select the COM port of WizFi360-EVB-Pico.

![Select COM port](https://hackster.imgix.net/uploads/attachments/1631781/image_zOte3P0JSp.png?auto=compress%2Cformat&w=740&h=555&fit=max)

Select COM port

⑤ Setup **device setting** according to device you use

Serial port configuration is different depending on the device used.

- Arduino Mega 2560 : ARDUINO_MEGA_2560

- WizFi360-EVB-Pico : **WIZFI360_EVB_PICO**

```plaintext
// setup according to the device you use
#define WIZFI360_EVB_PICO
```

⑥ Setup **Wi-Fi configuration**

```plaintext
/* Wi-Fi info */
char ssid[] = "wiznet";       // your network SSID (name)
char pass[] = "0123456789";   // your network password
```

⑦ Setup **OpenAI API key**

```plaintext
client.println("Authorization: Bearer sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); // your OpenAI API key
```

### **5. Example Build & Upload**

① After completing the configuration, click **Verify** button.

![Click Verify button](https://hackster.imgix.net/uploads/attachments/1631775/image_dW3ks3cKnB.png?auto=compress%2Cformat&w=740&h=555&fit=max)

Click Verify button

② When the build is completed, click **Upload** button to upload the firmware to the WizFi360-EVB-Pico.

![Click Upload button](https://hackster.imgix.net/uploads/attachments/1631776/image_SXKQS8CSuU.png?auto=compress%2Cformat&w=740&h=555&fit=max)

Click Upload button

**6. Running Example**

① Connect to the serial COM port of WizFi360-EVB-Pico with Tera Term.

![Setup serial COM port](https://hackster.imgix.net/uploads/attachments/1631782/image_4I3TD9tUKX.png?auto=compress%2Cformat&w=740&h=555&fit=max)

Setup serial COM port

② If the example works normally on WizFi360-EVB-Pico, you can see the Wi-Fi connection log and result using ChatGPT service using OpenAI API key as below.

![Example result that works normally](https://hackster.imgix.net/uploads/attachments/1631740/image_67SiYa8Vh5.png?auto=compress%2Cformat&w=740&h=555&fit=max)

Example result that works normally

---

Source: https://maker.wiznet.io/austin/projects/how-to-use-openai-api-with-wizfi360-evb-pico-in-arduino/
