hello friends. Firstly sorry my english.I know a little english not very well. I have a project about the esp8266.But I have a problem about Serial communication.I want to send a long String(max. 1000 byte) with Serial.Println() but data could not send correct to the opposite micro controller device with RX TX pins. How can I increase the buffer size or split the data before I sent . The problem not always shows up ,just It showed up when I try a few times
` server.on("/runScript", HTTP_POST, [](AsyncWebServerRequest *request) {
if (request->hasArg("command"))
{
String command = request->arg("command");
Serial.println(command);
// Handle the command as needed
// You can add your logic here to process the command
// For simplicity, just printing it to the Serial Monitor
}
request->send(200, "text/plain", "Command received");
});
`
Be aware that esp8266 have only one full serial port, the one connected to usb-serial.
Some devboards fail to use tx/rx pins for Serial.
If you only need to send (and not to receive), you could use Serial1 TX on pin Gpio2.
If your baudrate is low, you can also use softwareserial. Or swap Serial to Gpio 13/15
I have an atmega32U4 with in arduino pro micro.I am building an automation .My data like this
"SHELL terminator
STRING memory=$(free)
STRING sudo /bin/bash -c "echo $memory > $HOME/use_memory/memory.txt"
STRING cd $HOME/use_memory/ & python3 -m http.server
PORT http,5000,memory.txt,$USER"
Then I processes the data in atmega micro chip and send with keystroke to the computer
is this really problem that I am using the TX pin. I have connected cross over the cabless with atmega32U4.The problem usualy is being when I runed the command a few trys
Actually, the main function of my code is to take the data coming from this web and send it via serial port by making a post request to "/runScript". I have already shared this page of my code at the top. I'm sharing part of my main web page that sends "command", part of loop() and setup()
i told you that the code can't help, there's only serial communication in one or two places in the code.Whatever.The problem seems to be caused by buffer from HardwareSerial of buffer size.i read that it was set from h and added the following "#define SERIAL_TX_BUFFER_SIZE 1024 #define SERIAL_RX_BUFFER_SIZE 512" but there is still the same error.Could this be due to the fact that I put a String expression in the serial phonjtion? Because the string has extra bytes and space.
You haven't publish any errors.
My point was just to verify that you really have working serial connection with your other MCU, not that your buffer size is correct.