#define RXp2 16
#define TXp2 17
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial2.begin(9600, SERIAL_8N1, RXp2, TXp2);
}
void loop() {
Serial.println("Message Received: ");
Serial.println(Serial2.readString());
}
I made a trial project as in the link. Everything worked fine. But when I want to send data faster than about 1000 ms from arduino, I cannot read this fast incoming data from ESP32. Has anything like this happened before?
...........................................................................
Help us help you.
Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'
Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.
Include the entire error message. It is easy to do. There is a button (lower right of the IDE window) called "copy error message". Copy the error and paste into a post in code tags. Paraphrasing the error message leaves out important information.
Post a schematic.
Post an image of your project.
Which Micro Controller are you using?
Is this simulator code?
Please describe the problem better then you just did.
I am taking an analog reading using a potentiometer. I'm converting the data here to digital. and I can control the delay by using this digital data in delay in stm32.
The code for stm32f103c8t6 I wrote is briefly as follows (i used stm32CUBEIDE for this)
you are getting timeouts of 1 second,
e.g. if you call
Serial2.readString()
if nothing is received within a second it will timeout returning empty string
hence you are getting delays of a second in your code
check if there is anything to read, e.g.
if (Serial2.available()) {
metin = Serial2.readString()
.... etc
}
I solved this problem dear friend. thanks for helping. now i will tell you how i solved it. First of all, I should say that I have been trying to solve this problem for about 8-10 days. I tried many purely experimental things to solve this problem. I made a lot of changes in the main libraries of the arduino. I hope I remember unnecessary changes and can undo those changes . now let's get to the solution;
C:\Users..\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\cores\esp32
we have such a file path. here are the main libraries of arduino. i edited this file "Stream.h"
In a part of this header file, there are codes as seen below.
Stream():_startMillis(0)
{
_timeout = 1000;//here is line 54
}
virtual ~Stream() {}
I replaced the 1000 millisecond delay on line 54 with 100 in the header file. and I saved the header file
Stream():_startMillis(0)
{
_timeout = 100;//here is line 54
}
virtual ~Stream() {}
this is how i solved this problem. I don't know if there is any other solution.