Serial communication failure!

Hello everyone,
I’ll start with that I’m rather new to Platformio so please be nice to me. I’m as most of people here Arduino IDE user and have several years experience with Arduino stuffs such as ATtemaga- and ATtiny chips, but, totally new to STM32 chips and thought it would be a great opportunity to use an advance programming IDE as VS code and Platformio… enough talking and let me explain my problem.

I’m using blue pill board to interfacing a bluetooth module and using SWD method to upload my code to the STM32 IC and that why I need a serial monitor to see messages that I get from the other side which is my mobile phone so I used an FTDI programming board to get a monitor!
I used USART1 for the FTDI and USART2 for the bluetooth, but whatever I did, I could just get message from the bluetooth and read it on the monitor, but couldn’t send any AT command.
I tried and switched many USART ports (pins) but, without any luck!
Here’s my code and .ini file and hope someone with same issue maybe can help me and thanks in advanced.
Tommy

#include <Arduino.h>
HardwareSerial Serial2(PA3, PA2);
void setup() {
  Serial.begin(9600);
  Serial2.begin(9600);
  
}
void loop() {
 while (Serial.available()) {
    Serial2.write(Serial.read());
  }
  while (Serial2.available()) {
    Serial.write(Serial2.read());
  }
}

##########################platformio.ini######################

[env:genericSTM32F103C8]
platform = ststm32
board = genericSTM32F103C8
framework = arduino
upload_protocol = stlink
monitor_port = COM[4]
monitor_speed = 9600
monitor_flags = 
    --echo 
    --eol 
    CRLF

##############################################################

OBS! Can someone tell me how to post a code in better way?

If you were able to get a message from USART2 where the bluetooth (I assume sume HC-05 thingy) is connected to and that was forwarded to the USART1 where your serial monitor is connected to, your firmware technically works (a serial-to-serial bridge).

The reason why you might not be able to send AT commands is because the bluetooth module needs to be powered up with a certain pin pulled high / low. That pin is usually labeled “KEY” on the module. Some modules don’t have this, but have a push button on the module that you must keep pressed while power is first applied.

See e.g.

Note: Since you already have a FTDI USB-serial adapter, you can connect it directly to the bluetooth module to configure it (e.g. with an external serial monitor program like hterm or PlatformIO’s serial monitor, both set for 38400 baud).

I’ve edited your post using Markdown formatting.

Thank you very much for your reply!
I figured out the problem. It’s the send_on_enter function which is totally new to me as I’m Arduino IDE user lol.
“monitor_filters = send_on_enter” wasn’t enough! I had to disable both DTR and RTS so it would be

monitor_filters = send_on_enter 
monitor_dtr = 0
monitor_rts = 0

And IT WORKS!

1 Like

Oh my, I was completeley off then :smiley:

Glad you worked it out though.

Hehe… but it works and hope this post can help someone with the same issue. I spent the whole day trying to figure out what’s wrong :frowning: