I have an Arduino UNO and an ESP32 that need to communicate to each other using SoftwareSerial. The problem I am coming across is that when I call readString and print it out using Serial, it will not give me everything that has been printed out from my ESP32.
I have my Arduino RX Pin hooked up to 4 and TX hooked up to 5 I have my ESP32 RX2 Pin hooked up to 16 and TX2 pin hooked up to 17, with the GND hooked up to directly to the Arduino GND I am not using any resistors, straight up 5v of pure power
Arduino UNO Code:
// C-standard library
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
// Allows us to avoid using PINS 1 and 0
#include <SoftwareSerial.h>
#define RX_PIN 4
#define TX_PIN 5
SoftwareSerial ardSerial(RX_PIN, TX_PIN);
void setup(void) {
// Get access to network
pinMode(RX_PIN, INPUT);
pinMode(TX_PIN, OUTPUT);
Serial.begin(9600);
while(!Serial) {}
ardSerial.begin(9600);
while(!ardSerial) {}
}
void loop(void) {
while (ardSerial.available() > 0) {
String payload = ardSerial.readString();
Serial.println(payload);
}
delay(1000);
}
ESP32 Code
#include <stdlib.h>
#include <string.h>
// Allows us to avoid using PINS 0 and 1
#include <SoftwareSerial.h>
SoftwareSerial ardSerial;
void setup(void) {
// Begin connections
Serial.begin(115200);
while (!Serial) {}
ardSerial.begin(9600, SWSERIAL_8N1, RX2_PIN, TX2_PIN);
while (!ardSerial) {}
return;
}
void loop(void) {
{
String spotData = "Huge JSON File that needs transferred";
ardSerial.print(spotData);
}
delay(5000);
}
Expected result:
- Able to retrieve every little bit of the JSON file that was printed out
Actual result:
- Only receive like half of the JSON file