Wiznet makers

rahulkhanna

Published June 08, 2023 © MIT license (MIT)

0 UCC

0 VAR

3 Contests

0 Followers

1 Following

QuizMaster - ChatGPT-Driven Quiz Game

QuizMaster is an interactive game that makes learning fun usingWIZnet W5300 TOE Shield, STM32F429 Nucleo and ChatGPT.

COMPONENTS Hardware components

WIZnet - W5300-TOE-Shield

x 1


x 1


ST - NUCLEO-F429ZI

x 1

Software Apps and online services

Arduino - Arduino IDE

x 1


PROJECT DESCRIPTION

Quick Intro

Introducing my entry for the WIZnet annual IoT design contest! We proudly present the "Educational Quiz Game," a captivating project showcasing the WIZnet W5300 TOE shield, STM32F429 Nucleo Board, and Infineon IoT Sense board with OLED display. Our project combines cutting-edge technology and educational content to create an interactive quiz game experience.

Setting up the Hardware

We will be using the W5300-TOE-Arduino git for this project. After configuration, plug the WIZnet W5300 TOE Shield into the Nucleo-STM32F429ZI as shown. 

                       

By following the example, we have successfully implemented the advanced chat server demonstration.

Concept

The Educational Quiz Game is designed to make learning fun and interactive by challenging players with a series of educational questions. We will develop an educational quiz game using Arduino, an Ethernet module, and the ChatGPT API. The Arduino board displays questions on an OLED screen and waits for user responses. When the user selects an answer, the Arduino sends the response to the ChatGPT API for evaluation. The API determines if the answer is correct or incorrect and sends the result back to the Arduino, which updates the score and displays the outcome. This interactive quiz game can cover various subjects, making learning fun and engaging.

Hardware Connections

Infineon IoT Sense board with the OLED display offers a crisp and clear interface for displaying questions, options, and scores. We'll be using the I2C port Pins PB8, and PB9 for the OLED. The GPIO pins PG5, PG8, PE0 & PF11 are used for the buttons that enable players to input their answers. (Option A, B, C, D) 

Button button1(PG5); 
Button button2(PG8); 
Button button3(PE0); 
Button button4(PF11);

Let's Code and Play

The WIZnet W5300 TOE shield provides reliable Internet connectivity, ensuring uninterrupted communication with the ChatGPT API for fetching and evaluating quiz questions. The ChatGPT API powers the quiz game by providing a vast database of educational questions. It enables real-time interaction, ensuring a dynamic and engaging experience for players.

The OLED display on the Infineon IoT Sense board showcases the current score of the player.

void introtext(void) {
  display.clearDisplay();
  display.setTextSize(1); // Draw 2X-scale text
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(25, 0);
  display.println("QuizMaster");
  display.println("ChatGPT-Driven Quiz");
  display.println("");
  display.println("YouTube @rahul-khanna");

  display.display();      // Show initial text
  delay(1000); // Adjust the delay time to control scrolling speed
  display.clearDisplay();

}

Players are presented with a series of educational questions on the OLED display. They use the buttons on the STM32F429 Nucleo Board to select their answers. Upon receiving an answer, the board communicates with the ChatGPT API to evaluate the response. The API responds with the correctness of the answer, and the OLED display updates the scores accordingly. Players can see their scores and compete against each other to achieve the highest score.

Create a ChatGPT API Key as shown. 

Replace "YOUR_API_KEY" with your actual ChatGPT API key in the line below.

// ChatGPT API endpoint and parameters
const char* apiEndpoint = "https://api.openai.com/v1/engines/davinci-codex/completions";
const char* apiKey = "YOUR_API_KEY";
const int contentLength = 74;  // Adjust the content length based on the prompt length

ChatGPT API request 

if (client.connect(apiEndpoint, 443)) { 
String payload = "Ask me a quiz question with four options and tell the correct option
 ";
client.println("POST " + String(apiEndpoint) + " HTTP/1.1"); 
client.println("Host: api.openai.com"); 
client.println("Authorization: Bearer " + String(apiKey)); 
client.println("Content-Type: application/json"); 
client.println("Content-Length: " + String(contentLength + payload.length())); client.println(); 
client.println(payload); 
} 
else { 
Serial.println("Connection to ChatGPT API failed!"); 
}

Chat GPT API response

The ChatGPT API makes the gaming experience interesting. Instant feedback on the correctness of answers reinforces learning and encourages players to improve their knowledge base.

Conclusion

Our Educational Quiz Game demonstrates the power of IoT and educational content integration. By leveraging the ChatGPT API, we create an immersive quiz game experience that engages players, promotes learning, and showcases the capabilities of the WIZnet W5300 TOE shield in providing seamless Internet connectivity. The project aims to inspire students and learners of all ages to explore educational topics in a fun and interactive manner. Thanks for reading!


 

Documents
  • Connection Diagram

Comments Write