idahowalker wrote: ↑Wed Oct 30, 2019 9:59 pm
You could set up another serial port, Serial2, on your ESP32.
Connect a wire from Serial1tx to Serial2rx. Send some data out Serial1, print Serial2 receive data to Serial, did you get sumpting printed on the serial monitor? If you did serial1 sent sumpting, and Serial2 got it.
How am I supposed to do that ?
On the Wroom-32 Serial1 pins are RXD = GPIO9 and TXD = GPIO10, and those are Flash pins. Using these pins makes my ESP to restart continuously.
Serial0 pins are GPIO1 and 3 and I have tried this and this prints directly to the Serial Monitor.
Even so, I've tried it.
I have connected
TX1 1 to
RX2 16.
I have tried this on an ESP32 DevKitV4 Wrover-B.
Code: Select all
#include <Arduino.h>
HardwareSerial USE_SERIAL1(1);
HardwareSerial USE_SERIAL2(2);
#define TX1 1
#define RX1 3
#define TX2 17
#define RX2 16
void setup() {
Serial.begin(115200);
delay(1000);
USE_SERIAL1.begin(9600, SERIAL_8N1, RX1, TX1);
USE_SERIAL2.begin(9600, SERIAL_8N1, RX2, TX2);
USE_SERIAL1.write("SET detectionDirection 1");
String s = "SET detectionDirection 1";
for(int i=0; i<s.length(); i++) {
// Serial.println(s[i]);
}
// String Radar_String = "";
// if(USE_SERIAL2.available() > 0) {
// // Serial.println("USE_SERIAL1 is available.");
// while (USE_SERIAL2.available()) {
// char radar = USE_SERIAL1.read();
// Radar_String += radar; // this adds up all the input
// }
// }
// Serial.println(Radar_String);
}
void loop() {
delay(1000);
}
And this is the output:
Code: Select all
␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀
As you can see
USE_SERIAL1 prints directly to
Serial.
Code: Select all
String Radar_String = "";
if(USE_SERIAL2.available() > 0) {
// Serial.println("USE_SERIAL1 is available.");
while (USE_SERIAL2.available()) {
char radar = USE_SERIAL1.read();
Radar_String += radar; // this adds up all the input
}
}
Serial.println("read: " + Radar_String);
This bit of code doesn't print a thing.
How do I make it work ? Because I literally have no idea.