Hello Deva_Rishi! It's supposed to put the received data -> Jason file so it can be accessed by the web server. Or maybe there's another way to it.
I apologize for the message I sent. I was quite tired and simply attached everything into the code and making it a mess. I got a nap and I just tried the simple program that you have given. So, it doesn't show the question marks anymore... In the Serial monitor, it's just this. Is this a good sign?
Also this is the wiring adjustments I made (I wanted to make sure I'm doing it right)...
I'll explain it starting from the black and brown box connected by a resistor/somehow looking divided by them...
Brown is the Rx of Uno and Black being Tx of ESP32
The other black and brown that are beside each other...
Brown is the GND for ESP32 and the Black is the GND for Uno.
Now for the wirings for the voltage divider...
White is the Rx of the ESP32 and the orange is the Tx of the Uno.
That's all for the wirings
And some extra details...
For Uno, the TX (transmitter) is blinking and for the ESP32, only the red led lights up.
For reference, here is an image:
[EDIT: I forgot to add the code I used but this is it...
Uno R3 Sample Sketch:
void setup() {
Serial.begin(115200);
}
void loop() {
Serial.println("Hi");
}
ESP32 Sample Sketch:
void setup() {
Serial.begin(115200);
Serial2.begin(115200);
}
void loop() {
if(Serial.available()) {
Serial2.write(Serial.read());
}
if(Serial2.available()) {
Serial.write(Serial2.read());
}
}
That's all for the code]
[EDIT2: Decided to use the code from Robin (using the finalized one and copy and pasted after analyzing it but I don't get any data from it at all.)
Uno code:
void setup() {
Serial.begin(115200);
}
void loop() {
Serial.println("<Hello!>");
}
ESP32 code:
//---DATA---
const byte CharNo = 32;
char CharRcv[CharNo];
boolean newdata = false;
void setup(){
Serial.begin(115200);
Serial2.begin(115200);
}
void recvWithStartEndMarkers() {
static boolean recvInProgress = false;
static byte ndx = 0;
char startMarker = '<';
char endMarker = '>';
char rc;
if (Serial2.available() > 0 && newdata == false) {
rc = Serial2.read();
if (recvInProgress == true) {
if (rc != endMarker) {
CharRcv[ndx] = rc;
ndx++;
if (ndx >= CharNo) {
ndx = CharNo - 1;
}
}
else {
CharRcv[ndx] = '\0'; // terminate the string
recvInProgress = false;
ndx = 0;
newdata = true;
}
}
else if (rc == startMarker) {
recvInProgress = true;
}
}
}
void showNewData() {
if (newdata == true) {
Serial.print("This just in ... ");
Serial.println(CharRcv);
newdata = false;
}
}
void loop(){
recvWithStartEndMarkers();
showNewData();
}
If I'm doing this right. I assumed that since I'm using pin 16&17. It should be Serial2.available();
However, for some reason, it will show no data... ]
This is all, thank you. I also apologize for the inconvenience.