@J-M-L Ok I think I understood. I'll do a hand-drawn and tell me if it's correct. A couple minutes and I'll be back
@J-M-L here's the hand-drawn.
just the GND, not the 5V.
of course the resistors have to be set up correctly as a voltage divider
Oh I was almost forgetting... what about the USB communication between the ESP and the tablet?
what about it ?
if your tablet is capable of providing regular 5V 500mA power through its port then it can power the ESP through USB and the communication can be Serial if your tablet offers that capability of a Serial driver for the USB port for example. Depends on what the tablet can or cannot do
Post #22 is suggesting something like Fig-1 using resistors for level shifting of logic signal.
Figure-1:
If you use Laptop instead of Tablet, you can develop applications for ESP32/MEGA using Arduino IDE and also powering the ESP32.
No, I can't use a laptop because it's like a mini robot that moves. About the tablet I know it supports Otg so the voltage should be Ok, but I can't find the serial driver info. It's a Galaxy Tab A 8.0 (2019).
@GolamMostafa
Wait looking from the Mega TX after the first resistor are there a cable that goes to the ESP RX and another resistor that goes between the 2 GNDs?
well that second resistor is what makes the voltage divider, you take the 3.3V in between and the other resistor does go to GND, yes.
As you've GND just underneath in the drawing, that's why @GolamMostafa connected it there.
Yes!
@J-M-L @GolamMostafa ok thank you for telling me about this. I could have risked a lot.
Hi!
I was working on this project, I'll show you a hand drawn with all the parts and what happens.
Problem is at point 2:
When I send the data from the tablet with serial comm. it reads something else and the answer from ChatGPT is a simple " I am an Ai language model and I cannot provide any information or response without contest to your letter (and sometimes it says the number 119 or 111)
I even tried from my pc and it's the same but when I directly type the question into the code it works fine...
This is the code that takes the question from the serial and doesn't work:
/*
* Project ChatGPT Client For ESP32
* Description: For HTTPS connection using WiFiClientSecure
* Date: 04-02-2023
*/
#include <WiFiClientSecure.h>
#include <ArduinoJson.h>
#include <ChatGPT.hpp>
static const char *ssid = "Walid's Galaxy A53 5G";
static const char *password = "my pw";
WiFiClientSecure client;
ChatGPT<WiFiClientSecure> chat_gpt(&client, "v1", "my Api key");
String result;
String domanda;
void setup() {
Serial.begin(115200);
Serial.print("Connecting to WiFi network: ");
Serial.print(ssid);
Serial.println("'...");
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
Serial.println("Connecting...");
delay(500);
}
Serial.println("Connected to Wifi");
// Ignore SSL certificate validation
client.setInsecure();
}
void loop() {
if (Serial.available()) {
char incomingChar = Serial.read();
domanda = String(incomingChar);
Serial.println("[ChatGPT] Only print a content message");
if (chat_gpt.simple_message("gpt-3.5-turbo-0301", "user", domanda, result)) {
Serial.println("===OK===");
Serial.println(result);
} else {
Serial.println("===ERROR===");
Serial.println(result);
}
Serial.println("\n\n[ChatGPT] Print full message(JSON Type)");
if (chat_gpt.full_message("gpt-3.5-turbo", "user", "What is the OpenAI mission?", result)) {
Serial.println("===OK===");
Serial.println(result);
} else {
Serial.println("===ERROR===");
Serial.println(result);
}
}
}
This is the one that takes the question from the code and works:
#include <WiFiClientSecure.h>
#include <ArduinoJson.h>
#include <ChatGPT.hpp>
static const char *ssid = "<WIFI_SSID>";
static const char *password = "<WIFI_PW>";
WiFiClientSecure client;
ChatGPT<WiFiClientSecure> chat_gpt(&client, "v1", "<OpenAI_API_KEY>");
void setup() {
Serial.begin(115200);
Serial.print("Connecting to WiFi network: ");
Serial.print(ssid);
Serial.println("'...");
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
Serial.println("Connecting...");
delay(500);
}
Serial.println("Connected!");
// Ignore SSL certificate validation
client.setInsecure();
String result;
Serial.println("[ChatGPT] Only print a content message");
if (chat_gpt.simple_message("gpt-3.5-turbo-0301", "user", "Planning a 3-day trip to San Diego", result)) {
Serial.println("===OK===");
Serial.println(result);
} else {
Serial.println("===ERROR===");
Serial.println(result);
}
Serial.println("\n\n[ChatGPT] Print full message(JSON Type)");
if (chat_gpt.full_message("gpt-3.5-turbo", "user", "What is the OpenAI mission?", result)) {
Serial.println("===OK===");
Serial.println(result);
} else {
Serial.println("===ERROR===");
Serial.println(result);
}
}
void loop() {}
Thank you
Wow! Thank you for the fast answer! I knew there was something wrong with that serial. I'll read about it and let you know.
Your two or more topics on the same or similar subject have been merged.
Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.
Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.
Repeated duplicate posting could result in a temporary or permanent ban from the forum.
Could you take a few moments to Learn How To Use The Forum
It will help you get the best out of the forum in the future.
Thank you.
HII! it's me again.
I decided I'm going to connect the ESP-32 and the tablet by bluetooth instead of USB because I had some problems with the USB port of the tablet. The only problem is that I don't know if I can connect it with 2 devices that are: the phone which will send the question to the Esp, and the tablet which will receive the answer.
Oh and another thing is that if I use an end marker for the received question from the phone can I make it read the other data that doesn't have an endmarker? because on my phone I will use 2 apps that send different data that can't mix: one app that I made is for sending the question and the other is for sending the commands that will go to the DC motors to make the robot move.
Thank you a lot for the help you gave me
The help that you can get is:
developping your project step by step. One step after the other and not all at the same time.
Thinking through what you want to do all in all is good.
But working on all ends at the same time is a really bad idea.
jumping over to the next thing if problems occur is a bad strategy.
A longer time ago I tried to get bluetooth and WiFi to work at the same time but it did not work.
Bluetooth needs a lot of memory.
You can. It is just a matter of your programming skills
Oh! such a project is very different from ordering a large bowl with different flavors of ice cream.
Oh ! not to forget do you have
stracciatella?
honeydew melons?
lemon cheesecake?
panna cotta forest fruit?
and of course salted caramel?
But I guess you have to stumble and stumble and stumble and stumble around changing ideas, and changing ideas/approaches, changing ideas and aproaches before you believe it.
If this is a project for personal fun you can take time for it.
If this is a project where you have a deadline reduce it down to two devices. Do you understand?
8 - 6 = 2 devices that interact with each other.
In phantasy I can fly to the moon and through wormholes back or forth in time.
Get one part functioning properly including testing what happends if I change conditions to.....
Then add the next one.
@walid2009
I would suggest to develop the system using a PC under SSS Strategy (Small Start) and then replace the PC by Tablet. This development environment will allow the readers to participate in the ChatGPT based Project.
Can you please write (using Serial Numbers) below in plain text the names of the first 5 tasks that you are going to realize?
This is the philosophy behind the SSS Methodology of Project Development.
Did I do or wrote something wrong? English is not my native language and I'm 14. I mean calm down, it's just that I have time until Monday...
Oh and about the working of BT and WiFi at the same time it's not a problem I already tested it and same about memory, it's not a problem
Sorry I didn't understand what do you mean by using Serial Numbers
use google translate
most important lesson to learn: don't pause for a hole week
the more specific you ask the better help you can get
this is a pretty generalised question. No code no example of how the end-marker data looks like and how the non-endmarker-data looks like.
So the generalised answer is:
Yes this can be done.
The how it can be done depends fully on how the end-marker-message and the non-edmarker message looks like.