Hi again,
As I told you above, I need to send and receive a big JSON between Arduino and Weoms at one code, but at first, I started to send a moderate size string of about 75 characters ( 75 doesn't matter, I just want to send a not short string.
According to Serial Input Basics - updated (which you guys had recommended) I tried to send the string from UNO to Wemos D1 (as shown in the picture) but apparently, there are just only 64 characters could pass through serial communication.
whats is the problem?
Arduino Side:
#include <SoftwareSerial.h>
#include <ArduinoJson.h>
SoftwareSerial s(5,6);
void setup() {
Serial.begin(115200);
s.begin(115200);
}
void loop() {
s.write("<");
s.write("1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890");
s.write(">");
delay(2000);
}
Wemos Side:
#include <SoftwareSerial.h>
#include <ArduinoJson.h>
SoftwareSerial s(D6,D5);
const byte numChars = 1000;
char receivedChars[numChars];
String stringBuffer;
boolean newData = false;
void setup() {
Serial.begin(115200);
s.begin(115200);
}
void loop() {
Serial.println(SerialReceiver());
delay(2000);
}
char* SerialReceiver()
{
memset(receivedChars, 0x00, sizeof(receivedChars)); // i ssuppose this code clear the
receivedChars each loop
newData = false;
static boolean recvInProgress = false;
static byte ndx = 0;
char startMarker = '<';
char endMarker = '>';
char rc;
while (s.available() > 0 && newData == false) {
rc = s.read();
if (recvInProgress == true) {
if (rc != endMarker) {
receivedChars[ndx] = rc;
//stringBuffer +=String(rc);
ndx++;
if (ndx >= numChars) {
ndx = numChars - 1;
}
}
else {
receivedChars[ndx] = '\0'; // terminate the string
recvInProgress = false;
ndx = 0;
newData = true;
}
}
else if (rc == startMarker) {
recvInProgress = true;
}
}
return receivedChars;
}
Wiring
What Wemos get is only 64 characters of what Arduino sent