Skip to content

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.

austin

Published September 20, 2023

44 UCC

3 WCC

13 VAR

1 Followers

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

Project description

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.

And for the DALL-E basic example using OpenAI API, the example below was used.

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.

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

https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
Add Boards Manager URLs
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
Install board support package
 
2. H/W Preparation

WizFi360-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 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
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.

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
'WizFi360_arduino_library' location
 
Setup Sketchbook location
Setup Sketchbook location
 
② Open example

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

Open example
Open example
 
③ Select device

Select WizFi360-EVB-Pico.

Select device
Select device
 
④ Select COM port

Select the COM port of WizFi360-EVB-Pico.

Select COM port
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
// setup according to the device you use
#define WIZFI360_EVB_PICO

⑥ Setup Wi-Fi configuration

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

⑦ Setup OpenAI API key

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

5. Example Build & Upload

① After completing the configuration, click Verify button.

Click Verify button
Click Verify button
 
② When the build is completed, click Upload button to upload the firmware to the WizFi360-EVB-Pico.
Click Upload button
Click Upload button
 
6. Running Example

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

Setup serial COM port
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
Example result that works normally
 
③ If you access the URL, you can see the image created using DALL-E service as below.
 
Ceated image
Ceated image
 


 

Documents

  • WizFi360_arduino_library

    Arduino library and examples for WizFi360

  • WizFi360-EVB-Pico Schematic

Comments

Similar projects you might like

Comments