Quizmaster - Chatgpt-driven Quiz Game

About the project

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

Project info

Difficulty: Moderate

Platforms: ArduinoSTMicroelectronicsWIZnet

Estimated time: 1 hour

License: MIT license (MIT)

Items used in this project

Hardware components

STMicroelectronics NUCLEO-F439ZI STMicroelectronics NUCLEO-F439ZI x 1
Wiznet W5300 Wiznet W5300 x 1

Software apps and online services

Arduino IDE Arduino IDE

Story

Quick Intro

We're excited to present the "Educational Quiz Game, " an interesting 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 documentation, 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!

Schematics, diagrams and documents

Block Diagram

Code

Project Repo

Credits

Photo of the lonely programmer

the lonely programmer

Passionate Techie ! Robotics | Electronics | Programming Hey Geek! If you are in search of electronics projects, Arduino based projects or any Micro-controller based projects, this channel is for you. In this channel, we build electronics projects using the impressive and low-cost boards that are available today. If you are a maker or if you want to learn how to make your own Arduino projects and other interesting Robots, do subscribe the channel to be a part of this community. We develop our own hardware and software projects and will try to build something new. Don’t worry if you don’t know how to program. I'll share the algorithm if you face any difficulties.

   

Leave your feedback...