---
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-1/"
markdown_url: "https://maker.wiznet.io/austin/projects/how-to-use-openai-api-with-wizfi360-evb-pico-in-arduino-1/md"
type: "WCC: WIZnet Created Content"
author: "austin"
original_author: "Austin"
published: "2023-09-20"
language: "en"
tags: ["DALL-E", "WizFi360-EVB-Pico", "Arduino"]
likes: 1
views: 1226
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

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

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

Original author: Austin

## 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%2D44628336cfa4d71657c04fbf4bf9b8c4%2Epng) (schematics)

## Article

This document will guide through a series of steps from configuring development environment to running **WizFi360 Arduino library & DALL-Ebasic 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 **DALL-E basic example using OpenAI API**, the example below was used.

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

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

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

Please note that in this guide DALL-E 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/1631785/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/1631786/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/1631787/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 DALL-E 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/1631788/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/1631789/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/1631797/image_1fpKZThF4P.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/1631800/image_WCwwpMGAZP.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/1631801/image_pKF0TWDVOB.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/1631802/image_aRqqPpMc0S.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/1631803/image_GOU6PVVTG7.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/1631795/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 DALL-E service using OpenAI API key as below.

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

Example result that works normally

③ If you access the URL, you can see the image created using DALL-E service as below.

![Ceated image](https://hackster.imgix.net/uploads/attachments/1631818/image_CZLEhhOOvE.png?auto=compress%2Cformat&w=740&h=555&fit=max)

Ceated image

---

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