Ezo A Pet Robot

Published  November 21, 2024   0
Ezo A Pet Robot

Unfortunately, my project failed but I can express what I have tried to create. Ezo has many abilities the common one is talking to you like a friend and answering any of your questions remembering things and having the freedom to look around and understand the surroundings and it can show faces based on the situation and your answer Now the cool part comes where Ezo now has pins on it and can control them according to your order so if you do not know C++ Ezo can help your simple projects come to life.

COMPONENTS REQUIRED:

  1. The Maixduino board

  2. L298N motor driver

  3. 12 v motors

  4. 12v battery

  5. Wires (jumper and solid core)

To see the full demonstration video, click on the YouTube Video below

CIRCUIT DIAGRAM:

Ezo AI Circuit Diagram

CODE EXPLAINATION:

The code I could write:

#include <WiFi.h> // Include Wi-Fi library to
connect to Wi-Fi networks
#include <HttpClient.h> // Include HTTP client
library for HTTP requests
// WiFi credentials
char ssid[] = "yourSSID"; // Wi-Fi network name
char password[] = "yourPassword"; // Wi-Fi
password
// Server and API details
const char* server = "api.openai.com"; //
OpenAI API server
const int port = 443; // Port for HTTPS (secure
communication)
const char* apiUrl = "/v1/chat/completions"; //
API endpoint for ChatGPT
const char* apiKey = "yourApiKey"; // API key
for authorization
// Initialize WiFi and HTTP clients
WiFiClient wifiClient; // WiFi client to manage
network connection
HttpClient httpClient(wifiClient); // HTTP client
for sending requests over WiFi
void setup() {
Serial.begin(9600); // Start serial
communication at 9600 baud rate
// Connect to WiFi
Serial.print("Connecting to WiFi...");
WiFi.begin(ssid, password); // Begin WiFi
connection
while (WiFi.status() != WL_CONNECTED) { //
Wait until connected
delay(500);
Serial.print("."); // Print dots while waiting
}
Serial.println("\nConnected to WiFi"); // Confirm
connection
}
String chatWithGPT(String userInput) {
// Prepare JSON data for the API request,
embedding user input
String jsonData = "{\"model\": \"gpt-3.5-turbo\"
,
\"messages\": [{\"role\": \"user\"
, \"content\": \"" +
userInput + "\"}]}";
const char* jsonDataCStr = jsonData.c_str(); //
Convert JSON data to C string
// Send POST request to OpenAI API
httpClient.beginRequest(); // Start the request
httpClient.post(server, port, apiUrl,
jsonDataCStr); // Send POST request with
server, port, and URL
// Add HTTP headers
httpClient.sendHeader("Authorization"
, ("Bearer
" + String(apiKey)).c_str()); // API authorization
httpClient.sendHeader("Content-Type"
,
"application/json"); // Data type
httpClient.sendHeader("Content-Length"
,
strlen(jsonDataCStr)); // Data length
// End request and receive response
httpClient.endRequest(); // Complete the HTTP
request
String response = httpClient.readString(); //
Read the response from the server
return response; // Return response as a string
}
void loop() {
String userInput = "Hello, ChatGPT!"; // Sample
input message to ChatGPT
String response = chatWithGPT(userInput); //
Call function to send message and get
response
Serial.println("ChatGPT response: " +
response); // Print ChatGPT's response to
Serial Monitor
delay(10000); // Wait 10 seconds before
sending the next request
}

PICTURE OF THE DELIVERY:

Maixduino Kit

Have any question realated to this Article?

Ask Our Community Members