I am currently facing a problem using an ESP32 and Matlab.
Everything works just fine except after Matlab closes the serial connection using fclose, the ESP32 resets. There are two ways to get out of this state, so the ESP32 works normally again:
1. Open the serial monitor in the Arduino IDE. The monitor shows the information of the bootloader. The ESP32 works after it until fclose happens again.
2. Use fopen in Matlab, wait a little bit and the ESP32 works again fine.
Both ways won't work for my project. The ESP32 needs to be always online since it's used as an access point.
Here is the a simple code example to simulate the problem:
ESP32:
Code: Select all
void setup()
{
Serial.begin(230400);
pinMode(32, OUTPUT);
digitalWrite(32, LOW);
}
void loop()
{
}
Matlab:
Code: Select all
s = serial('COM20');
set(s,'BaudRate',230400, 'timeout', 0.5);
fopen(s);
fclose(s);
Does anyone has any Idea?
I already used google and looked in a bunch of diffent forums but I couldn't find the correct solution to avoid this problem. I don't really understand the problem since it's just opening and closing a serial port.
Thanks in advance!