Teensy 4.1 master and ESP32 in Slave, possible ?

Status
Not open for further replies.

SPIRIT

Active member
Hello. I am working on my Hanpan project with FSR Pads and everything is working fine. I can connect it to a PC or a phone via USB. But I would like to add a bluetooth connection and I have an ESP32 card. Is it possible to place the ESP32 card as a slave? What solution to send a midi signal in BLE with a Teensy 4.1 ?
Thanks
 
Hello, I swim a little ... More simply, how to send a MIDI note from a Bluetooth from a Teensy, regardless of the use module HC-06 Adafruit BLE ESP32 ...
Thank you so much
 
Hello, because you have to start somewhere, the famous Hello World
But it doesn't work
I am connected on the Teensy 4 to RX1 (pin 0) and TX1 (pin 1), on ESP32 to RX2 (GIOP16) and TX2 (GIOP17)
I guess it's not so simple.

Thanks, and best regards


Teensy master
Code:
void setup()
{
  Serial.begin(9600); // USB is always 12 Mbit/sec
}

void loop()
{
  Serial.println("Hello World...");
  delay(1000);  // do not print too fast!
}


ESP32 slave
Code:
#define RXD2 16
#define TXD2 17

void setup() {
  Serial.begin(115200);
  Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);

}

void loop() {
 Serial.print("Receided :");
 Serial.println(Serial2.readString());
 delay(200);

}
 
You also need to connect the ground of both together.
...and you need to setup and user Serial1 on Teensy.
Your code is using Serial which is usb serial to the PC.

I have been using Serial1 at 2000000 baud. That's 200,000 characters per second, ridiculous!!
I'm not saying that the ESP32 can go that fast.
 
If I tell you you will not learn anything.
First of all Serial on Teensy is the USB port talking to your PC.
I suggest you read this. That way you will learn more about your teensy and how to use it and also how to solve your problem.
The solution is quite simple actually.
 
Thanks for your helps. I try this but don't work

Code:
void setup()
{
  Serial.begin(115200);
}

void loop()
{
  Serial1.println("Hello World...");
  delay(1000);  // do not print too fast!
}
 
Thanks for your helps. I try this but don't work

Code:
void setup()
{
  Serial.begin(115200);
}

void loop()
{
  Serial1.println("Hello World...");
  delay(1000);  // do not print too fast!
}

Did you initialise/start Serial1?

EDIT:
The baud rate MUST be the same on Teensy and ESP32, as well as parity and stop bit settings.
 
Last edited:
Better ?

Code:
// set this to the hardware serial port you wish to use
#define HWSERIAL Serial1

void setup()
{
  Serial.begin(115200);
  HWSERIAL.begin(9600);
}

void loop()
{
  HWSERIAL.print("Hello World...");  
  delay(1000);  // do not print too fast!
}
 
Well, I do get a response when I start teensy, but then the reception freezes. But it's starting to be interesting

Receided :Hello World...Hello World...Hello World...Hello World...Hello World...Hello World...Hello World...Hello World...Hello World...
Receided :
Receided :
 
Last edited:
Hi ! A small adjustment with BAUD at 921600 and delay, now it works perfectly.
Thank you very much for your patient and for taking the time to explain to me :)

Code:
//Teensy 4 Master
#define HWSERIAL Serial5

void setup()
{
  Serial.begin(115200);
  HWSERIAL.begin(921600);
}

void loop()
{
  HWSERIAL.println("Hello World...");  
  delay(1200);  // do not print too fast!
}

Code:
// ESP32 Slave
#define RXD2 16
#define TXD2 17

void setup() {
  Serial.begin(115200);
  Serial2.begin(921600, SERIAL_8N2, RXD2, TXD2);

}

void loop() {

Serial.print("Receided :");  
Serial.println(Serial2.readString());
delay(200); 
}
 
Status
Not open for further replies.
Back
Top