Hello, I tested some very simple code in Arduino IDE that sends a string between the Teensy4.1 and ESP8266 via SerialSoftware library.
One the Teensy side:
#include <SoftwareSerial.h>
SoftwareSerial Teensy_SoftSerial(7,8);
void setup() {
Serial.begin(115200);
Teensy_SoftSerial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
Teensy_SoftSerial.print("Hello World \n");
delay(500);
}
and on the ESP8266 side:
#include <SoftwareSerial.h>
SoftwareSerial Wifi_SoftSerial(D6,D5);
char c;
String dataIn;
void setup() {
Serial.begin(115200);
Wifi_SoftSerial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
while(Wifi_SoftSerial.available()>0)
{
c = Wifi_SoftSerial.read();
if (c == '\n') {break;}
else {dataIn+=c;}
}
if (c=='\n')
{
Serial.println(dataIn);
c=0;
dataIn="";
}
}
I see “Hello World” populate in the ESP8266 serial monitor successfully.
I cannot figure out how to achieve the same functionality between the Teensy4.1 and the RTL8720DN (BW16). I have tried using PB1 and PB2 with a similar code and using the built in AmebaSoftwareSerial library, with no success. Can someone show an example?
Hi @microPC,
Have you taken a look at the example SoftwareSerial_basic.ino in the SDK?
Please post the code that you are uploading into the BW16 board for us to help with the troubleshooting. Check that your wiring connections are correct.
Thank you.
Thank you for your reply I am very grateful to anyone who can help. I will absolutely show my code and upload pictures of my wiring when I get home from work this evening. Just posting this while driving to work. Please please have a look at my code and wiring when I upload.
Thanks,
Dan
Hi @Kelvin_Huang I have gotten it to work - sometimes you just need to know there is someone online willing to help you and that is enough to allow you to think straight.
For anyone it may benefit, here is the wiring and the code:
Teensy side:
SoftwareSerial Teensy_SoftSerial(7,8);
char c;
String dataIn;
void setup() {
Serial.begin(115200);
Teensy_SoftSerial.begin(115200);
}
void loop() {
while (Teensy_SoftSerial.available()>0)
{
c = Teensy_SoftSerial.read();
if (c == '\n') {break;}
else {dataIn+=c;}
}
if (c=='\n')
{
Serial.println(dataIn);
c=0;
dataIn="";
}
Teensy_SoftSerial.print("Hello Ameba \n");
delay(500);
}
BW16 side:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(PB2, PB1); // RX, TX
char c;
String dataIn;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(115200);
Serial.println("Goodnight moon!");
// set the data rate for the SoftwareSerial port
mySerial.begin(115200);
}
void loop() { // run over and over
while (mySerial.available()>0)
{
c = mySerial.read();
if (c == '\n') {break;}
else {dataIn+=c;}
}
if (c=='\n')
{
Serial.println(dataIn);
c=0;
dataIn="";
}
mySerial.print("Hello Teensy \n");
delay(500);
}
Wiring: On the Teensy pin 7 and 8 are connected to PB2 and PB1 on the RTL8720DN, and the Teensy 5V pin is connected to power line on bread board, GND to ground line on breadboard, and the RTL8720DN ground pin is connected to ground line on breadboard. See below images:
1 Like